Skip to content

Commit

Permalink
更新说明文件
Browse files Browse the repository at this point in the history
  • Loading branch information
hxg2050 committed Jan 11, 2024
1 parent a9a4fa2 commit 07dad7e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
## 一个超级精简的缓动库
# hease

> 一个超级精简的缓动库
[![publish](https://github.com/hxg2050/hease/actions/workflows/publish.yml/badge.svg)](https://github.com/hxg2050/hease/actions/workflows/publish.yml)
[![npm-downloads](https://img.shields.io/npm/dm/hease.svg)](https://www.npmjs.com/package/hease)
[![npm-version](https://img.shields.io/npm/v/hease.svg)](https://www.npmjs.com/package/hease)
内置缓动函数速查表请参考: [https://easings.net/zh-cn](https://easings.net/zh-cn)

## 安装
```sh
npm install hease
```

## 例子
```ts
import { hease, EASE } from 'hease';
// 播放,并注册相关事件
Expand Down
52 changes: 33 additions & 19 deletions src/hease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,45 @@ export interface Hease<T extends number | number[]> {
stop: () => this
}

export type HEaseValue = number | number[];

class _Hease extends EE {
constructor(public config: any) {
super();
}
type en<T, K> = never extends T ? K : never;

/**
* 起始状态
*/
from() {

}
type a = en<never, number>;

class _Hease<T extends HEaseValue = HEaseValue> extends EE {
/**
* 目标状态
* 起始属性
*/
to() {

}

from: T;
/**
* 缓动函数
* 结束属性
*/
ease() {

to: T;
/**
* 动画时长
*/
duration = 1000;

constructor(public config: {
from: T,
to: T,
duration?: number,
ease?: (x: number) => number
}) {
super();
this.from = config.from;
this.to = config.to;
if (Number.isFinite(config.duration)) {
this.duration = config.duration!;
}
}

/**
* 动画时长
* 缓动函数
*/
duration() {
ease() {

}

Expand Down Expand Up @@ -88,6 +96,12 @@ class _Hease extends EE {
}
}

// const he = new _Hease({
// 'from': [1],
// 'to': [1]
// });
// const he2 = he.from([1, 2]);//.to(1);
// he2.to(1);
/**
* 简易刷新器
*/
Expand Down

0 comments on commit 07dad7e

Please sign in to comment.