From cb2451ec805ee8ba9846d30cadf3f4029be378d3 Mon Sep 17 00:00:00 2001 From: youxia <243802688@qq.com> Date: Fri, 1 Mar 2024 14:20:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EbindTicker=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=BB=91=E5=AE=9A=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E5=99=A8=EF=BC=8C=E6=96=B0=E5=A2=9EcreateUpd?= =?UTF-8?q?ate=EF=BC=8C=E5=8F=AF=E4=BB=A5=E5=88=9B=E5=BB=BA=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=8F=AF=E7=94=A8update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 22 +++++- example/index.html | 25 ++++--- example/index.ts | 15 ++++ package.json | 2 +- src/hease.ts | 176 +++++++++++++++++++++------------------------ 5 files changed, 132 insertions(+), 108 deletions(-) create mode 100644 example/index.ts diff --git a/README.md b/README.md index b4561cd..475b9c6 100644 --- a/README.md +++ b/README.md @@ -27,4 +27,24 @@ const ani = hease(0, 1, 2000, EASE.linear) ani.stop(); // 立即完成动画 ani.complete(); -``` \ No newline at end of file +``` +### 如何播放无数次动画? +```ts +// ... +// 只需要在播放数传入Infinity +ani.play(Infinity) +// ... +``` +`注意:`无限播放动画将无法触发`onComplete`,但是可以通过手动调用`complete`方法触发 + +## 相关API补充 +``hease(from: number|number[], to: number|number[], duration = 1000, ease = EASE.linear)`` +创建一个缓动器 +``Hease.play()`` +直接播放1次动画,或者继续播放动画 +``Hease.play(num: number)`` +播放num次动画 +``bindTicker(fn: HeaseTicker)`` +绑定自定义刷新器 +``createUpdate(fn: (dt: number) => void)`` +创建一个刷新运行对象 \ No newline at end of file diff --git a/example/index.html b/example/index.html index a75b783..ff31f3c 100644 --- a/example/index.html +++ b/example/index.html @@ -1,13 +1,16 @@ -
- - -