@x1a0ma17x/zeppos-fx 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +3 -0
- package/CHANGELOG.md +33 -0
- package/README.md +68 -136
- package/README_zh-CN.md +65 -142
- package/example/app.js +9 -9
- package/example/app.json +4 -10
- package/example/global.d.ts +1 -1
- package/example/jsconfig.json +9 -9
- package/example/package.json +17 -14
- package/example/page/i18n/en-US.po +1 -1
- package/example/page/index.js +45 -19
- package/example/page/index.r.layout.js +6 -6
- package/example/pnpm-lock.yaml +31 -0
- package/fx.js +6 -6
- package/package.json +1 -1
- package/example/app-side/i18n/en-US.po +0 -2
- package/example/app-side/index.js +0 -13
- package/example/page/i18n/fr-FR.po +0 -4
- package/example/page/i18n/ru-RU.po +0 -4
- package/example/page/i18n/zh-CN.po +0 -2
- package/example/page/i18n/zh-TW.po +0 -4
- package/example/page/index.anim.js +0 -37
- package/example/page/index.style.js +0 -13
- package/example/setting/i18n/en-US.po +0 -2
- package/example/setting/index.js +0 -7
- package/src/example/app.js +0 -10
- package/src/example/app.json +0 -46
- package/src/example/assets/default.b/icon.png +0 -0
- package/src/example/assets/default.r/icon.png +0 -0
- package/src/example/assets/default.s/icon.png +0 -0
- package/src/example/global.d.ts +0 -1
- package/src/example/jsconfig.json +0 -9
- package/src/example/libs/fx.js +0 -325
- package/src/example/package.json +0 -14
- package/src/example/page/anim.js +0 -60
- package/src/example/page/i18n/en-US.po +0 -2
- package/src/example/page/index.js +0 -13
- package/src/example/page/index.r.layout.js +0 -6
package/example/page/index.js
CHANGED
|
@@ -1,19 +1,45 @@
|
|
|
1
|
-
import hmUI from "@zos/ui";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import * as hmUI from "@zos/ui";
|
|
2
|
+
import { Fx } from "@x1a0ma17x/zeppos-fx";
|
|
3
|
+
|
|
4
|
+
Page({
|
|
5
|
+
build() {
|
|
6
|
+
const text = hmUI.createWidget(hmUI.widget.TEXT, {
|
|
7
|
+
// 创建一个简单的 TEXT 控件
|
|
8
|
+
x: 0,
|
|
9
|
+
y: 120,
|
|
10
|
+
w: 288,
|
|
11
|
+
h: 46,
|
|
12
|
+
color: 0xffffff,
|
|
13
|
+
text_size: 36,
|
|
14
|
+
align_h: hmUI.align.CENTER_H,
|
|
15
|
+
align_v: hmUI.align.CENTER_V,
|
|
16
|
+
text_style: hmUI.text_style.NONE,
|
|
17
|
+
text: "HELLO ZEPPOS",
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const fx = new Fx({
|
|
21
|
+
delay: 0, // 延迟执行的时间(毫秒)
|
|
22
|
+
begin: 0, // 初始函数值
|
|
23
|
+
end: 1, // 结束函数值
|
|
24
|
+
fps: 60, // 帧率
|
|
25
|
+
time: 1000, // 总时长(毫秒)
|
|
26
|
+
style: Fx.Styles.EASE_IN_OUT_QUAD, // 预设类型
|
|
27
|
+
enabled: true, // 是否默认启用(即创建Fx实例时自动启动)
|
|
28
|
+
onStop() {
|
|
29
|
+
// 动画结束后的回调函数
|
|
30
|
+
console.log("anim stop");
|
|
31
|
+
},
|
|
32
|
+
func: (result) => {
|
|
33
|
+
// 每一帧的回调函数,参数为当前函数值,取值范围为[begin, end]
|
|
34
|
+
text.setProperty(hmUI.prop.MORE, {
|
|
35
|
+
x: 300 * result,
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// 状态控制
|
|
41
|
+
fx.start();
|
|
42
|
+
// fx.pause();
|
|
43
|
+
// fx.stop();
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { px } from "@zos/utils";
|
|
2
|
-
|
|
3
|
-
export const TEXT_STYLE = {
|
|
4
|
-
x: px(0),
|
|
5
|
-
y: px(0),
|
|
6
|
-
}
|
|
1
|
+
import { px } from "@zos/utils";
|
|
2
|
+
|
|
3
|
+
export const TEXT_STYLE = {
|
|
4
|
+
x: px(0),
|
|
5
|
+
y: px(0),
|
|
6
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
lockfileVersion: '9.0'
|
|
2
|
+
|
|
3
|
+
settings:
|
|
4
|
+
autoInstallPeers: true
|
|
5
|
+
excludeLinksFromLockfile: false
|
|
6
|
+
|
|
7
|
+
importers:
|
|
8
|
+
|
|
9
|
+
.:
|
|
10
|
+
dependencies:
|
|
11
|
+
'@x1a0ma17x/zeppos-fx':
|
|
12
|
+
specifier: ^2.0.3
|
|
13
|
+
version: 2.0.3
|
|
14
|
+
devDependencies:
|
|
15
|
+
'@zeppos/device-types':
|
|
16
|
+
specifier: ^3.0.0
|
|
17
|
+
version: 3.0.1
|
|
18
|
+
|
|
19
|
+
packages:
|
|
20
|
+
|
|
21
|
+
'@x1a0ma17x/zeppos-fx@2.0.3':
|
|
22
|
+
resolution: {integrity: sha512-mhZhlWRZjNXyhNrKHHjtp4Z9rOIQhDd5SxDoPIqVwdy8tialvAAe4qjxCcB+tAMYkLgs6CUj9uDmq7ZQZnxwfQ==}
|
|
23
|
+
|
|
24
|
+
'@zeppos/device-types@3.0.1':
|
|
25
|
+
resolution: {integrity: sha512-7rUsKLFiTdwIU3NarEKbEoQjr2X1kE6/8ra+mM3+zXDnwhELPowwC4Sl5UGS71PjTa9Rb+s4WygOHkjeEmJcoA==}
|
|
26
|
+
|
|
27
|
+
snapshots:
|
|
28
|
+
|
|
29
|
+
'@x1a0ma17x/zeppos-fx@2.0.3': {}
|
|
30
|
+
|
|
31
|
+
'@zeppos/device-types@3.0.1': {}
|
package/fx.js
CHANGED
|
@@ -39,7 +39,7 @@ export class Fx {
|
|
|
39
39
|
* @param {number} [options.end=100] 目标函数值
|
|
40
40
|
* @param {number} [options.x_start] 自定义函数的开始x坐标
|
|
41
41
|
* @param {number} [options.x_end] 自定义函数的结束x坐标
|
|
42
|
-
* @param {number} [options.time=
|
|
42
|
+
* @param {number} [options.time=1000] 执行总时间(毫秒)
|
|
43
43
|
* @param {Function} [options.fx] 自定义x=>y动画函数
|
|
44
44
|
* @param {Function} options.func 每帧执行的回调函数,参数为当前值
|
|
45
45
|
* @param {number} [options.fps=60] 动画帧率
|
|
@@ -53,7 +53,7 @@ export class Fx {
|
|
|
53
53
|
end = 100,
|
|
54
54
|
x_start,
|
|
55
55
|
x_end,
|
|
56
|
-
time =
|
|
56
|
+
time = 1000,
|
|
57
57
|
fx,
|
|
58
58
|
func,
|
|
59
59
|
fps = 60,
|
|
@@ -77,13 +77,13 @@ export class Fx {
|
|
|
77
77
|
this.x_start = x_start != null ? x_start * 1.0 : 0;
|
|
78
78
|
this.x_end = x_end != null ? x_end * 1.0 : 1;
|
|
79
79
|
this.fx = fx;
|
|
80
|
-
this.speed = (this.x_end - this.x_start) / (
|
|
80
|
+
this.speed = (this.x_end - this.x_start) / (fps * time / 1000);
|
|
81
81
|
} else {
|
|
82
82
|
// 使用预设样式
|
|
83
83
|
const styleName = this._getStyleName(style);
|
|
84
|
-
this.fx = (x) => Fx.Easing[styleName](x, begin, end, fps * time);
|
|
84
|
+
this.fx = (x) => Fx.Easing[styleName](x, begin, end, fps * time / 1000);
|
|
85
85
|
this.x_start = 0;
|
|
86
|
-
this.x_end = fps * time;
|
|
86
|
+
this.x_end = fps * time / 1000;
|
|
87
87
|
this.speed = 1;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -191,7 +191,7 @@ export class Fx {
|
|
|
191
191
|
this.func(this.fx(this.x_now));
|
|
192
192
|
}, this.per_clock);
|
|
193
193
|
|
|
194
|
-
this.timer.start();
|
|
194
|
+
this.timer.start(this.delay);
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Fx } from "../../fx";
|
|
2
|
-
const Track_1 = [
|
|
3
|
-
{
|
|
4
|
-
props: {
|
|
5
|
-
startTime: 1,
|
|
6
|
-
duration: 1,
|
|
7
|
-
fps: 1,
|
|
8
|
-
fx_style: Fx.Styles.LINEAR,
|
|
9
|
-
repeat: true,
|
|
10
|
-
},
|
|
11
|
-
func: (result) => {
|
|
12
|
-
console.log("result1 ", result);
|
|
13
|
-
return;
|
|
14
|
-
},
|
|
15
|
-
onStop: (result) => {
|
|
16
|
-
return;
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
props: {
|
|
21
|
-
startTime: 1,
|
|
22
|
-
duration: 1,
|
|
23
|
-
fps: 1,
|
|
24
|
-
fx_style: Fx.Styles.LINEAR,
|
|
25
|
-
repeat: true,
|
|
26
|
-
},
|
|
27
|
-
func: (result) => {
|
|
28
|
-
console.log("result2 ", result);
|
|
29
|
-
return;
|
|
30
|
-
},
|
|
31
|
-
onStop: (result) => {
|
|
32
|
-
return;
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
export const AnimProfile = [Track_1];
|
package/example/setting/index.js
DELETED
package/src/example/app.js
DELETED
package/src/example/app.json
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"configVersion": "v3",
|
|
3
|
-
"app": {
|
|
4
|
-
"appId": 25966,
|
|
5
|
-
"appName": "Empty",
|
|
6
|
-
"appType": "app",
|
|
7
|
-
"version": {
|
|
8
|
-
"code": 1,
|
|
9
|
-
"name": "1.0.0"
|
|
10
|
-
},
|
|
11
|
-
"icon": "icon.png",
|
|
12
|
-
"vender": "zepp",
|
|
13
|
-
"description": "empty application"
|
|
14
|
-
},
|
|
15
|
-
"permissions": [],
|
|
16
|
-
"runtime": {
|
|
17
|
-
"apiVersion": {
|
|
18
|
-
"compatible": "3.0.0",
|
|
19
|
-
"target": "3.0.0",
|
|
20
|
-
"minVersion": "3.0"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"targets": {
|
|
24
|
-
"default": {
|
|
25
|
-
"module": {
|
|
26
|
-
"page": {
|
|
27
|
-
"pages": [
|
|
28
|
-
"page/index"
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"platforms": [
|
|
33
|
-
{
|
|
34
|
-
"st": "r",
|
|
35
|
-
"dw": 480
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"i18n": {
|
|
41
|
-
"en-US": {
|
|
42
|
-
"appName": "Empty"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"defaultLanguage": "en-US"
|
|
46
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/example/global.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference path="node_modules/@zeppos/device-types/dist/index.d.ts" />
|
package/src/example/libs/fx.js
DELETED
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* fx.js
|
|
3
|
-
* @description A library for providing animations in ZeppOS. 一个用于在ZeppOS中提供动画的库
|
|
4
|
-
* @version 3.0.0
|
|
5
|
-
* @date 2024/11/02
|
|
6
|
-
* @author XiaomaiTX
|
|
7
|
-
* @license MIT
|
|
8
|
-
* https://github.com/XiaomaiTX/zeppos-fx
|
|
9
|
-
*
|
|
10
|
-
* **/
|
|
11
|
-
|
|
12
|
-
export class Fx {
|
|
13
|
-
constructor(params) {
|
|
14
|
-
this.tracks = params.tracks;
|
|
15
|
-
this.metadata = params.metadata;
|
|
16
|
-
this.status = "stop";
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
start() {
|
|
20
|
-
if (this.status == "stop" || this.status == "pause") {
|
|
21
|
-
this.status = "start";
|
|
22
|
-
for (let i = 0; i < this.tracks.length; i++) {
|
|
23
|
-
let track = this.tracks[i];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
tick(track) {
|
|
28
|
-
/**
|
|
29
|
-
* @param track
|
|
30
|
-
* @param track.progress 进度
|
|
31
|
-
* @param track.totalFrame 总帧数
|
|
32
|
-
*/
|
|
33
|
-
if (
|
|
34
|
-
this.status == "start" &&
|
|
35
|
-
track.progress < track.totalFrame
|
|
36
|
-
) {
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
stop() {
|
|
41
|
-
if (this.status != "stop") {
|
|
42
|
-
this.status = "stop";
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
restart() {
|
|
47
|
-
this.status = "start";
|
|
48
|
-
}
|
|
49
|
-
pause() {
|
|
50
|
-
if (this.status == "start") {
|
|
51
|
-
this.status = "pause";
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
getStatus() {
|
|
55
|
-
return this.status;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
Fx.Styles = {
|
|
59
|
-
/**
|
|
60
|
-
* List of preset styles
|
|
61
|
-
* @example EXAMPLE: indexNumber,
|
|
62
|
-
*
|
|
63
|
-
* */
|
|
64
|
-
// TODO Add more style
|
|
65
|
-
|
|
66
|
-
// The following presets are available for reference https://easings.net/
|
|
67
|
-
// 以下预设可参考 https://easings.net/
|
|
68
|
-
|
|
69
|
-
LINEAR: function (now_x, begin, end, max_x) {
|
|
70
|
-
function math_func(x) {
|
|
71
|
-
return x;
|
|
72
|
-
}
|
|
73
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
74
|
-
},
|
|
75
|
-
EASE_IN_SINE: function (now_x, begin, end, max_x) {
|
|
76
|
-
function math_func(x) {
|
|
77
|
-
return 1 - cos((x * Math.PI) / 2);
|
|
78
|
-
}
|
|
79
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
80
|
-
},
|
|
81
|
-
EASE_OUT_SINE: function (now_x, begin, end, max_x) {
|
|
82
|
-
function math_func(x) {
|
|
83
|
-
return sin((x * Math.PI) / 2);
|
|
84
|
-
}
|
|
85
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
86
|
-
},
|
|
87
|
-
EASE_IN_OUT_SINE: function (now_x, begin, end, max_x) {
|
|
88
|
-
function math_func(x) {
|
|
89
|
-
return -(cos(Math.PI * x) - 1) / 2;
|
|
90
|
-
}
|
|
91
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
92
|
-
},
|
|
93
|
-
EASE_IN_QUAD: function (now_x, begin, end, max_x) {
|
|
94
|
-
function math_func(x) {
|
|
95
|
-
return x * x;
|
|
96
|
-
}
|
|
97
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
98
|
-
},
|
|
99
|
-
EASE_OUT_QUAD: function (now_x, begin, end, max_x) {
|
|
100
|
-
function math_func(x) {
|
|
101
|
-
return 1 - (1 - x) * (1 - x);
|
|
102
|
-
}
|
|
103
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
104
|
-
},
|
|
105
|
-
EASE_IN_OUT_QUAD: function (now_x, begin, end, max_x) {
|
|
106
|
-
function math_func(x) {
|
|
107
|
-
return x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2;
|
|
108
|
-
}
|
|
109
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
110
|
-
},
|
|
111
|
-
EASE_IN_CUBIC: function (now_x, begin, end, max_x) {
|
|
112
|
-
function math_func(x) {
|
|
113
|
-
return x * x * x;
|
|
114
|
-
}
|
|
115
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
116
|
-
},
|
|
117
|
-
EASE_OUT_CUBIC: function (now_x, begin, end, max_x) {
|
|
118
|
-
function math_func(x) {
|
|
119
|
-
return 1 - Math.pow(1 - x, 3);
|
|
120
|
-
}
|
|
121
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
122
|
-
},
|
|
123
|
-
EASE_IN_OUT_CUBIC: function (now_x, begin, end, max_x) {
|
|
124
|
-
function math_func(x) {
|
|
125
|
-
return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
|
|
126
|
-
}
|
|
127
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
128
|
-
},
|
|
129
|
-
EASE_IN_QUART: function (now_x, begin, end, max_x) {
|
|
130
|
-
function math_func(x) {
|
|
131
|
-
return x * x * x * x;
|
|
132
|
-
}
|
|
133
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
134
|
-
},
|
|
135
|
-
EASE_OUT_QUART: function (now_x, begin, end, max_x) {
|
|
136
|
-
function math_func(x) {
|
|
137
|
-
return 1 - Math.pow(1 - x, 4);
|
|
138
|
-
}
|
|
139
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
140
|
-
},
|
|
141
|
-
EASE_IN_OUT_QUART: function (now_x, begin, end, max_x) {
|
|
142
|
-
function math_func(x) {
|
|
143
|
-
return x < 0.5
|
|
144
|
-
? 8 * x * x * x * x
|
|
145
|
-
: 1 - Math.pow(-2 * x + 2, 4) / 2;
|
|
146
|
-
}
|
|
147
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
148
|
-
},
|
|
149
|
-
EASE_IN_QUINT: function (now_x, begin, end, max_x) {
|
|
150
|
-
function math_func(x) {
|
|
151
|
-
return x * x * x * x * x;
|
|
152
|
-
}
|
|
153
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
154
|
-
},
|
|
155
|
-
EASE_OUT_QUINT: function (now_x, begin, end, max_x) {
|
|
156
|
-
function math_func(x) {
|
|
157
|
-
return 1 - Math.pow(1 - x, 4);
|
|
158
|
-
}
|
|
159
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
160
|
-
},
|
|
161
|
-
EASE_IN_OUT_QUINT: function (now_x, begin, end, max_x) {
|
|
162
|
-
function math_func(x) {
|
|
163
|
-
return x < 0.5
|
|
164
|
-
? 16 * x * x * x * x * x
|
|
165
|
-
: 1 - Math.pow(-2 * x + 2, 5) / 2;
|
|
166
|
-
}
|
|
167
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
168
|
-
},
|
|
169
|
-
EASE_IN_EXPO: function (now_x, begin, end, max_x) {
|
|
170
|
-
function math_func(x) {
|
|
171
|
-
return x === 0 ? 0 : Math.pow(2, 10 * x - 10);
|
|
172
|
-
}
|
|
173
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
174
|
-
},
|
|
175
|
-
EASE_OUT_EXPO: function (now_x, begin, end, max_x) {
|
|
176
|
-
function math_func(x) {
|
|
177
|
-
return x === 1 ? 1 : 1 - Math.pow(2, -10 * x);
|
|
178
|
-
}
|
|
179
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
180
|
-
},
|
|
181
|
-
EASE_IN_OUT_EXPO: function (now_x, begin, end, max_x) {
|
|
182
|
-
function math_func(x) {
|
|
183
|
-
return x === 0
|
|
184
|
-
? 0
|
|
185
|
-
: x === 1
|
|
186
|
-
? 1
|
|
187
|
-
: x < 0.5
|
|
188
|
-
? Math.pow(2, 20 * x - 10) / 2
|
|
189
|
-
: (2 - Math.pow(2, -20 * x + 10)) / 2;
|
|
190
|
-
}
|
|
191
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
192
|
-
},
|
|
193
|
-
EASE_IN_CIRC: function (now_x, begin, end, max_x) {
|
|
194
|
-
function math_func(x) {
|
|
195
|
-
return 1 - Math.sqrt(1 - Math.pow(x, 2));
|
|
196
|
-
}
|
|
197
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
198
|
-
},
|
|
199
|
-
EASE_OUT_CIRC: function (now_x, begin, end, max_x) {
|
|
200
|
-
function math_func(x) {
|
|
201
|
-
return Math.sqrt(1 - Math.pow(x - 1, 2));
|
|
202
|
-
}
|
|
203
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
204
|
-
},
|
|
205
|
-
EASE_IN_OUT_CIRC: function (now_x, begin, end, max_x) {
|
|
206
|
-
function math_func(x) {
|
|
207
|
-
return x < 0.5
|
|
208
|
-
? (1 - Math.sqrt(1 - Math.pow(2 * x, 2))) / 2
|
|
209
|
-
: (Math.sqrt(1 - Math.pow(-2 * x + 2, 2)) + 1) / 2;
|
|
210
|
-
}
|
|
211
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
212
|
-
},
|
|
213
|
-
EASE_IN_BACK: function (now_x, begin, end, max_x) {
|
|
214
|
-
function math_func(x) {
|
|
215
|
-
return 1.70158 + 1 * x * x * x - 1.70158 * x * x;
|
|
216
|
-
}
|
|
217
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
218
|
-
},
|
|
219
|
-
EASE_OUT_BACK: function (now_x, begin, end, max_x) {
|
|
220
|
-
function math_func(x) {
|
|
221
|
-
return (
|
|
222
|
-
1 +
|
|
223
|
-
1.70158 +
|
|
224
|
-
1 * Math.pow(x - 1, 3) +
|
|
225
|
-
1.70158 * Math.pow(x - 1, 2)
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
229
|
-
},
|
|
230
|
-
EASE_IN_OUT_BACK: function (now_x, begin, end, max_x) {
|
|
231
|
-
function math_func(x) {
|
|
232
|
-
return x < 0.5
|
|
233
|
-
? (Math.pow(2 * x, 2) *
|
|
234
|
-
((1.70158 * 1.525 + 1) * 2 * x - 1.70158 * 1.525)) /
|
|
235
|
-
2
|
|
236
|
-
: (Math.pow(2 * x - 2, 2) *
|
|
237
|
-
((1.70158 * 1.525 + 1) * (x * 2 - 2) + 1.70158 * 1.525) +
|
|
238
|
-
2) /
|
|
239
|
-
2;
|
|
240
|
-
}
|
|
241
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
242
|
-
},
|
|
243
|
-
EASE_IN_ELASTIC: function (now_x, begin, end, max_x) {
|
|
244
|
-
function math_func(x) {
|
|
245
|
-
return x === 0
|
|
246
|
-
? 0
|
|
247
|
-
: x === 1
|
|
248
|
-
? 1
|
|
249
|
-
: -Math.pow(2, 10 * x - 10) *
|
|
250
|
-
sin(((x * 10 - 10.75) * (2 * Math.PI)) / 3);
|
|
251
|
-
}
|
|
252
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
253
|
-
},
|
|
254
|
-
EASE_OUT_ELASTIC: function (now_x, begin, end, max_x) {
|
|
255
|
-
function math_func(x) {
|
|
256
|
-
return x === 0
|
|
257
|
-
? 0
|
|
258
|
-
: x === 1
|
|
259
|
-
? 1
|
|
260
|
-
: Math.pow(2, -10 * x) *
|
|
261
|
-
sin(((x * 10 - 0.75) * (2 * Math.PI)) / 3) +
|
|
262
|
-
1;
|
|
263
|
-
}
|
|
264
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
265
|
-
},
|
|
266
|
-
EASE_IN_OUT_ELASTIC: function (now_x, begin, end, max_x) {
|
|
267
|
-
function math_func(x) {
|
|
268
|
-
return x === 0
|
|
269
|
-
? 0
|
|
270
|
-
: x === 1
|
|
271
|
-
? 1
|
|
272
|
-
: x < 0.5
|
|
273
|
-
? -(
|
|
274
|
-
Math.pow(2, 20 * x - 10) *
|
|
275
|
-
sin(((20 * x - 11.125) * (2 * Math.PI)) / 4.5)
|
|
276
|
-
) / 2
|
|
277
|
-
: (Math.pow(2, -20 * x + 10) *
|
|
278
|
-
sin(((20 * x - 11.125) * (2 * Math.PI)) / 4.5)) /
|
|
279
|
-
2 +
|
|
280
|
-
1;
|
|
281
|
-
}
|
|
282
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
283
|
-
},
|
|
284
|
-
EASE_IN_BOUNCE: function (now_x, begin, end, max_x) {
|
|
285
|
-
function math_func(x) {
|
|
286
|
-
return 1 - Fx.Styles.bounceOut(1 - x);
|
|
287
|
-
}
|
|
288
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
289
|
-
},
|
|
290
|
-
EASE_OUT_BOUNCE: function (now_x, begin, end, max_x) {
|
|
291
|
-
function math_func(x) {
|
|
292
|
-
return Fx.Styles.bounceOut(x);
|
|
293
|
-
}
|
|
294
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
295
|
-
},
|
|
296
|
-
EASE_IN_OUT_BOUNCE: function (now_x, begin, end, max_x) {
|
|
297
|
-
function math_func(x) {
|
|
298
|
-
return x < 0.5
|
|
299
|
-
? (1 - Fx.Styles.bounceOut(1 - 2 * x)) / 2
|
|
300
|
-
: (1 + Fx.Styles.bounceOut(2 * x - 1)) / 2;
|
|
301
|
-
}
|
|
302
|
-
return begin + (end - begin) * math_func(now_x / max_x);
|
|
303
|
-
},
|
|
304
|
-
bounceOut: function (x) {
|
|
305
|
-
/**
|
|
306
|
-
* Returns the bounce out result of x
|
|
307
|
-
* @param {number} x
|
|
308
|
-
* @returns {number}
|
|
309
|
-
*/
|
|
310
|
-
const n1 = 7.5625;
|
|
311
|
-
const d1 = 2.75;
|
|
312
|
-
|
|
313
|
-
if (x < 1 / d1) {
|
|
314
|
-
return n1 * x * x;
|
|
315
|
-
} else if (x < 2 / d1) {
|
|
316
|
-
return n1 * (x -= 1.5 / d1) * x + 0.75;
|
|
317
|
-
} else if (x < 2.5 / d1) {
|
|
318
|
-
return n1 * (x -= 2.25 / d1) * x + 0.9375;
|
|
319
|
-
} else {
|
|
320
|
-
return n1 * (x -= 2.625 / d1) * x + 0.984375;
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
export default Fx;
|