@visactor/vrender-core 0.22.6 → 0.23.0-alpha.2

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.
Files changed (188) hide show
  1. package/cjs/canvas/constants.js +1 -2
  2. package/cjs/color-string/index.js +1 -2
  3. package/cjs/color-string/interpolate.d.ts +1 -0
  4. package/cjs/color-string/interpolate.js +7 -2
  5. package/cjs/color-string/interpolate.js.map +1 -1
  6. package/cjs/color-string/store.js +2 -1
  7. package/cjs/common/path-svg.js +1 -2
  8. package/cjs/common/performance-raf.d.ts +6 -0
  9. package/cjs/common/performance-raf.js +26 -0
  10. package/cjs/common/performance-raf.js.map +1 -0
  11. package/cjs/common/render-area.js +1 -0
  12. package/cjs/common/store.js +1 -1
  13. package/cjs/common/text.js +1 -1
  14. package/cjs/common/utils.js +1 -1
  15. package/cjs/core/application.js +1 -1
  16. package/cjs/core/camera.js +1 -1
  17. package/cjs/core/constants.js +1 -1
  18. package/cjs/core/core-modules.js +1 -1
  19. package/cjs/core/global-module.js +0 -2
  20. package/cjs/core/stage.d.ts +2 -1
  21. package/cjs/core/stage.js +19 -15
  22. package/cjs/core/stage.js.map +1 -1
  23. package/cjs/event/event-system.js +7 -6
  24. package/cjs/event/event-system.js.map +1 -1
  25. package/cjs/graphic/graphic.d.ts +4 -3
  26. package/cjs/graphic/graphic.js +16 -22
  27. package/cjs/graphic/graphic.js.map +1 -1
  28. package/cjs/index.d.ts +1 -3
  29. package/cjs/index.js +16 -17
  30. package/cjs/index.js.map +1 -1
  31. package/cjs/interface/animate.d.ts +5 -0
  32. package/cjs/interface/animate.js.map +1 -1
  33. package/cjs/interface/graphic.d.ts +3 -1
  34. package/cjs/interface/graphic.js.map +1 -1
  35. package/cjs/interface/index.d.ts +1 -1
  36. package/cjs/interface/index.js +9 -9
  37. package/cjs/interface/index.js.map +1 -1
  38. package/cjs/interface/stage.d.ts +1 -0
  39. package/cjs/interface/stage.js.map +1 -1
  40. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -2
  41. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +6 -5
  42. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  43. package/dist/index.es.js +2323 -5068
  44. package/es/canvas/constants.js +1 -2
  45. package/es/color-string/index.js +1 -2
  46. package/es/color-string/interpolate.d.ts +1 -0
  47. package/es/color-string/interpolate.js +4 -0
  48. package/es/color-string/interpolate.js.map +1 -1
  49. package/es/color-string/store.js +2 -1
  50. package/es/common/path-svg.js +1 -2
  51. package/es/common/performance-raf.d.ts +6 -0
  52. package/es/common/performance-raf.js +18 -0
  53. package/es/common/performance-raf.js.map +1 -0
  54. package/es/common/render-area.js +2 -1
  55. package/es/common/store.js +1 -1
  56. package/es/common/text.js +1 -1
  57. package/es/common/utils.js +1 -1
  58. package/es/core/application.js +1 -1
  59. package/es/core/camera.js +1 -1
  60. package/es/core/constants.js +1 -1
  61. package/es/core/core-modules.js +1 -1
  62. package/es/core/global-module.js +0 -2
  63. package/es/core/stage.d.ts +2 -1
  64. package/es/core/stage.js +18 -17
  65. package/es/core/stage.js.map +1 -1
  66. package/es/event/event-system.js +7 -6
  67. package/es/event/event-system.js.map +1 -1
  68. package/es/graphic/graphic.d.ts +4 -3
  69. package/es/graphic/graphic.js +17 -23
  70. package/es/graphic/graphic.js.map +1 -1
  71. package/es/index.d.ts +1 -3
  72. package/es/index.js +2 -6
  73. package/es/index.js.map +1 -1
  74. package/es/interface/animate.d.ts +5 -0
  75. package/es/interface/animate.js.map +1 -1
  76. package/es/interface/graphic.d.ts +3 -1
  77. package/es/interface/graphic.js.map +1 -1
  78. package/es/interface/index.d.ts +1 -1
  79. package/es/interface/index.js +2 -2
  80. package/es/interface/index.js.map +1 -1
  81. package/es/interface/stage.d.ts +1 -0
  82. package/es/interface/stage.js.map +1 -1
  83. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -2
  84. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +4 -5
  85. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  86. package/package.json +1 -1
  87. package/cjs/animate/Ticker/default-ticker.d.ts +0 -40
  88. package/cjs/animate/Ticker/default-ticker.js +0 -140
  89. package/cjs/animate/Ticker/default-ticker.js.map +0 -1
  90. package/cjs/animate/Ticker/index.d.ts +0 -5
  91. package/cjs/animate/Ticker/index.js +0 -23
  92. package/cjs/animate/Ticker/index.js.map +0 -1
  93. package/cjs/animate/Ticker/manual-ticker-handler.d.ts +0 -15
  94. package/cjs/animate/Ticker/manual-ticker-handler.js +0 -36
  95. package/cjs/animate/Ticker/manual-ticker-handler.js.map +0 -1
  96. package/cjs/animate/Ticker/manual-ticker.d.ts +0 -19
  97. package/cjs/animate/Ticker/manual-ticker.js +0 -37
  98. package/cjs/animate/Ticker/manual-ticker.js.map +0 -1
  99. package/cjs/animate/Ticker/raf-tick-handler.d.ts +0 -9
  100. package/cjs/animate/Ticker/raf-tick-handler.js +0 -30
  101. package/cjs/animate/Ticker/raf-tick-handler.js.map +0 -1
  102. package/cjs/animate/Ticker/timeout-tick-handler.d.ts +0 -9
  103. package/cjs/animate/Ticker/timeout-tick-handler.js +0 -28
  104. package/cjs/animate/Ticker/timeout-tick-handler.js.map +0 -1
  105. package/cjs/animate/Ticker/type.d.ts +0 -6
  106. package/cjs/animate/Ticker/type.js +0 -11
  107. package/cjs/animate/Ticker/type.js.map +0 -1
  108. package/cjs/animate/animate.d.ts +0 -147
  109. package/cjs/animate/animate.js +0 -403
  110. package/cjs/animate/animate.js.map +0 -1
  111. package/cjs/animate/custom-animate.d.ts +0 -236
  112. package/cjs/animate/custom-animate.js +0 -722
  113. package/cjs/animate/custom-animate.js.map +0 -1
  114. package/cjs/animate/default-ticker.d.ts +0 -2
  115. package/cjs/animate/default-ticker.js +0 -14
  116. package/cjs/animate/default-ticker.js.map +0 -1
  117. package/cjs/animate/easing-func.d.ts +0 -1
  118. package/cjs/animate/easing-func.js +0 -16
  119. package/cjs/animate/easing-func.js.map +0 -1
  120. package/cjs/animate/easing.d.ts +0 -49
  121. package/cjs/animate/easing.js +0 -141
  122. package/cjs/animate/easing.js.map +0 -1
  123. package/cjs/animate/group-fade.d.ts +0 -16
  124. package/cjs/animate/group-fade.js +0 -66
  125. package/cjs/animate/group-fade.js.map +0 -1
  126. package/cjs/animate/index.d.ts +0 -8
  127. package/cjs/animate/index.js +0 -24
  128. package/cjs/animate/index.js.map +0 -1
  129. package/cjs/animate/morphing.d.ts +0 -52
  130. package/cjs/animate/morphing.js +0 -292
  131. package/cjs/animate/morphing.js.map +0 -1
  132. package/cjs/animate/timeline.d.ts +0 -17
  133. package/cjs/animate/timeline.js +0 -46
  134. package/cjs/animate/timeline.js.map +0 -1
  135. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
  136. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
  137. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +0 -1
  138. package/es/animate/Ticker/default-ticker.d.ts +0 -40
  139. package/es/animate/Ticker/default-ticker.js +0 -138
  140. package/es/animate/Ticker/default-ticker.js.map +0 -1
  141. package/es/animate/Ticker/index.d.ts +0 -5
  142. package/es/animate/Ticker/index.js +0 -10
  143. package/es/animate/Ticker/index.js.map +0 -1
  144. package/es/animate/Ticker/manual-ticker-handler.d.ts +0 -15
  145. package/es/animate/Ticker/manual-ticker-handler.js +0 -28
  146. package/es/animate/Ticker/manual-ticker-handler.js.map +0 -1
  147. package/es/animate/Ticker/manual-ticker.d.ts +0 -19
  148. package/es/animate/Ticker/manual-ticker.js +0 -31
  149. package/es/animate/Ticker/manual-ticker.js.map +0 -1
  150. package/es/animate/Ticker/raf-tick-handler.d.ts +0 -9
  151. package/es/animate/Ticker/raf-tick-handler.js +0 -22
  152. package/es/animate/Ticker/raf-tick-handler.js.map +0 -1
  153. package/es/animate/Ticker/timeout-tick-handler.d.ts +0 -9
  154. package/es/animate/Ticker/timeout-tick-handler.js +0 -20
  155. package/es/animate/Ticker/timeout-tick-handler.js.map +0 -1
  156. package/es/animate/Ticker/type.d.ts +0 -6
  157. package/es/animate/Ticker/type.js +0 -7
  158. package/es/animate/Ticker/type.js.map +0 -1
  159. package/es/animate/animate.d.ts +0 -147
  160. package/es/animate/animate.js +0 -398
  161. package/es/animate/animate.js.map +0 -1
  162. package/es/animate/custom-animate.d.ts +0 -236
  163. package/es/animate/custom-animate.js +0 -699
  164. package/es/animate/custom-animate.js.map +0 -1
  165. package/es/animate/default-ticker.d.ts +0 -2
  166. package/es/animate/default-ticker.js +0 -12
  167. package/es/animate/default-ticker.js.map +0 -1
  168. package/es/animate/easing-func.d.ts +0 -1
  169. package/es/animate/easing-func.js +0 -10
  170. package/es/animate/easing-func.js.map +0 -1
  171. package/es/animate/easing.d.ts +0 -49
  172. package/es/animate/easing.js +0 -134
  173. package/es/animate/easing.js.map +0 -1
  174. package/es/animate/group-fade.d.ts +0 -16
  175. package/es/animate/group-fade.js +0 -56
  176. package/es/animate/group-fade.js.map +0 -1
  177. package/es/animate/index.d.ts +0 -8
  178. package/es/animate/index.js +0 -16
  179. package/es/animate/index.js.map +0 -1
  180. package/es/animate/morphing.d.ts +0 -52
  181. package/es/animate/morphing.js +0 -295
  182. package/es/animate/morphing.js.map +0 -1
  183. package/es/animate/timeline.d.ts +0 -17
  184. package/es/animate/timeline.js +0 -42
  185. package/es/animate/timeline.js.map +0 -1
  186. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
  187. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
  188. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +0 -1
@@ -1,398 +0,0 @@
1
- import { AnimateMode, AnimateStatus, AnimateStepType, AttributeUpdateType } from "../common/enums";
2
-
3
- import { Easing } from "./easing";
4
-
5
- import { Logger, max } from "@visactor/vutils";
6
-
7
- import { defaultTimeline } from "./timeline";
8
-
9
- import { Generator } from "../common/generator";
10
-
11
- export class ACustomAnimate {
12
- constructor(from, to, duration, easing, params) {
13
- this.from = from, this.to = to, this.duration = duration, this.easing = easing,
14
- this.params = params, this.updateCount = 0;
15
- }
16
- bind(target, subAni) {
17
- this.target = target, this.subAnimate = subAni, this.onBind();
18
- }
19
- onBind() {}
20
- onFirstRun() {}
21
- onStart() {}
22
- onEnd() {}
23
- getEndProps() {
24
- return this.to;
25
- }
26
- getFromProps() {
27
- return this.from;
28
- }
29
- getMergedEndProps() {
30
- var _a;
31
- const thisEndProps = this.getEndProps();
32
- return thisEndProps ? this._endProps === thisEndProps ? this._mergedEndProps : (this._endProps = thisEndProps,
33
- void (this._mergedEndProps = Object.assign({}, null !== (_a = this.step.prev.getLastProps()) && void 0 !== _a ? _a : {}, thisEndProps))) : this.step.prev ? this.step.prev.getLastProps() : thisEndProps;
34
- }
35
- update(end, ratio, out) {
36
- if (0 === this.updateCount) {
37
- this.onFirstRun();
38
- const props = this.step.getLastProps();
39
- Object.keys(props).forEach((k => {
40
- this.subAnimate.animate.validAttr(k) && (out[k] = props[k]);
41
- }));
42
- }
43
- this.updateCount += 1, this.onUpdate(end, ratio, out), end && this.onEnd();
44
- }
45
- }
46
-
47
- export class CbAnimate extends ACustomAnimate {
48
- constructor(cb) {
49
- super(null, null, 0, "linear"), this.cb = cb;
50
- }
51
- onUpdate(end, ratio, out) {}
52
- onStart() {
53
- this.cb();
54
- }
55
- }
56
-
57
- export class Animate {
58
- constructor(id = Generator.GenAutoIncrementId(), timeline = defaultTimeline, slience) {
59
- this.id = id, this.timeline = timeline || defaultTimeline, this.status = AnimateStatus.INITIAL,
60
- this.tailAnimate = new SubAnimate(this), this.subAnimates = [ this.tailAnimate ],
61
- this.timeScale = 1, this.rawPosition = -1, this._startTime = 0, this._duringTime = 0,
62
- this.timeline.addAnimate(this), this.slience = slience;
63
- }
64
- setTimeline(timeline) {
65
- timeline !== this.timeline && (this.timeline.removeAnimate(this, !1), timeline.addAnimate(this));
66
- }
67
- getStartTime() {
68
- return this._startTime;
69
- }
70
- getDuration() {
71
- return this.subAnimates.reduce(((t, subAnimate) => t + subAnimate.totalDuration), 0);
72
- }
73
- after(animate) {
74
- const t = animate.getDuration();
75
- return this._startTime = t, this;
76
- }
77
- afterAll(list) {
78
- let maxT = -1 / 0;
79
- return list.forEach((a => {
80
- maxT = max(a.getDuration(), maxT);
81
- })), this._startTime = maxT, this;
82
- }
83
- parallel(animate) {
84
- return this._startTime = animate.getStartTime(), this;
85
- }
86
- static AddInterpolate(name, cb) {
87
- Animate.interpolateMap.set(name, cb);
88
- }
89
- play(customAnimate) {
90
- if (this.tailAnimate.play(customAnimate), this.target) {
91
- const stage = this.target.stage;
92
- stage && stage.renderNextFrame();
93
- }
94
- return 1 === this.subAnimates.length && this.tailAnimate.totalDuration === customAnimate.duration && this.trySetAttribute(customAnimate.getFromProps(), customAnimate.mode),
95
- this;
96
- }
97
- trySetAttribute(attr, mode = Animate.mode) {
98
- attr && mode & AnimateMode.SET_ATTR_IMMEDIATELY && this.target.setAttributes && this.target.setAttributes(attr, !1, {
99
- type: AttributeUpdateType.ANIMATE_PLAY
100
- });
101
- }
102
- runCb(cb) {
103
- const customAnimate = new CbAnimate((() => {
104
- cb(this, customAnimate.step.prev);
105
- }));
106
- return this.tailAnimate.play(customAnimate), this;
107
- }
108
- customInterpolate(key, ratio, from, to, target, ret) {
109
- const func = Animate.interpolateMap.get(key) || Animate.interpolateMap.get("");
110
- return !!func && func(key, ratio, from, to, target, ret);
111
- }
112
- pause() {
113
- this.status === AnimateStatus.RUNNING && (this.status = AnimateStatus.PAUSED);
114
- }
115
- resume() {
116
- this.status === AnimateStatus.PAUSED && (this.status = AnimateStatus.RUNNING);
117
- }
118
- to(props, duration, easing, params) {
119
- if (this.tailAnimate.to(props, duration, easing, params), this.target) {
120
- const stage = this.target.stage;
121
- stage && stage.renderNextFrame();
122
- }
123
- return this;
124
- }
125
- from(props, duration, easing, params) {
126
- if (this.tailAnimate.from(props, duration, easing, params), this.target) {
127
- const stage = this.target.stage;
128
- stage && stage.renderNextFrame();
129
- }
130
- return this;
131
- }
132
- wait(duration) {
133
- if (this.tailAnimate.wait(duration), this.target) {
134
- const stage = this.target.stage;
135
- stage && stage.renderNextFrame();
136
- }
137
- return this;
138
- }
139
- startAt(t) {
140
- if (this.tailAnimate.startAt(t), this.target) {
141
- const stage = this.target.stage;
142
- stage && stage.renderNextFrame();
143
- }
144
- return this;
145
- }
146
- loop(l) {
147
- if (this.tailAnimate.loop = l, this.target) {
148
- const stage = this.target.stage;
149
- stage && stage.renderNextFrame();
150
- }
151
- return this;
152
- }
153
- reversed(r) {
154
- if (this.tailAnimate.reversed = r, this.target) {
155
- const stage = this.target.stage;
156
- stage && stage.renderNextFrame();
157
- }
158
- return this;
159
- }
160
- bounce(b) {
161
- if (this.tailAnimate.bounce = b, this.target) {
162
- const stage = this.target.stage;
163
- stage && stage.renderNextFrame();
164
- }
165
- return this;
166
- }
167
- subAnimate() {
168
- const sa = new SubAnimate(this, this.tailAnimate);
169
- return this.tailAnimate = sa, this.subAnimates.push(sa), sa.bind(this.target), this;
170
- }
171
- getStartProps() {
172
- return this.subAnimates[0].getStartProps();
173
- }
174
- getEndProps() {
175
- return this.tailAnimate.getEndProps();
176
- }
177
- depreventAttr(key) {
178
- this._preventAttrs && this._preventAttrs.delete(key);
179
- }
180
- preventAttr(key) {
181
- this._preventAttrs || (this._preventAttrs = new Set), this._preventAttrs.add(key);
182
- }
183
- preventAttrs(keys) {
184
- keys.forEach((key => this.preventAttr(key)));
185
- }
186
- validAttr(key) {
187
- return !this._preventAttrs || !this._preventAttrs.has(key);
188
- }
189
- bind(target) {
190
- return this.target = target, this.target.onAnimateBind && !this.slience && this.target.onAnimateBind(this),
191
- this.subAnimates.forEach((sa => {
192
- sa.bind(target);
193
- })), this;
194
- }
195
- advance(delta) {
196
- if (this._duringTime < this._startTime) {
197
- if (this._duringTime + delta * this.timeScale < this._startTime) return void (this._duringTime += delta * this.timeScale);
198
- delta = this._duringTime + delta * this.timeScale - this._startTime, this._duringTime = this._startTime;
199
- }
200
- this.status === AnimateStatus.INITIAL && (this.status = AnimateStatus.RUNNING, this._onStart && this._onStart.forEach((cb => cb())));
201
- this.setPosition(Math.max(this.rawPosition, 0) + delta * this.timeScale) && this.status === AnimateStatus.RUNNING && (this.status = AnimateStatus.END,
202
- this._onEnd && this._onEnd.forEach((cb => cb())));
203
- }
204
- setPosition(rawPosition) {
205
- let sa, d = 0;
206
- const prevRawPos = this.rawPosition, maxRawPos = this.subAnimates.reduce(((a, b) => a + b.totalDuration), 0);
207
- rawPosition < 0 && (rawPosition = 0);
208
- const end = rawPosition >= maxRawPos;
209
- if (end && (rawPosition = maxRawPos), rawPosition === prevRawPos) return end;
210
- for (let i = 0; i < this.subAnimates.length && (sa = this.subAnimates[i], !(d + sa.totalDuration >= rawPosition)); i++) d += sa.totalDuration,
211
- sa = void 0;
212
- return this.rawPosition = rawPosition, sa.setPosition(rawPosition - d), end;
213
- }
214
- onStart(cb) {
215
- this._onStart || (this._onStart = []), this._onStart.push(cb);
216
- }
217
- onEnd(cb) {
218
- this._onEnd || (this._onEnd = []), this._onEnd.push(cb);
219
- }
220
- onRemove(cb) {
221
- this._onRemove || (this._onRemove = []), this._onRemove.push(cb);
222
- }
223
- onFrame(cb) {
224
- this._onFrame || (this._onFrame = []), this._onFrame.push(cb);
225
- }
226
- release() {
227
- this.status = AnimateStatus.END;
228
- }
229
- stop(nextVal) {
230
- nextVal || this.target.onStop(), "start" === nextVal ? this.target.onStop(this.getStartProps()) : "end" === nextVal ? this.target.onStop(this.getEndProps()) : this.target.onStop(nextVal),
231
- this.release();
232
- }
233
- }
234
-
235
- Animate.mode = AnimateMode.NORMAL, Animate.interpolateMap = new Map;
236
-
237
- export class SubAnimate {
238
- get totalDuration() {
239
- return this.calcAttr(), this._totalDuration + this._startAt;
240
- }
241
- constructor(animate, lastSubAnimate) {
242
- this.rawPosition = -1, this.position = 0, this.loop = 0, this.duration = 0, this.animate = animate,
243
- this.stepHead = new Step(0, 0, lastSubAnimate ? Object.assign({}, lastSubAnimate.stepTail.props) : {}),
244
- this.stepTail = this.stepHead, this.dirty = !0, this._startAt = 0;
245
- }
246
- calcAttr() {
247
- this.dirty && (this._totalDuration = this.duration * (this.loop + 1));
248
- }
249
- bind(target) {
250
- return this.target = target, this;
251
- }
252
- play(customAnimate) {
253
- let duration = customAnimate.duration;
254
- (null == duration || duration < 0) && (duration = 0);
255
- const easing = customAnimate.easing, easingFunc = "string" == typeof easing ? Easing[easing] : easing, step = this._addStep(duration, null, easingFunc);
256
- return step.type = AnimateStepType.customAnimate, this._appendProps(customAnimate.getEndProps(), step, !1),
257
- this._appendCustomAnimate(customAnimate, step), this;
258
- }
259
- to(props, duration, easing, params) {
260
- (null == duration || duration < 0) && (duration = 0);
261
- const easingFunc = "string" == typeof easing ? Easing[easing] : easing, step = this._addStep(duration, null, easingFunc);
262
- return step.type = AnimateStepType.to, this._appendProps(props, step, !!params && params.tempProps),
263
- step.propKeys || (step.propKeys = Object.keys(step.props)), params && params.noPreventAttrs || this.target.animates && this.target.animates.forEach((a => {
264
- a.id !== this.animate.id && a.preventAttrs(step.propKeys);
265
- })), this;
266
- }
267
- from(props, duration, easing, params) {
268
- this.to(props, 0, easing, params);
269
- const toProps = {};
270
- this.stepTail.propKeys || (this.stepTail.propKeys = Object.keys(this.stepTail.props)),
271
- this.stepTail.propKeys.forEach((k => {
272
- toProps[k] = this.getLastPropByName(k, this.stepTail);
273
- })), this.to(toProps, duration, easing, params), this.stepTail.type = AnimateStepType.from;
274
- }
275
- startAt(t) {
276
- return t < 0 && (t = 0), this._startAt = t, this;
277
- }
278
- getStartProps() {
279
- var _a;
280
- return null === (_a = this.stepHead) || void 0 === _a ? void 0 : _a.props;
281
- }
282
- getEndProps() {
283
- return this.stepTail.props;
284
- }
285
- getLastStep() {
286
- return this._lastStep;
287
- }
288
- wait(duration) {
289
- if (duration > 0) {
290
- const step = this._addStep(+duration, null);
291
- step.type = AnimateStepType.wait, step.prev.customAnimate ? step.props = step.prev.customAnimate.getEndProps() : step.props = step.prev.props,
292
- this.target.onAddStep && this.target.onAddStep(step);
293
- }
294
- return this;
295
- }
296
- _addStep(duration, props, easingFunc) {
297
- const step = new Step(this.duration, duration, props, easingFunc);
298
- return this.duration += duration, this.stepTail.append(step), this.stepTail = step,
299
- step;
300
- }
301
- _appendProps(props, step, tempProps) {
302
- step.props = tempProps ? props : Object.assign({}, props);
303
- let lastStep = step.prev;
304
- const _props = step.props;
305
- for (step.propKeys || (step.propKeys = Object.keys(step.props)), step.propKeys.forEach((k => {
306
- void 0 === step.props[k] && (step.props[k] = this.target.getDefaultAttribute(k));
307
- })); lastStep.prev; ) lastStep.props && (lastStep.propKeys || (lastStep.propKeys = Object.keys(lastStep.props)),
308
- lastStep.propKeys.forEach((key => {
309
- void 0 === _props[key] && (_props[key] = lastStep.props[key]);
310
- }))), step.propKeys = Object.keys(step.props), lastStep = lastStep.prev;
311
- const initProps = this.stepHead.props;
312
- step.propKeys || (step.propKeys = Object.keys(_props)), step.propKeys.forEach((key => {
313
- if (void 0 === initProps[key]) {
314
- const parentAnimateInitProps = this.animate.getStartProps();
315
- initProps[key] = parentAnimateInitProps[key] = this.target.getComputedAttribute(key);
316
- }
317
- })), this.target.onAddStep && this.target.onAddStep(step);
318
- }
319
- _appendCustomAnimate(customAnimate, step) {
320
- step.customAnimate = customAnimate, customAnimate.step = step, customAnimate.bind(this.target, this);
321
- }
322
- setPosition(rawPosition) {
323
- var _a;
324
- const d = this.duration, loopCount = this.loop, prevRawPos = this.rawPosition;
325
- let loop, position, end = !1;
326
- const startAt = null !== (_a = this._startAt) && void 0 !== _a ? _a : 0;
327
- if (rawPosition < 0 && (rawPosition = 0), rawPosition < startAt) return this.rawPosition = rawPosition,
328
- !1;
329
- if (rawPosition -= startAt, d <= 0 && (end = !0, d < 0)) return end;
330
- if (loop = Math.floor(rawPosition / d), position = rawPosition - loop * d, end = rawPosition >= loopCount * d + d,
331
- end && (position = d, loop = loopCount, rawPosition = position * loop + d), rawPosition === prevRawPos) return end;
332
- const rev = !this.reversed != !(this.bounce && loop % 2);
333
- return rev && (position = d - position), this._deltaPosition = position - this.position,
334
- this.position = position, this.rawPosition = rawPosition + startAt, this.updatePosition(end, rev),
335
- end;
336
- }
337
- updatePosition(end, rev) {
338
- if (!this.stepHead) return;
339
- let step = this.stepHead.next;
340
- const position = this.position, duration = this.duration;
341
- if (this.target && step) {
342
- let stepNext = step.next;
343
- for (;stepNext && stepNext.position <= position; ) step = stepNext, stepNext = step.next;
344
- let ratio = end ? 0 === duration ? 1 : position / duration : (position - step.position) / step.duration;
345
- step.easing && (ratio = step.easing(ratio)), this.tryCallCustomAnimateLifeCycle(step, this._lastStep || (rev ? this.stepTail : this.stepHead), rev),
346
- this.updateTarget(step, ratio, end), this._lastStep = step, this.animate._onFrame && this.animate._onFrame.forEach((cb => cb(step, ratio)));
347
- }
348
- }
349
- tryCallCustomAnimateLifeCycle(step, lastStep, rev) {
350
- if (step !== lastStep) if (rev) {
351
- let _step = lastStep.prev;
352
- for (;_step && _step !== step; ) _step.customAnimate && (_step.customAnimate.onStart && _step.customAnimate.onStart(),
353
- _step.customAnimate.onEnd && _step.customAnimate.onEnd()), _step = step.prev;
354
- lastStep && lastStep.customAnimate && lastStep.customAnimate.onEnd && lastStep.customAnimate.onEnd(),
355
- step && step.customAnimate && step.customAnimate.onStart && step.customAnimate.onStart();
356
- } else {
357
- let _step = lastStep.next;
358
- for (;_step && _step !== step; ) _step.customAnimate && (_step.customAnimate.onStart && _step.customAnimate.onStart(),
359
- _step.customAnimate.onEnd && _step.customAnimate.onEnd()), _step = _step.next;
360
- lastStep && lastStep.customAnimate && lastStep.customAnimate.onEnd && lastStep.customAnimate.onEnd(),
361
- step && step.customAnimate && step.customAnimate.onStart && step.customAnimate.onStart();
362
- }
363
- }
364
- getLastPropByName(name, step) {
365
- let lastStep = step.prev;
366
- for (;lastStep; ) {
367
- if (lastStep.props && void 0 !== lastStep.props[name]) return lastStep.props[name];
368
- if (lastStep.customAnimate) {
369
- const val = lastStep.customAnimate.getEndProps()[name];
370
- if (void 0 !== val) return val;
371
- }
372
- lastStep = lastStep.prev;
373
- }
374
- return Logger.getInstance().warn("未知错误,step中找不到属性"), step.props[name];
375
- }
376
- updateTarget(step, ratio, end) {
377
- null == step.props && null == step.customAnimate || this.target.onStep(this, this.animate, step, ratio, end);
378
- }
379
- }
380
-
381
- class Step {
382
- constructor(position, duration, props, easing) {
383
- this.duration = duration, this.position = position, this.props = props, this.easing = easing;
384
- }
385
- append(step) {
386
- step.prev = this, step.next = this.next, this.next = step;
387
- }
388
- getLastProps() {
389
- let step = this.prev;
390
- for (;step; ) {
391
- if (step.props) return step.props;
392
- if (step.customAnimate) return step.customAnimate.getMergedEndProps();
393
- step = step.prev;
394
- }
395
- return null;
396
- }
397
- }
398
- //# sourceMappingURL=animate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/animate/animate.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AA2BhD,MAAM,OAAgB,cAAc;IAgBlC,YAAY,IAAO,EAAE,EAAK,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAAY;QAC5E,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CA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AAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAES,YAAY,CAAC,IAAU,EAAE,KAAa,EAAE,GAAY;QAC5D,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,EAAE;YACpD,OAAO;SACR;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;CACF;AAmUD,MAAM,IAAI;IAiBR,YAAY,QAAgB,EAAE,QAAgB,EAAE,KAAW,EAAE,MAAuB;QAClF,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,IAAU;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,YAAY;QACV,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,OAAO,IAAI,EAAE;YACX,IAAI,IAAI,CAAC,KAAK,EAAE;gBACd,OAAO,IAAI,CAAC,KAAK,CAAC;aACnB;iBAAM,IAAI,IAAI,CAAC,aAAa,EAAE;gBAC7B,OAAO,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,CAAC;aAC/C;YACD,IAAI,GAAG,IAAI,CAAC,IAAW,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF","file":"animate.js","sourcesContent":["import type {\n EasingType,\n EasingTypeFunc,\n IAnimate,\n IAnimateStepType,\n IAnimateTarget,\n ICustomAnimate,\n IGraphic,\n IStep,\n IStepConfig,\n ISubAnimate,\n ITimeline\n} from '../interface';\nimport { AnimateMode, AnimateStatus, AnimateStepType, AttributeUpdateType } from '../common/enums';\nimport { Easing } from './easing';\nimport { Logger, max } from '@visactor/vutils';\nimport { defaultTimeline } from './timeline';\nimport { Generator } from '../common/generator';\n\n// 参考TweenJS\n// https://github.com/CreateJS/TweenJS/tree/master/src/tweenjs\n/**\n * The MIT License (MIT)\n\n Copyright (c) 2014 gskinner.com, inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n */\nexport abstract class ACustomAnimate<T> implements ICustomAnimate {\n declare from: T;\n declare to: T;\n declare duration: number;\n declare easing: EasingType;\n declare params: any;\n declare target: IAnimateTarget;\n declare updateCount: number;\n declare subAnimate: ISubAnimate;\n declare step?: IStep;\n declare mode?: AnimateMode;\n\n // 用于判断是否一致\n declare _endProps?: any;\n declare _mergedEndProps?: any;\n\n constructor(from: T, to: T, duration: number, easing: EasingType, params?: any) {\n this.from = from;\n this.to = to;\n this.duration = duration;\n this.easing = easing;\n this.params = params;\n this.updateCount = 0;\n }\n\n bind(target: IAnimateTarget, subAni: ISubAnimate) {\n this.target = target;\n this.subAnimate = subAni;\n this.onBind();\n }\n\n // 在第一次调用的时候触发\n onBind() {\n return;\n }\n\n // 第一次执行的时候调用\n onFirstRun() {\n return;\n }\n\n // 开始执行的时候调用(如果有循环,那每个周期都会调用)\n onStart() {\n return;\n }\n\n // 结束执行的时候调用(如果有循环,那每个周期都会调用)\n onEnd() {\n return;\n }\n\n getEndProps(): Record<string, any> | void {\n return this.to;\n }\n\n getFromProps(): Record<string, any> | void {\n return this.from;\n }\n\n getMergedEndProps(): Record<string, any> | void {\n const thisEndProps = this.getEndProps();\n if (thisEndProps) {\n if (this._endProps === thisEndProps) {\n return this._mergedEndProps;\n }\n this._endProps = thisEndProps;\n this._mergedEndProps = Object.assign({}, this.step.prev.getLastProps() ?? {}, thisEndProps);\n return;\n }\n return this.step.prev ? this.step.prev.getLastProps() : thisEndProps;\n }\n\n // abstract getFromValue(key: string): any;\n // abstract getToValue(key: string): any;\n\n abstract onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n if (this.updateCount === 0) {\n this.onFirstRun();\n // out添加之前的props\n const props = this.step.getLastProps();\n Object.keys(props).forEach(k => {\n if (this.subAnimate.animate.validAttr(k)) {\n out[k] = props[k];\n }\n });\n }\n this.updateCount += 1;\n this.onUpdate(end, ratio, out);\n if (end) {\n this.onEnd();\n }\n }\n}\n\nexport class CbAnimate extends ACustomAnimate<null> {\n cb: () => void;\n\n constructor(cb: () => void) {\n super(null, null, 0, 'linear');\n this.cb = cb;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n return;\n }\n\n onStart(): void {\n this.cb();\n }\n}\n\ntype InterpolateFunc = (\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IAnimateTarget,\n out: Record<string, any>\n) => boolean;\n\nexport class Animate implements IAnimate {\n static mode: AnimateMode = AnimateMode.NORMAL;\n declare target: IAnimateTarget;\n declare timeline: ITimeline;\n declare nextAnimate?: IAnimate;\n declare prevAnimate?: IAnimate;\n // 当前Animate的状态,正常,暂停,结束\n declare status: AnimateStatus;\n declare readonly id: string | number;\n // 开始时间\n protected declare _startTime: number;\n protected declare _duringTime: number;\n declare subAnimates: SubAnimate[];\n declare tailAnimate: SubAnimate;\n\n // 绝对的位置\n declare rawPosition: number;\n // 时间倍速缩放\n declare timeScale: number;\n\n declare interpolateFunc: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n\n declare _onStart?: (() => void)[];\n declare _onFrame?: ((step: IStep, ratio: number) => void)[];\n declare _onEnd?: (() => void)[];\n declare _onRemove?: (() => void)[];\n declare _preventAttrs?: Set<string>;\n static interpolateMap: Map<string, InterpolateFunc> = new Map();\n slience?: boolean;\n\n constructor(\n id: string | number = Generator.GenAutoIncrementId(),\n timeline: ITimeline = defaultTimeline,\n slience?: boolean\n ) {\n this.id = id;\n this.timeline = timeline || defaultTimeline;\n this.status = AnimateStatus.INITIAL;\n this.tailAnimate = new SubAnimate(this);\n this.subAnimates = [this.tailAnimate];\n this.timeScale = 1;\n this.rawPosition = -1;\n this._startTime = 0;\n this._duringTime = 0;\n this.timeline.addAnimate(this);\n this.slience = slience;\n }\n\n setTimeline(timeline: ITimeline) {\n if (timeline === this.timeline) {\n return;\n }\n this.timeline.removeAnimate(this, false);\n timeline.addAnimate(this);\n }\n\n getStartTime(): number {\n return this._startTime;\n }\n\n getDuration(): number {\n return this.subAnimates.reduce((t, subAnimate) => t + subAnimate.totalDuration, 0);\n }\n\n after(animate: IAnimate) {\n const t = animate.getDuration();\n this._startTime = t;\n return this;\n }\n\n afterAll(list: IAnimate[]) {\n let maxT = -Infinity;\n list.forEach(a => {\n maxT = max(a.getDuration(), maxT);\n });\n this._startTime = maxT;\n return this;\n }\n\n parallel(animate: IAnimate) {\n this._startTime = animate.getStartTime();\n return this;\n }\n\n static AddInterpolate(name: string, cb: InterpolateFunc) {\n Animate.interpolateMap.set(name, cb);\n }\n\n play(customAnimate: ICustomAnimate) {\n this.tailAnimate.play(customAnimate);\n // todo: 考虑使用绑定的ticker执行\n if (this.target) {\n const stage = (this.target as IGraphic).stage;\n stage && stage.renderNextFrame();\n }\n if (this.subAnimates.length === 1 && this.tailAnimate.totalDuration === customAnimate.duration) {\n this.trySetAttribute(customAnimate.getFromProps(), customAnimate.mode);\n }\n return this;\n }\n\n trySetAttribute(attr: Record<string, any> | void, mode: AnimateMode = Animate.mode) {\n if (attr && mode & AnimateMode.SET_ATTR_IMMEDIATELY) {\n (this.target as any).setAttributes &&\n (this.target as any).setAttributes(attr, false, { type: AttributeUpdateType.ANIMATE_PLAY });\n }\n }\n\n runCb(cb: (a: IAnimate, step: IStep) => void) {\n // this.tailAnimate.runCb(cb);\n const customAnimate = new CbAnimate(() => {\n cb(this, customAnimate.step.prev);\n });\n this.tailAnimate.play(customAnimate);\n return this;\n }\n\n /**\n * 自定义插值,返回false表示没有匹配上\n * @param key\n * @param from\n * @param to\n */\n customInterpolate(\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IAnimateTarget,\n ret: Record<string, any>\n ): boolean {\n const func = Animate.interpolateMap.get(key) || Animate.interpolateMap.get('');\n if (!func) {\n return false;\n }\n return func(key, ratio, from, to, target, ret);\n }\n\n pause() {\n if (this.status === AnimateStatus.RUNNING) {\n this.status = AnimateStatus.PAUSED;\n }\n }\n\n resume() {\n if (this.status === AnimateStatus.PAUSED) {\n this.status = AnimateStatus.RUNNING;\n }\n }\n\n to(props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) {\n this.tailAnimate.to(props, duration, easing, params);\n // 默认开始动画\n // todo: 考虑使用绑定的ticker执行\n if (this.target) {\n const stage = (this.target as IGraphic).stage;\n stage && stage.renderNextFrame();\n }\n // if (this.subAnimates.length === 1 && this.tailAnimate.duration === duration) {\n // this.trySetAttribute(props);\n // }\n return this;\n }\n from(props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) {\n this.tailAnimate.from(props, duration, easing, params);\n // todo: 考虑使用绑定的ticker执行\n if (this.target) {\n const stage = (this.target as IGraphic).stage;\n stage && stage.renderNextFrame();\n }\n return this;\n }\n wait(duration: number) {\n this.tailAnimate.wait(duration);\n // todo: 考虑使用绑定的ticker执行\n if (this.target) {\n const stage = (this.target as IGraphic).stage;\n stage && stage.renderNextFrame();\n }\n return this;\n }\n startAt(t: number) {\n this.tailAnimate.startAt(t);\n // todo: 考虑使用绑定的ticker执行\n if (this.target) {\n const stage = (this.target as IGraphic).stage;\n stage && stage.renderNextFrame();\n }\n return this;\n }\n\n loop(l: number) {\n this.tailAnimate.loop = l;\n // todo: 考虑使用绑定的ticker执行\n if (this.target) {\n const stage = (this.target as IGraphic).stage;\n stage && stage.renderNextFrame();\n }\n return this;\n }\n\n reversed(r: boolean) {\n this.tailAnimate.reversed = r;\n // todo: 考虑使用绑定的ticker执行\n if (this.target) {\n const stage = (this.target as IGraphic).stage;\n stage && stage.renderNextFrame();\n }\n return this;\n }\n\n bounce(b: boolean) {\n this.tailAnimate.bounce = b;\n // todo: 考虑使用绑定的ticker执行\n if (this.target) {\n const stage = (this.target as IGraphic).stage;\n stage && stage.renderNextFrame();\n }\n return this;\n }\n\n subAnimate() {\n const sa = new SubAnimate(this, this.tailAnimate);\n this.tailAnimate = sa;\n this.subAnimates.push(sa);\n sa.bind(this.target);\n return this;\n }\n\n getStartProps(): Record<string, any> {\n return this.subAnimates[0].getStartProps();\n }\n\n getEndProps(): Record<string, any> {\n return this.tailAnimate.getEndProps();\n }\n\n depreventAttr(key: string) {\n if (!this._preventAttrs) {\n return;\n }\n this._preventAttrs.delete(key);\n }\n preventAttr(key: string) {\n if (!this._preventAttrs) {\n this._preventAttrs = new Set();\n }\n this._preventAttrs.add(key);\n }\n preventAttrs(keys: string[]) {\n keys.forEach(key => this.preventAttr(key));\n }\n validAttr(key: string): boolean {\n if (!this._preventAttrs) {\n return true;\n }\n return !this._preventAttrs.has(key);\n }\n\n bind(target: IAnimateTarget) {\n this.target = target;\n\n if (this.target.onAnimateBind && !this.slience) {\n this.target.onAnimateBind(this);\n }\n\n this.subAnimates.forEach(sa => {\n sa.bind(target);\n });\n return this;\n }\n\n advance(delta: number) {\n // startTime之前的时间不计入耗时\n if (this._duringTime < this._startTime) {\n if (this._duringTime + delta * this.timeScale < this._startTime) {\n this._duringTime += delta * this.timeScale;\n return;\n }\n delta = this._duringTime + delta * this.timeScale - this._startTime;\n this._duringTime = this._startTime;\n }\n // 执行advance\n if (this.status === AnimateStatus.INITIAL) {\n this.status = AnimateStatus.RUNNING;\n this._onStart && this._onStart.forEach(cb => cb());\n }\n const end = this.setPosition(Math.max(this.rawPosition, 0) + delta * this.timeScale);\n if (end && this.status === AnimateStatus.RUNNING) {\n this.status = AnimateStatus.END;\n this._onEnd && this._onEnd.forEach(cb => cb());\n }\n }\n\n setPosition(rawPosition: number): boolean {\n let d = 0;\n let sa: SubAnimate | undefined;\n const prevRawPos = this.rawPosition;\n const maxRawPos = this.subAnimates.reduce((a, b) => a + b.totalDuration, 0);\n\n if (rawPosition < 0) {\n rawPosition = 0;\n }\n\n const end = rawPosition >= maxRawPos;\n\n if (end) {\n rawPosition = maxRawPos;\n }\n\n if (rawPosition === prevRawPos) {\n return end;\n }\n\n // 查找对应的subAnimate\n for (let i = 0; i < this.subAnimates.length; i++) {\n sa = this.subAnimates[i];\n if (d + sa.totalDuration >= rawPosition) {\n break;\n } else {\n d += sa.totalDuration;\n sa = undefined;\n }\n }\n this.rawPosition = rawPosition;\n sa.setPosition(rawPosition - d);\n\n return end;\n }\n\n onStart(cb: () => void) {\n if (!this._onStart) {\n this._onStart = [];\n }\n this._onStart.push(cb);\n }\n onEnd(cb: () => void) {\n if (!this._onEnd) {\n this._onEnd = [];\n }\n this._onEnd.push(cb);\n }\n onRemove(cb: () => void) {\n if (!this._onRemove) {\n this._onRemove = [];\n }\n this._onRemove.push(cb);\n }\n onFrame(cb: (step: IStep, ratio: number) => void) {\n if (!this._onFrame) {\n this._onFrame = [];\n }\n this._onFrame.push(cb);\n }\n release() {\n this.status = AnimateStatus.END;\n return;\n }\n\n stop(nextVal?: 'start' | 'end' | Record<string, any>) {\n if (!nextVal) {\n this.target.onStop();\n }\n if (nextVal === 'start') {\n this.target.onStop(this.getStartProps());\n } else if (nextVal === 'end') {\n this.target.onStop(this.getEndProps());\n } else {\n this.target.onStop(nextVal);\n }\n this.release();\n }\n}\n\n// Animate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;\n\nexport class SubAnimate implements ISubAnimate {\n declare target: IAnimateTarget;\n declare animate: IAnimate;\n // 默认的初始step,一定存在,且stepHead的props一定保存整个subAnimate阶段所有属性的最初\n protected declare stepHead: Step;\n protected declare stepTail: Step;\n // 结束时反转动画\n declare bounce: boolean;\n // 是否reverse\n declare reversed: boolean;\n // 循环次数,0为执行一次,1为执行两次,Infinity为无限循环\n declare loop: number;\n // 持续时间,不包括循环\n declare duration: number;\n // 位置,在[0, duration]之间\n declare position: number;\n // 绝对的位置,在[0, loops * duration]之间\n declare rawPosition: number;\n declare dirty: boolean;\n\n declare _totalDuration: number;\n declare _startAt: number;\n declare _lastStep: IStep;\n declare _deltaPosition: number;\n\n get totalDuration(): number {\n this.calcAttr();\n return this._totalDuration + this._startAt;\n }\n\n constructor(animate: IAnimate, lastSubAnimate?: SubAnimate) {\n this.rawPosition = -1;\n this.position = 0;\n this.loop = 0;\n this.duration = 0;\n this.animate = animate;\n if (lastSubAnimate) {\n this.stepHead = new Step(0, 0, Object.assign({}, lastSubAnimate.stepTail.props));\n } else {\n this.stepHead = new Step(0, 0, {});\n }\n this.stepTail = this.stepHead;\n this.dirty = true;\n this._startAt = 0;\n }\n\n // 计算按需计算的属性\n protected calcAttr() {\n if (!this.dirty) {\n return;\n }\n\n this._totalDuration = this.duration * (this.loop + 1);\n }\n\n bind(target: IAnimateTarget) {\n this.target = target;\n return this;\n }\n\n play(customAnimate: ICustomAnimate) {\n let duration = customAnimate.duration;\n if (duration == null || duration < 0) {\n duration = 0;\n }\n const easing = customAnimate.easing;\n const easingFunc = typeof easing === 'string' ? Easing[easing] : easing;\n const step = this._addStep(duration, null, easingFunc);\n step.type = AnimateStepType.customAnimate;\n this._appendProps(customAnimate.getEndProps(), step, false);\n this._appendCustomAnimate(customAnimate, step);\n return this;\n }\n\n // _appendPlayProps(step: IStep) {\n\n // return;\n // }\n\n to(props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) {\n if (duration == null || duration < 0) {\n duration = 0;\n }\n\n const easingFunc = typeof easing === 'string' ? Easing[easing] : easing;\n\n const step = this._addStep(duration, null, easingFunc);\n step.type = AnimateStepType.to;\n this._appendProps(props, step, params ? params.tempProps : false);\n // this._appendPlayProps(step);\n\n if (!step.propKeys) {\n step.propKeys = Object.keys(step.props);\n }\n if (!(params && params.noPreventAttrs)) {\n this.target.animates &&\n this.target.animates.forEach(a => {\n if (a.id !== this.animate.id) {\n a.preventAttrs(step.propKeys);\n }\n });\n }\n return this;\n }\n\n from(props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) {\n this.to(props, 0, easing, params);\n const toProps = {};\n if (!this.stepTail.propKeys) {\n this.stepTail.propKeys = Object.keys(this.stepTail.props);\n }\n this.stepTail.propKeys.forEach(k => {\n toProps[k] = this.getLastPropByName(k, this.stepTail);\n });\n this.to(toProps, duration, easing, params);\n this.stepTail.type = AnimateStepType.from;\n }\n\n startAt(t: number) {\n if (t < 0) {\n t = 0;\n }\n this._startAt = t;\n return this;\n }\n\n getStartProps() {\n return this.stepHead?.props;\n }\n\n getEndProps() {\n return this.stepTail.props;\n }\n\n getLastStep() {\n return this._lastStep;\n }\n\n wait(duration: number) {\n if (duration > 0) {\n const step = this._addStep(+duration, null);\n\n step.type = AnimateStepType.wait;\n // TODO 这里如果跳帧的话会存在bug\n if (step.prev.customAnimate) {\n step.props = step.prev.customAnimate.getEndProps();\n } else {\n step.props = step.prev.props;\n }\n if (this.target.onAddStep) {\n this.target.onAddStep(step);\n }\n // this._appendPlayProps(step);\n }\n return this;\n }\n\n protected _addStep(duration: number, props: any, easingFunc?: EasingTypeFunc) {\n const step = new Step(this.duration, duration, props, easingFunc);\n this.duration += duration;\n this.stepTail.append(step);\n this.stepTail = step;\n return step;\n }\n\n protected _appendProps(props: any, step: Step, tempProps?: boolean) {\n if (tempProps) {\n step.props = props;\n } else {\n // todo: 是否需要深拷贝props\n step.props = Object.assign({}, props);\n }\n let lastStep = step.prev;\n const _props = step.props;\n // 将undefined的属性设置到默认值\n if (!step.propKeys) {\n step.propKeys = Object.keys(step.props);\n }\n step.propKeys.forEach(k => {\n if (step.props[k] === undefined) {\n step.props[k] = this.target.getDefaultAttribute(k);\n }\n });\n // 拷贝之前的step阶段属性\n while (lastStep.prev) {\n if (lastStep.props) {\n if (!lastStep.propKeys) {\n lastStep.propKeys = Object.keys(lastStep.props);\n }\n lastStep.propKeys.forEach(key => {\n if (_props[key] === undefined) {\n _props[key] = lastStep.props[key];\n }\n });\n }\n // 重置propKeys\n step.propKeys = Object.keys(step.props);\n lastStep = lastStep.prev;\n }\n\n // 设置最初的props属性\n const initProps = this.stepHead.props;\n if (!step.propKeys) {\n step.propKeys = Object.keys(_props);\n }\n step.propKeys.forEach(key => {\n if (initProps[key] === undefined) {\n const parentAnimateInitProps = this.animate.getStartProps();\n initProps[key] = parentAnimateInitProps[key] = this.target.getComputedAttribute(key);\n }\n });\n\n if (this.target.onAddStep) {\n this.target.onAddStep(step);\n }\n }\n\n protected _appendCustomAnimate(customAnimate: ICustomAnimate, step: Step) {\n step.customAnimate = customAnimate;\n customAnimate.step = step;\n customAnimate.bind(this.target, this);\n }\n\n setPosition(rawPosition: number) {\n const d = this.duration;\n const loopCount = this.loop;\n const prevRawPos = this.rawPosition;\n let end = false;\n let loop: number; // 当前是第几次循环\n let position: number; // 当前周期的时间\n const startAt = this._startAt ?? 0;\n\n if (rawPosition < 0) {\n rawPosition = 0;\n }\n if (rawPosition < startAt) {\n this.rawPosition = rawPosition;\n return false;\n }\n rawPosition = rawPosition - startAt;\n if (d <= 0) {\n // 如果不用执行,跳过\n end = true;\n // 小于0的话,直接return,如果等于0,那还是得走动画逻辑,将end属性设置上去\n if (d < 0) {\n return end;\n }\n }\n loop = Math.floor(rawPosition / d);\n position = rawPosition - loop * d;\n\n // 计算rawPosition\n end = rawPosition >= loopCount * d + d;\n // 如果结束,跳过\n if (end) {\n position = d;\n loop = loopCount;\n rawPosition = position * loop + d;\n }\n\n if (rawPosition === prevRawPos) {\n return end;\n }\n\n // reverse动画\n const rev = !this.reversed !== !(this.bounce && loop % 2);\n if (rev) {\n position = d - position;\n }\n\n this._deltaPosition = position - this.position;\n this.position = position;\n this.rawPosition = rawPosition + startAt;\n\n this.updatePosition(end, rev);\n\n return end;\n }\n\n protected updatePosition(end: boolean, rev: boolean) {\n if (!this.stepHead) {\n return;\n }\n let step = this.stepHead.next;\n const position = this.position;\n const duration = this.duration;\n if (this.target && step) {\n let stepNext = step.next;\n while (stepNext && stepNext.position <= position) {\n step = stepNext;\n stepNext = step.next;\n }\n let ratio = end ? (duration === 0 ? 1 : position / duration) : (position - step.position) / step.duration; // TODO: revisit this.\n if (step.easing) {\n ratio = step.easing(ratio);\n }\n // 判断这次和上次过程中是否经历了自定义step,如果跳过了自定义step那么执行自定义step的onEnd\n this.tryCallCustomAnimateLifeCycle(step, this._lastStep || (rev ? this.stepTail : this.stepHead), rev);\n // if (step !== this._lastStep) {\n // if (this._deltaPosition > 0) {\n // let _step = step.prev;\n // while (_step && _step !== this._lastStep) {\n // if (_step.customAnimate) {\n // _step.customAnimate.onEnd();\n // }\n // _step = _step.prev;\n // }\n // if (_step && _step.customAnimate) {\n // _step.customAnimate.onEnd();\n // }\n // } else if (this._deltaPosition < 0) {\n // let _step = step.next;\n // while (_step && _step !== this._lastStep) {\n // if (_step.customAnimate) {\n // _step.customAnimate.onEnd();\n // }\n // _step = _step.next;\n // }\n // if (_step && _step.customAnimate) {\n // _step.customAnimate.onEnd();\n // }\n // }\n // }\n this.updateTarget(step, ratio, end);\n this._lastStep = step;\n\n this.animate._onFrame && this.animate._onFrame.forEach(cb => cb(step, ratio));\n }\n }\n\n // 如果动画卡顿跳过了自定义动画,那么尝试执行自定义动画的生命周期\n tryCallCustomAnimateLifeCycle(step: IStep, lastStep: IStep, rev: boolean) {\n if (step === lastStep) {\n return;\n }\n if (rev) {\n let _step = lastStep.prev;\n while (_step && _step !== step) {\n if (_step.customAnimate) {\n _step.customAnimate.onStart && _step.customAnimate.onStart();\n _step.customAnimate.onEnd && _step.customAnimate.onEnd();\n }\n _step = step.prev;\n }\n // 执行lastStep的onEnd和currentStep的onStart\n if (lastStep && lastStep.customAnimate) {\n lastStep.customAnimate.onEnd && lastStep.customAnimate.onEnd();\n }\n if (step && step.customAnimate) {\n step.customAnimate.onStart && step.customAnimate.onStart();\n }\n } else {\n let _step = lastStep.next;\n while (_step && _step !== step) {\n if (_step.customAnimate) {\n _step.customAnimate.onStart && _step.customAnimate.onStart();\n _step.customAnimate.onEnd && _step.customAnimate.onEnd();\n }\n _step = _step.next;\n }\n // 执行lastStep的onEnd和currentStep的onStart\n if (lastStep && lastStep.customAnimate) {\n lastStep.customAnimate.onEnd && lastStep.customAnimate.onEnd();\n }\n if (step && step.customAnimate) {\n step.customAnimate.onStart && step.customAnimate.onStart();\n }\n }\n }\n\n /**\n * 获取这个属性的上一个值\n * @param name\n * @param step\n * @returns\n */\n getLastPropByName(name: string, step: Step): any {\n let lastStep = step.prev;\n while (lastStep) {\n if (lastStep.props && lastStep.props[name] !== undefined) {\n return lastStep.props[name];\n } else if (lastStep.customAnimate) {\n const val = lastStep.customAnimate.getEndProps()[name];\n if (val !== undefined) {\n return val;\n }\n }\n lastStep = lastStep.prev;\n }\n\n Logger.getInstance().warn('未知错误,step中找不到属性');\n return step.props[name];\n }\n\n protected updateTarget(step: Step, ratio: number, end: boolean) {\n if (step.props == null && step.customAnimate == null) {\n return;\n }\n this.target.onStep(this, this.animate, step, ratio, end);\n }\n}\n\n// export class Animate implements IAnimate {\n// declare target: IAnimateTarget;\n// declare timeline: ITimeline;\n// protected declare stepHead: Step;\n// protected declare stepTail: Step;\n// declare nextAnimate?: Animate;\n// declare prevAnimate?: Animate;\n// // 结束时反转动画\n// declare bounce: boolean;\n// // 是否reverse\n// declare reversed: boolean;\n// // 循环次数,0为执行一次,1为执行两次,Infinity为无限循环\n// declare loop: number;\n// // 持续时间,不包括循环\n// declare duration: number;\n// // 当前Animate的状态,正常,暂停,结束\n// declare status: AnimateStatus;\n// // 位置,在[0, duration]之间\n// declare position: number;\n// // 绝对的位置,在[0, loops * duration]之间\n// declare rawPosition: number;\n// // 开始时间\n// protected declare _startAt: number;\n// // 时间的缩放,例如2表示2倍速\n// declare timeScale: number;\n// declare props: Record<string, any>;\n// declare readonly id: string | number;\n\n// protected declare _onStart?: (() => void)[];\n// protected declare _onFrame?: ((step: IStep, ratio: number) => void)[];\n// protected declare _onEnd?: (() => void)[];\n// declare _onRemove?: (() => void)[];\n// declare _preventAttrs?: Set<string>;\n\n// constructor(id: string | number = Generator.GenAutoIncrementId(), timeline: ITimeline = defaultTimeline) {\n// this.timeline = timeline;\n// this.status = AnimateStatus.INITIAL;\n// this.rawPosition = -1;\n// this.position = 0;\n// this.loop = 0;\n// this.timeline.addAnimate(this);\n// this.timeScale = 1;\n// this.id = id;\n// this.props = {};\n// this.stepHead = new Step(0, 0, {});\n// this.stepTail = this.stepHead;\n// }\n\n// preventAttr(key: string) {\n// if (!this._preventAttrs) {\n// this._preventAttrs = new Set();\n// }\n// this._preventAttrs.add(key);\n// }\n// preventAttrs(keys: string[]) {\n// keys.forEach(key => this.preventAttr(key));\n// }\n// validAttr(key: string): boolean {\n// if (!this._preventAttrs) {\n// return true;\n// }\n// return !this._preventAttrs.has(key);\n// }\n\n// getLastPropByName(name: string, step: Step): any {\n// let lastStep = step.prev;\n// while (lastStep) {\n// if (lastStep.props && lastStep.props[name] !== undefined) {\n// return lastStep.props[name];\n// }\n// lastStep = lastStep.prev;\n// }\n// let val = this.props[name];\n// if (!val) {\n// console.warn('未知错误,step中找不到属性');\n// val = this.target.getComputedAttribute(name);\n// this.props[name] = val;\n// }\n\n// return val;\n// }\n\n// bind(target: IAnimateTarget) {\n// this.target = target;\n// this.duration = 0;\n// return this;\n// }\n\n// startAt(t: number) {\n// if (t < 0) {\n// return this;\n// }\n// this._startAt = t;\n// return this;\n// }\n\n// to(props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) {\n// if (duration == null || duration < 0) {\n// duration = 0;\n// }\n\n// const easingFunc = typeof easing === 'string' ? Easing[easing] : easing;\n\n// const step = this._addStep(duration, null, easingFunc);\n// this._appendProps(props, step, params ? params.tempProps : false);\n// return this;\n// }\n\n// wait(duration: number) {\n// if (duration > 0) {\n// const step = this._addStep(+duration, null);\n// if (step.prev) {\n// step.props = step.prev.props;\n// }\n// if (this.target.onAddStep) {\n// this.target.onAddStep(step);\n// }\n// }\n// return this;\n// }\n\n// protected _addStep(duration: number, props: any, easingFunc?: EasingTypeFunc) {\n// const step = new Step(this.duration, duration, props, easingFunc);\n// this.duration += duration;\n// this.stepTail.append(step);\n// this.stepTail = step;\n// return step;\n// }\n\n// protected _appendProps(props: any, step: Step, tempProps?: boolean) {\n// if (tempProps) {\n// step.props = props;\n// } else {\n// // todo: 是否需要深拷贝props\n// step.props = Object.assign({}, props);\n// }\n// let lastStep = step.prev;\n// const _props = step.props;\n// // 拷贝之前的step阶段属性\n// while (lastStep.prev) {\n// if (lastStep.props) {\n// if (!lastStep.propKeys) {\n// lastStep.propKeys = Object.keys(lastStep.props);\n// }\n// lastStep.propKeys.forEach(key => {\n// if (_props[key] === undefined) {\n// _props[key] = lastStep.props[key];\n// }\n// });\n// }\n// lastStep = lastStep.prev;\n// }\n\n// // 设置最初的props属性\n// const initProps = this.stepHead.props;\n// if (!step.propKeys) {\n// step.propKeys = Object.keys(_props);\n// step.propKeys.forEach(key => {\n// initProps[key] = this.target.getComputedAttribute(key);\n// });\n// }\n\n// if (this.target.onAddStep) {\n// this.target.onAddStep(step);\n// }\n// }\n\n// advance(delta: number) {\n// if (this.status === AnimateStatus.INITIAL) {\n// this.status = AnimateStatus.RUNNING;\n// this._onStart && this._onStart.forEach(cb => cb());\n// }\n// const end = this.setPosition(this.rawPosition + delta * this.timeScale);\n// if (end && this.status === AnimateStatus.RUNNING) {\n// this.status = AnimateStatus.END;\n// this._onEnd && this._onEnd.forEach(cb => cb());\n// }\n// }\n\n// setPosition(rawPosition: number) {\n// const d = this.duration;\n// const loopCount = this.loop;\n// const prevRawPos = this.rawPosition;\n// let end = false;\n// let loop: number; // 当前是第几次循环\n// let position: number; // 当前周期的时间\n// const startAt = this._startAt ?? 0;\n\n// if (rawPosition < 0) {\n// rawPosition = 0;\n// }\n// if (rawPosition < startAt) {\n// this.rawPosition = rawPosition;\n// return false;\n// }\n// rawPosition = rawPosition - startAt;\n// if (d <= 0) {\n// // 如果不用执行,跳过\n// end = true;\n// return end;\n// }\n// loop = Math.floor(rawPosition / d);\n// position = rawPosition - loop * d;\n\n// // 计算rawPosition\n// end = rawPosition >= loopCount * d + d;\n// // 如果结束,跳过\n// if (end) {\n// position = d;\n// loop = loopCount;\n// rawPosition = position * loop + d;\n// }\n\n// if (rawPosition === prevRawPos) {\n// return end;\n// }\n\n// // reverse动画\n// const rev = !this.reversed !== !(this.bounce && loop % 2);\n// if (rev) {\n// position = d - position;\n// }\n\n// this.position = position;\n// this.rawPosition = rawPosition + startAt;\n\n// this.updatePosition(end);\n\n// return end;\n// }\n\n// protected updatePosition(end: boolean) {\n// if (!this.stepHead) {\n// return;\n// }\n// let step = this.stepHead;\n// const position = this.position;\n// const duration = this.duration;\n// if (this.target && step) {\n// let stepNext = step.next;\n// while (stepNext && stepNext.position <= position) {\n// step = step.next;\n// stepNext = step.next;\n// }\n// let ratio = end ? (duration === 0 ? 1 : position / duration) : (position - step.position) / step.duration; // TODO: revisit this.\n// if (step.easing) {\n// ratio = step.easing(ratio);\n// }\n// this.updateTarget(step, ratio, end);\n// this._onFrame && this._onFrame.forEach(cb => cb(step, ratio));\n// }\n// }\n\n// protected updateTarget(step: Step, ratio: number, end: boolean) {\n// if (step.props == null) {\n// return;\n// }\n// this.target.onStep(this, step, ratio, end);\n// }\n\n// onStart(cb: () => void) {\n// if (!this._onStart) {\n// this._onStart = [];\n// }\n// this._onStart.push(cb);\n// }\n// onEnd(cb: () => void) {\n// if (!this._onEnd) {\n// this._onEnd = [];\n// }\n// this._onEnd.push(cb);\n// }\n// onRemove(cb: () => void) {\n// if (!this._onRemove) {\n// this._onRemove = [];\n// }\n// this._onRemove.push(cb);\n// }\n// onFrame(cb: (step: IStep, ratio: number) => void) {\n// if (!this._onFrame) {\n// this._onFrame = [];\n// }\n// this._onFrame.push(cb);\n// }\n\n// getStartProps() {\n// return this.stepHead?.props;\n// }\n\n// getEndProps(target: Record<string, any> = {}) {\n// let step = this.stepHead;\n// while (step) {\n// if (step.props) {\n// Object.assign(target, step.props);\n// }\n// step = step.next;\n// }\n\n// return target;\n// }\n\n// stop(nextVal?: 'start' | 'end' | Record<string, any>) {\n// this.status = AnimateStatus.END;\n// if (!nextVal) {\n// this.target.onStop();\n// }\n// if (nextVal === 'start') {\n// this.target.onStop(this.getStartProps());\n// } else if (nextVal === 'end') {\n// this.target.onStop(this.getEndProps());\n// } else {\n// this.target.onStop(nextVal);\n// }\n// }\n\n// release() {\n// this.status = AnimateStatus.END;\n// return;\n// }\n// }\n\nclass Step implements IStep {\n declare prev?: Step;\n // 持续时间\n declare duration: number;\n // 在animate中的位置\n declare position: number;\n declare next?: Step;\n declare props: any;\n // 保存解析后的props,用于性能优化\n declare parsedProps?: any;\n declare propKeys?: string[];\n declare easing?: EasingTypeFunc;\n declare customAnimate?: ICustomAnimate;\n // passive: boolean;\n // index: number;\n type: IAnimateStepType;\n\n constructor(position: number, duration: number, props?: any, easing?: EasingTypeFunc) {\n this.duration = duration;\n this.position = position;\n this.props = props;\n this.easing = easing;\n }\n\n append(step: Step) {\n step.prev = this;\n step.next = this.next;\n this.next = step;\n }\n\n getLastProps() {\n let step = this.prev;\n while (step) {\n if (step.props) {\n return step.props;\n } else if (step.customAnimate) {\n return step.customAnimate.getMergedEndProps();\n }\n step = step.prev as any;\n }\n return null;\n }\n}\n"]}