A library for providing simple animations in ZeppOS.
中文文档(在写了别催了) »
Download
·
Report Bug
·
Request Feature
A library for providing simple animations in ZeppOS. You can use simple functions to add animations to your UI widgets
Here's why:
Use the Usage to easily get started.
The content here will help you get familiar with the program quickly.
Before using this library, please make sure you already have an understanding of ZeppOS applet development, you can refer to the ZeppOS official documentation.
Also, you need a code editor(Like Microsoft VSCode)
and knowledge of JavaScript
.
To use this library, you need to create a ZeppOS applet project first.refer to the ZeppOS quick start.
Please download the latest fx.js
file in the Releases, and place fx.js
in the utils/
directory of the root of the applet
Add a reference to fx.js in the project
import { Fx } from "../utils/fx"; // Replace with the path to your fx.js
At this point, you're ready to use the fx.js
library
You can refer to the following example to use this library and you should get the expected results like this: The position of the text moves from x=100 to x=200 with a non-linear motion effect
const text = hmUI.createWidget(hmUI.widget.TEXT, {
// create a text widget
x: 100,
y: 120,
w: 288,
h: 46,
color: 0xffffff,
text_size: 36,
align_h: hmUI.align.CENTER_H,
align_v: hmUI.align.CENTER_V,
text_style: hmUI.text_style.NONE,
text: 'HELLO ZEPPOS'
})
let fx = new Fx({
begin: 100, // Initial value of function.
end: 200, // Target value of function.
fps: 60, // FPS.
time: 1, // Total during time (s).
style: Fx.Styles.EASE_IN_OUT_QUAD, // Types of animation presets used, seeing @Fx.Style.
onStop() {
console.log("anim stop");
}, // Callback function at the end of the animation.
// Callback function for each frame, the parameter is the current function value, the value range is [begin, end]
func: (result) => text.setProperty(hmUI.prop.X, result),
});
fx.restart(); // Replay animation can be called multiple times.
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE.txt
for more information.
XiaomaiTX - i@lenrome.cn
Project Link: https://github.com/your_username/repo_name