oipage 2.0.0 → 2.0.1-alpha.0
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/CHANGELOG +7 -0
- package/nodejs/animation/index.d.ts +10 -0
- package/nodejs/animation/index.js +38 -9
- package/nodejs/logform/index.d.ts +1 -1
- package/nodejs/option/index.js +2 -0
- package/package.json +1 -1
- package/web/animation/index.d.ts +10 -0
- package/web/animation/index.js +38 -9
- package/web/option/index.js +2 -0
- package/web/performChunk/index.d.ts +1 -1
package/CHANGELOG
CHANGED
|
@@ -27,7 +27,10 @@ function animation(doback, duration, callback) {
|
|
|
27
27
|
let id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0);
|
|
28
28
|
$timers.push({
|
|
29
29
|
"id": id,
|
|
30
|
-
"createTime": new Date(),
|
|
30
|
+
"createTime": new Date(), // 开始时间
|
|
31
|
+
"pauseTime": -1, // 暂停的时间,继续运行的时候,借助此计算暂停的时间差
|
|
32
|
+
"pauseKeepTime": 0, // 暂停用去的时间
|
|
33
|
+
"status": "running", // running(运行中), paused(暂停中)
|
|
31
34
|
"tick": tick,
|
|
32
35
|
"duration": duration,
|
|
33
36
|
"callback": callback
|
|
@@ -70,15 +73,21 @@ function animation(doback, duration, callback) {
|
|
|
70
73
|
callback = timer.callback;
|
|
71
74
|
|
|
72
75
|
//执行
|
|
73
|
-
passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
|
|
76
|
+
passTime = (+new Date().valueOf() - createTime.valueOf() - timer.pauseKeepTime) / duration;
|
|
74
77
|
passTime = passTime > 1 ? 1 : passTime;
|
|
75
|
-
|
|
76
|
-
if (
|
|
78
|
+
|
|
79
|
+
if (timer.status === "running") {
|
|
80
|
+
tick(passTime);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 只有当动画没有结束或者动画处于暂停状态时,才继续添加到timers堆栈
|
|
84
|
+
if ((passTime < 1 || timer.status === "paused") && timer.id) {
|
|
77
85
|
//动画没有结束再添加
|
|
78
86
|
$timers.push(timer);
|
|
79
87
|
} else {
|
|
80
88
|
callback(passTime);
|
|
81
89
|
}
|
|
90
|
+
|
|
82
91
|
}
|
|
83
92
|
if ($timers.length <= 0) {
|
|
84
93
|
clock.stop();
|
|
@@ -105,14 +114,34 @@ function animation(doback, duration, callback) {
|
|
|
105
114
|
}, duration, callback);
|
|
106
115
|
|
|
107
116
|
return {
|
|
108
|
-
//
|
|
109
|
-
// 用于在动画结束前结束动画
|
|
117
|
+
// 结束动画
|
|
110
118
|
stop: function () {
|
|
111
|
-
let i
|
|
112
|
-
for (i in $timers) {
|
|
119
|
+
for (let i in $timers) {
|
|
113
120
|
if ($timers[i].id == id) {
|
|
114
121
|
$timers[i].id = void 0;
|
|
115
|
-
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
// 暂停动画
|
|
126
|
+
pause: function () {
|
|
127
|
+
for (let i in $timers) {
|
|
128
|
+
if ($timers[i].id == id) {
|
|
129
|
+
if ($timers[i].pauseTime === -1) {
|
|
130
|
+
$timers[i].pauseTime = new Date();
|
|
131
|
+
$timers[i].status = "paused";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
// 继续动画
|
|
137
|
+
resume: function () {
|
|
138
|
+
for (let i in $timers) {
|
|
139
|
+
if ($timers[i].id == id) {
|
|
140
|
+
if ($timers[i].pauseTime !== -1) {
|
|
141
|
+
$timers[i].pauseKeepTime += (new Date().valueOf() - $timers[i].pauseTime.valueOf());
|
|
142
|
+
$timers[i].pauseTime = -1;
|
|
143
|
+
$timers[i].status = "running";
|
|
144
|
+
}
|
|
116
145
|
}
|
|
117
146
|
}
|
|
118
147
|
}
|
package/nodejs/option/index.js
CHANGED
package/package.json
CHANGED
package/web/animation/index.d.ts
CHANGED
package/web/animation/index.js
CHANGED
|
@@ -27,7 +27,10 @@ export function animation(doback, duration, callback) {
|
|
|
27
27
|
let id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0);
|
|
28
28
|
$timers.push({
|
|
29
29
|
"id": id,
|
|
30
|
-
"createTime": new Date(),
|
|
30
|
+
"createTime": new Date(), // 开始时间
|
|
31
|
+
"pauseTime": -1, // 暂停的时间,继续运行的时候,借助此计算暂停的时间差
|
|
32
|
+
"pauseKeepTime": 0, // 暂停用去的时间
|
|
33
|
+
"status": "running", // running(运行中), paused(暂停中)
|
|
31
34
|
"tick": tick,
|
|
32
35
|
"duration": duration,
|
|
33
36
|
"callback": callback
|
|
@@ -70,15 +73,21 @@ export function animation(doback, duration, callback) {
|
|
|
70
73
|
callback = timer.callback;
|
|
71
74
|
|
|
72
75
|
//执行
|
|
73
|
-
passTime = (+new Date().valueOf() - createTime.valueOf()) / duration;
|
|
76
|
+
passTime = (+new Date().valueOf() - createTime.valueOf() - timer.pauseKeepTime) / duration;
|
|
74
77
|
passTime = passTime > 1 ? 1 : passTime;
|
|
75
|
-
|
|
76
|
-
if (
|
|
78
|
+
|
|
79
|
+
if (timer.status === "running") {
|
|
80
|
+
tick(passTime);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 只有当动画没有结束或者动画处于暂停状态时,才继续添加到timers堆栈
|
|
84
|
+
if ((passTime < 1 || timer.status === "paused") && timer.id) {
|
|
77
85
|
//动画没有结束再添加
|
|
78
86
|
$timers.push(timer);
|
|
79
87
|
} else {
|
|
80
88
|
callback(passTime);
|
|
81
89
|
}
|
|
90
|
+
|
|
82
91
|
}
|
|
83
92
|
if ($timers.length <= 0) {
|
|
84
93
|
clock.stop();
|
|
@@ -105,14 +114,34 @@ export function animation(doback, duration, callback) {
|
|
|
105
114
|
}, duration, callback);
|
|
106
115
|
|
|
107
116
|
return {
|
|
108
|
-
//
|
|
109
|
-
// 用于在动画结束前结束动画
|
|
117
|
+
// 结束动画
|
|
110
118
|
stop: function () {
|
|
111
|
-
let i
|
|
112
|
-
for (i in $timers) {
|
|
119
|
+
for (let i in $timers) {
|
|
113
120
|
if ($timers[i].id == id) {
|
|
114
121
|
$timers[i].id = void 0;
|
|
115
|
-
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
// 暂停动画
|
|
126
|
+
pause: function () {
|
|
127
|
+
for (let i in $timers) {
|
|
128
|
+
if ($timers[i].id == id) {
|
|
129
|
+
if ($timers[i].pauseTime === -1) {
|
|
130
|
+
$timers[i].pauseTime = new Date();
|
|
131
|
+
$timers[i].status = "paused";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
// 继续动画
|
|
137
|
+
resume: function () {
|
|
138
|
+
for (let i in $timers) {
|
|
139
|
+
if ($timers[i].id == id) {
|
|
140
|
+
if ($timers[i].pauseTime !== -1) {
|
|
141
|
+
$timers[i].pauseKeepTime += (new Date().valueOf() - $timers[i].pauseTime.valueOf());
|
|
142
|
+
$timers[i].pauseTime = -1;
|
|
143
|
+
$timers[i].status = "running";
|
|
144
|
+
}
|
|
116
145
|
}
|
|
117
146
|
}
|
|
118
147
|
}
|
package/web/option/index.js
CHANGED