@visactor/vrender-animate 0.22.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.
Files changed (303) hide show
  1. package/README.md +177 -0
  2. package/cjs/animate-extension.d.ts +15 -0
  3. package/cjs/animate-extension.js +46 -0
  4. package/cjs/animate-extension.js.map +1 -0
  5. package/cjs/animate.d.ts +71 -0
  6. package/cjs/animate.js +210 -0
  7. package/cjs/animate.js.map +1 -0
  8. package/cjs/custom/clip-graphic.d.ts +53 -0
  9. package/cjs/custom/clip-graphic.js +146 -0
  10. package/cjs/custom/clip-graphic.js.map +1 -0
  11. package/cjs/custom/clip.d.ts +13 -0
  12. package/cjs/custom/clip.js +24 -0
  13. package/cjs/custom/clip.js.map +1 -0
  14. package/cjs/custom/common.d.ts +22 -0
  15. package/cjs/custom/common.js +58 -0
  16. package/cjs/custom/common.js.map +1 -0
  17. package/cjs/custom/custom-animate.d.ts +15 -0
  18. package/cjs/custom/custom-animate.js +25 -0
  19. package/cjs/custom/custom-animate.js.map +1 -0
  20. package/cjs/custom/fade.d.ts +13 -0
  21. package/cjs/custom/fade.js +24 -0
  22. package/cjs/custom/fade.js.map +1 -0
  23. package/cjs/custom/group-fade.d.ts +16 -0
  24. package/cjs/custom/group-fade.js +66 -0
  25. package/cjs/custom/group-fade.js.map +1 -0
  26. package/cjs/custom/growAngle.d.ts +37 -0
  27. package/cjs/custom/growAngle.js +140 -0
  28. package/cjs/custom/growAngle.js.map +1 -0
  29. package/cjs/custom/growCenter.d.ts +17 -0
  30. package/cjs/custom/growCenter.js +161 -0
  31. package/cjs/custom/growCenter.js.map +1 -0
  32. package/cjs/custom/growHeight.d.ts +36 -0
  33. package/cjs/custom/growHeight.js +154 -0
  34. package/cjs/custom/growHeight.js.map +1 -0
  35. package/cjs/custom/growPoints.d.ts +52 -0
  36. package/cjs/custom/growPoints.js +227 -0
  37. package/cjs/custom/growPoints.js.map +1 -0
  38. package/cjs/custom/growRadius.d.ts +41 -0
  39. package/cjs/custom/growRadius.js +113 -0
  40. package/cjs/custom/growRadius.js.map +1 -0
  41. package/cjs/custom/growWidth.d.ts +36 -0
  42. package/cjs/custom/growWidth.js +154 -0
  43. package/cjs/custom/growWidth.js.map +1 -0
  44. package/cjs/custom/input-text.d.ts +29 -0
  45. package/cjs/custom/input-text.js +45 -0
  46. package/cjs/custom/input-text.js.map +1 -0
  47. package/cjs/custom/number.d.ts +25 -0
  48. package/cjs/custom/number.js +102 -0
  49. package/cjs/custom/number.js.map +1 -0
  50. package/cjs/custom/register.d.ts +1 -0
  51. package/cjs/custom/register.js +35 -0
  52. package/cjs/custom/register.js.map +1 -0
  53. package/cjs/custom/scale-in.d.ts +13 -0
  54. package/cjs/custom/scale-in.js +57 -0
  55. package/cjs/custom/scale-in.js.map +1 -0
  56. package/cjs/custom/scale.d.ts +20 -0
  57. package/cjs/custom/scale.js +106 -0
  58. package/cjs/custom/scale.js.map +1 -0
  59. package/cjs/custom/sphere.d.ts +20 -0
  60. package/cjs/custom/sphere.js +26 -0
  61. package/cjs/custom/sphere.js.map +1 -0
  62. package/cjs/custom/state.d.ts +13 -0
  63. package/cjs/custom/state.js +25 -0
  64. package/cjs/custom/state.js.map +1 -0
  65. package/cjs/custom/tag-points.d.ts +26 -0
  66. package/cjs/custom/tag-points.js +81 -0
  67. package/cjs/custom/tag-points.js.map +1 -0
  68. package/cjs/custom/update.d.ts +14 -0
  69. package/cjs/custom/update.js +26 -0
  70. package/cjs/custom/update.js.map +1 -0
  71. package/cjs/executor/animate-executor.d.ts +36 -0
  72. package/cjs/executor/animate-executor.js +177 -0
  73. package/cjs/executor/animate-executor.js.map +1 -0
  74. package/cjs/executor/executor.d.ts +69 -0
  75. package/cjs/executor/executor.js +6 -0
  76. package/cjs/executor/executor.js.map +1 -0
  77. package/cjs/index.d.ts +25 -0
  78. package/cjs/index.js +214 -0
  79. package/cjs/index.js.map +1 -0
  80. package/cjs/interpolate/executor.d.ts +66 -0
  81. package/cjs/interpolate/executor.js +6 -0
  82. package/cjs/interpolate/executor.js.map +1 -0
  83. package/cjs/interpolate/number.d.ts +1 -0
  84. package/cjs/interpolate/number.js +10 -0
  85. package/cjs/interpolate/number.js.map +1 -0
  86. package/cjs/interpolate/store.d.ts +32 -0
  87. package/cjs/interpolate/store.js +96 -0
  88. package/cjs/interpolate/store.js.map +1 -0
  89. package/cjs/intreface/animate.d.ts +91 -0
  90. package/cjs/intreface/animate.js +10 -0
  91. package/cjs/intreface/animate.js.map +1 -0
  92. package/cjs/intreface/easing.d.ts +3 -0
  93. package/cjs/intreface/easing.js +6 -0
  94. package/cjs/intreface/easing.js.map +1 -0
  95. package/cjs/intreface/state.d.ts +35 -0
  96. package/cjs/intreface/state.js +6 -0
  97. package/cjs/intreface/state.js.map +1 -0
  98. package/cjs/intreface/ticker.d.ts +37 -0
  99. package/cjs/intreface/ticker.js +10 -0
  100. package/cjs/intreface/ticker.js.map +1 -0
  101. package/cjs/intreface/timeline.d.ts +17 -0
  102. package/cjs/intreface/timeline.js +6 -0
  103. package/cjs/intreface/timeline.js.map +1 -0
  104. package/cjs/intreface/type.d.ts +13 -0
  105. package/cjs/intreface/type.js +15 -0
  106. package/cjs/intreface/type.js.map +1 -0
  107. package/cjs/register.d.ts +1 -0
  108. package/cjs/register.js +19 -0
  109. package/cjs/register.js.map +1 -0
  110. package/cjs/state/animation-state-machine.d.ts +22 -0
  111. package/cjs/state/animation-state-machine.js +53 -0
  112. package/cjs/state/animation-state-machine.js.map +1 -0
  113. package/cjs/state/animation-state-queue.d.ts +24 -0
  114. package/cjs/state/animation-state-queue.js +66 -0
  115. package/cjs/state/animation-state-queue.js.map +1 -0
  116. package/cjs/state/animation-state-registry.d.ts +14 -0
  117. package/cjs/state/animation-state-registry.js +53 -0
  118. package/cjs/state/animation-state-registry.js.map +1 -0
  119. package/cjs/state/animation-state.d.ts +25 -0
  120. package/cjs/state/animation-state.js +80 -0
  121. package/cjs/state/animation-state.js.map +1 -0
  122. package/cjs/state/animation-states-registry.d.ts +17 -0
  123. package/cjs/state/animation-states-registry.js +95 -0
  124. package/cjs/state/animation-states-registry.js.map +1 -0
  125. package/cjs/state/graphic-extension.d.ts +12 -0
  126. package/cjs/state/graphic-extension.js +37 -0
  127. package/cjs/state/graphic-extension.js.map +1 -0
  128. package/cjs/state/index.d.ts +3 -0
  129. package/cjs/state/index.js +22 -0
  130. package/cjs/state/index.js.map +1 -0
  131. package/cjs/state/types.d.ts +11 -0
  132. package/cjs/state/types.js +6 -0
  133. package/cjs/state/types.js.map +1 -0
  134. package/cjs/step.d.ts +49 -0
  135. package/cjs/step.js +124 -0
  136. package/cjs/step.js.map +1 -0
  137. package/cjs/ticker/default-ticker.d.ts +39 -0
  138. package/cjs/ticker/default-ticker.js +133 -0
  139. package/cjs/ticker/default-ticker.js.map +1 -0
  140. package/cjs/ticker/manual-ticker.d.ts +6 -0
  141. package/cjs/ticker/manual-ticker.js +37 -0
  142. package/cjs/ticker/manual-ticker.js.map +1 -0
  143. package/cjs/timeline.d.ts +34 -0
  144. package/cjs/timeline.js +84 -0
  145. package/cjs/timeline.js.map +1 -0
  146. package/cjs/utils/easing-func.d.ts +1 -0
  147. package/cjs/utils/easing-func.js +16 -0
  148. package/cjs/utils/easing-func.js.map +1 -0
  149. package/cjs/utils/easing.d.ts +49 -0
  150. package/cjs/utils/easing.js +141 -0
  151. package/cjs/utils/easing.js.map +1 -0
  152. package/dist/index.es.js +3824 -0
  153. package/es/animate-extension.d.ts +15 -0
  154. package/es/animate-extension.js +42 -0
  155. package/es/animate-extension.js.map +1 -0
  156. package/es/animate.d.ts +71 -0
  157. package/es/animate.js +207 -0
  158. package/es/animate.js.map +1 -0
  159. package/es/custom/clip-graphic.d.ts +53 -0
  160. package/es/custom/clip-graphic.js +134 -0
  161. package/es/custom/clip-graphic.js.map +1 -0
  162. package/es/custom/clip.d.ts +13 -0
  163. package/es/custom/clip.js +14 -0
  164. package/es/custom/clip.js.map +1 -0
  165. package/es/custom/common.d.ts +22 -0
  166. package/es/custom/common.js +48 -0
  167. package/es/custom/common.js.map +1 -0
  168. package/es/custom/custom-animate.d.ts +15 -0
  169. package/es/custom/custom-animate.js +17 -0
  170. package/es/custom/custom-animate.js.map +1 -0
  171. package/es/custom/fade.d.ts +13 -0
  172. package/es/custom/fade.js +14 -0
  173. package/es/custom/fade.js.map +1 -0
  174. package/es/custom/group-fade.d.ts +16 -0
  175. package/es/custom/group-fade.js +56 -0
  176. package/es/custom/group-fade.js.map +1 -0
  177. package/es/custom/growAngle.d.ts +37 -0
  178. package/es/custom/growAngle.js +132 -0
  179. package/es/custom/growAngle.js.map +1 -0
  180. package/es/custom/growCenter.d.ts +17 -0
  181. package/es/custom/growCenter.js +155 -0
  182. package/es/custom/growCenter.js.map +1 -0
  183. package/es/custom/growHeight.d.ts +36 -0
  184. package/es/custom/growHeight.js +144 -0
  185. package/es/custom/growHeight.js.map +1 -0
  186. package/es/custom/growPoints.d.ts +52 -0
  187. package/es/custom/growPoints.js +219 -0
  188. package/es/custom/growPoints.js.map +1 -0
  189. package/es/custom/growRadius.d.ts +41 -0
  190. package/es/custom/growRadius.js +105 -0
  191. package/es/custom/growRadius.js.map +1 -0
  192. package/es/custom/growWidth.d.ts +36 -0
  193. package/es/custom/growWidth.js +144 -0
  194. package/es/custom/growWidth.js.map +1 -0
  195. package/es/custom/input-text.d.ts +29 -0
  196. package/es/custom/input-text.js +37 -0
  197. package/es/custom/input-text.js.map +1 -0
  198. package/es/custom/number.d.ts +25 -0
  199. package/es/custom/number.js +94 -0
  200. package/es/custom/number.js.map +1 -0
  201. package/es/custom/register.d.ts +1 -0
  202. package/es/custom/register.js +39 -0
  203. package/es/custom/register.js.map +1 -0
  204. package/es/custom/scale-in.d.ts +13 -0
  205. package/es/custom/scale-in.js +49 -0
  206. package/es/custom/scale-in.js.map +1 -0
  207. package/es/custom/scale.d.ts +20 -0
  208. package/es/custom/scale.js +96 -0
  209. package/es/custom/scale.js.map +1 -0
  210. package/es/custom/sphere.d.ts +20 -0
  211. package/es/custom/sphere.js +20 -0
  212. package/es/custom/sphere.js.map +1 -0
  213. package/es/custom/state.d.ts +13 -0
  214. package/es/custom/state.js +17 -0
  215. package/es/custom/state.js.map +1 -0
  216. package/es/custom/tag-points.d.ts +26 -0
  217. package/es/custom/tag-points.js +77 -0
  218. package/es/custom/tag-points.js.map +1 -0
  219. package/es/custom/update.d.ts +14 -0
  220. package/es/custom/update.js +18 -0
  221. package/es/custom/update.js.map +1 -0
  222. package/es/executor/animate-executor.d.ts +36 -0
  223. package/es/executor/animate-executor.js +169 -0
  224. package/es/executor/animate-executor.js.map +1 -0
  225. package/es/executor/executor.d.ts +69 -0
  226. package/es/executor/executor.js +2 -0
  227. package/es/executor/executor.js.map +1 -0
  228. package/es/index.d.ts +25 -0
  229. package/es/index.js +50 -0
  230. package/es/index.js.map +1 -0
  231. package/es/interpolate/executor.d.ts +66 -0
  232. package/es/interpolate/executor.js +2 -0
  233. package/es/interpolate/executor.js.map +1 -0
  234. package/es/interpolate/number.d.ts +1 -0
  235. package/es/interpolate/number.js +4 -0
  236. package/es/interpolate/number.js.map +1 -0
  237. package/es/interpolate/store.d.ts +32 -0
  238. package/es/interpolate/store.js +88 -0
  239. package/es/interpolate/store.js.map +1 -0
  240. package/es/intreface/animate.d.ts +91 -0
  241. package/es/intreface/animate.js +6 -0
  242. package/es/intreface/animate.js.map +1 -0
  243. package/es/intreface/easing.d.ts +3 -0
  244. package/es/intreface/easing.js +2 -0
  245. package/es/intreface/easing.js.map +1 -0
  246. package/es/intreface/state.d.ts +35 -0
  247. package/es/intreface/state.js +2 -0
  248. package/es/intreface/state.js.map +1 -0
  249. package/es/intreface/ticker.d.ts +37 -0
  250. package/es/intreface/ticker.js +6 -0
  251. package/es/intreface/ticker.js.map +1 -0
  252. package/es/intreface/timeline.d.ts +17 -0
  253. package/es/intreface/timeline.js +2 -0
  254. package/es/intreface/timeline.js.map +1 -0
  255. package/es/intreface/type.d.ts +13 -0
  256. package/es/intreface/type.js +14 -0
  257. package/es/intreface/type.js.map +1 -0
  258. package/es/register.d.ts +1 -0
  259. package/es/register.js +20 -0
  260. package/es/register.js.map +1 -0
  261. package/es/state/animation-state-machine.d.ts +22 -0
  262. package/es/state/animation-state-machine.js +47 -0
  263. package/es/state/animation-state-machine.js.map +1 -0
  264. package/es/state/animation-state-queue.d.ts +24 -0
  265. package/es/state/animation-state-queue.js +58 -0
  266. package/es/state/animation-state-queue.js.map +1 -0
  267. package/es/state/animation-state-registry.d.ts +14 -0
  268. package/es/state/animation-state-registry.js +45 -0
  269. package/es/state/animation-state-registry.js.map +1 -0
  270. package/es/state/animation-state.d.ts +25 -0
  271. package/es/state/animation-state.js +72 -0
  272. package/es/state/animation-state.js.map +1 -0
  273. package/es/state/animation-states-registry.d.ts +17 -0
  274. package/es/state/animation-states-registry.js +87 -0
  275. package/es/state/animation-states-registry.js.map +1 -0
  276. package/es/state/graphic-extension.d.ts +12 -0
  277. package/es/state/graphic-extension.js +29 -0
  278. package/es/state/graphic-extension.js.map +1 -0
  279. package/es/state/index.d.ts +3 -0
  280. package/es/state/index.js +6 -0
  281. package/es/state/index.js.map +1 -0
  282. package/es/state/types.d.ts +11 -0
  283. package/es/state/types.js +2 -0
  284. package/es/state/types.js.map +1 -0
  285. package/es/step.d.ts +49 -0
  286. package/es/step.js +120 -0
  287. package/es/step.js.map +1 -0
  288. package/es/ticker/default-ticker.d.ts +39 -0
  289. package/es/ticker/default-ticker.js +129 -0
  290. package/es/ticker/default-ticker.js.map +1 -0
  291. package/es/ticker/manual-ticker.d.ts +6 -0
  292. package/es/ticker/manual-ticker.js +29 -0
  293. package/es/ticker/manual-ticker.js.map +1 -0
  294. package/es/timeline.d.ts +34 -0
  295. package/es/timeline.js +79 -0
  296. package/es/timeline.js.map +1 -0
  297. package/es/utils/easing-func.d.ts +1 -0
  298. package/es/utils/easing-func.js +8 -0
  299. package/es/utils/easing-func.js.map +1 -0
  300. package/es/utils/easing.d.ts +49 -0
  301. package/es/utils/easing.js +134 -0
  302. package/es/utils/easing.js.map +1 -0
  303. package/package.json +72 -0
package/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # VRender Animation Module
2
+
3
+ This module provides a graph-based animation system for VRender.
4
+
5
+ ## Features
6
+
7
+ - Graph-based animation system
8
+ - Support for simple property animations
9
+ - Support for sequence and parallel animations
10
+ - Support for composite animations
11
+ - Support for custom animations
12
+ - Support for path animations
13
+ - Compatible with the legacy animation system
14
+ - Advanced composition capabilities for nested animations
15
+ - Proper propagation of animation events in complex choreography
16
+
17
+ ## Recent Updates
18
+
19
+ - **Improved Animation Node Composition**: Fixed issues with propagation in `GraphAdapterNode` to ensure proper animation sequencing
20
+ - **Enhanced Duration Calculation**: Better handling of duration for sequence and parallel animations
21
+ - **Better Event Handling**: Improved monitoring of animation completion and successor activation
22
+
23
+ ## Usage
24
+
25
+ ### Basic Property Animation
26
+
27
+ ```typescript
28
+ import { createAnimationNode, createGraphManager } from '@visactor/vrender-animate';
29
+
30
+ // Create a simple animation node
31
+ const moveNode = createAnimationNode({
32
+ id: 'move',
33
+ target: myRect,
34
+ propertyName: 'x',
35
+ toValue: 200,
36
+ duration: 1000
37
+ });
38
+
39
+ // Create a graph manager
40
+ const graphManager = createGraphManager(moveNode, stage);
41
+
42
+ // Start the animation
43
+ graphManager.start();
44
+ ```
45
+
46
+ ### Sequence Animation
47
+
48
+ ```typescript
49
+ import { createAnimationNode, createSequence, createGraphManager } from '@visactor/vrender-animate';
50
+
51
+ // Create animation nodes
52
+ const moveNode = createAnimationNode({
53
+ id: 'move',
54
+ target: myRect,
55
+ propertyName: 'x',
56
+ toValue: 200,
57
+ duration: 1000
58
+ });
59
+
60
+ const colorNode = createAnimationNode({
61
+ id: 'color',
62
+ target: myRect,
63
+ propertyName: 'fill',
64
+ toValue: 'blue',
65
+ duration: 1000
66
+ });
67
+
68
+ // Create a sequence
69
+ const sequence = createSequence([moveNode, colorNode]);
70
+
71
+ // Create a graph manager
72
+ const graphManager = createGraphManager(sequence, stage);
73
+
74
+ // Start the animation
75
+ graphManager.start();
76
+ ```
77
+
78
+ ### Nested Animations (Advanced Composition)
79
+
80
+ The animation system supports nesting of animations, allowing complex choreography:
81
+
82
+ ```typescript
83
+ import { createAnimationNode, createSequence, createParallel, createGraphManager } from '@visactor/vrender-animate';
84
+
85
+ // Create simple animations for rectangle 1
86
+ const moveRect1 = createAnimationNode({
87
+ target: rect1,
88
+ propertyName: 'x',
89
+ toValue: 500,
90
+ duration: 2000
91
+ });
92
+
93
+ const colorRect1 = createAnimationNode({
94
+ target: rect1,
95
+ propertyName: 'fill',
96
+ toValue: 'red',
97
+ duration: 1000
98
+ });
99
+
100
+ // Create simple animations for rectangle 2
101
+ const moveRect2 = createAnimationNode({
102
+ target: rect2,
103
+ propertyName: 'y',
104
+ toValue: 300,
105
+ duration: 1500
106
+ });
107
+
108
+ const colorRect2 = createAnimationNode({
109
+ target: rect2,
110
+ propertyName: 'fill',
111
+ toValue: 'blue',
112
+ duration: 800
113
+ });
114
+
115
+ // Create sequences for each rectangle
116
+ const sequence1 = createSequence([moveRect1, colorRect1]);
117
+ const sequence2 = createSequence([moveRect2, colorRect2]);
118
+
119
+ // Run both sequences in parallel
120
+ const parallelAnimation = createParallel([sequence1, sequence2]);
121
+
122
+ // Create additional animations
123
+ const finalAnimation = createAnimationNode({
124
+ target: rect3,
125
+ propertyName: 'opacity',
126
+ toValue: 0,
127
+ duration: 1000
128
+ });
129
+
130
+ // Create a final sequence that runs the parallel animations and then the final animation
131
+ const fullAnimation = createSequence([parallelAnimation, finalAnimation]);
132
+
133
+ // Create graph manager and start the animation
134
+ const graphManager = createGraphManager(fullAnimation, stage);
135
+ graphManager.start();
136
+ ```
137
+
138
+ ### Cleanup Completed Animations
139
+
140
+ The animation system includes a mechanism to clean up completed animations to free memory and resources:
141
+
142
+ ```typescript
143
+ import { createAnimationNode, createSequence, createGraphManager } from '@visactor/vrender-animate';
144
+
145
+ // Create animation nodes (as shown in previous examples)
146
+ // ...
147
+
148
+ // Create a graph manager
149
+ const graphManager = createGraphManager(myAnimationGraph, stage);
150
+
151
+ // Start the animation
152
+ graphManager.start();
153
+
154
+ // Later, when animations have completed, you can clean up:
155
+ graphManager.onAllComplete = () => {
156
+ console.log('All animations completed');
157
+
158
+ // Remove completed animation nodes
159
+ const removed = graphManager.cleanupCompletedNodes();
160
+ console.log(`Cleaned up ${removed} completed nodes`);
161
+ };
162
+
163
+ // You can also manually trigger cleanup at any time:
164
+ function handleCleanupButtonClick() {
165
+ const removed = graphManager.cleanupCompletedNodes();
166
+ console.log(`Cleaned up ${removed} completed nodes`);
167
+ }
168
+
169
+ // By default, the cleanup is performed in "safe mode", which only removes nodes
170
+ // that have no successors or whose successors have also completed.
171
+ // To forcibly remove all completed nodes:
172
+ graphManager.cleanupCompletedNodes(false);
173
+ ```
174
+
175
+ ## API
176
+
177
+ See the API documentation for more details.
@@ -0,0 +1,15 @@
1
+ import type { IGraphicAnimateParams } from '@visactor/vrender-core';
2
+ import type { IAnimate } from './intreface/animate';
3
+ import { Animate } from './animate';
4
+ import { DefaultTimeline } from './timeline';
5
+ import { DefaultTicker } from './ticker/default-ticker';
6
+ export declare class AnimateExtension {
7
+ animatedAttribute: Record<string, any> | null;
8
+ animates: Map<string | number, IAnimate>;
9
+ getAttributes(final?: boolean): any;
10
+ animate(params?: IGraphicAnimateParams): Animate;
11
+ protected computeAnimatedAttribute(): void;
12
+ createTimeline(): DefaultTimeline;
13
+ createTicker(stage: any): DefaultTicker;
14
+ protected getFinalAttribute(): {};
15
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.AnimateExtension = void 0;
6
+
7
+ const animate_1 = require("./animate"), timeline_1 = require("./timeline"), default_ticker_1 = require("./ticker/default-ticker");
8
+
9
+ class AnimateExtension {
10
+ constructor() {
11
+ this.animatedAttribute = null;
12
+ }
13
+ getAttributes(final = !1) {
14
+ return final ? (this.computeAnimatedAttribute(), this.getFinalAttribute()) : this.attribute;
15
+ }
16
+ animate(params) {
17
+ var _a, _b, _c;
18
+ this.animates || (this.animates = new Map);
19
+ const animate = new animate_1.Animate(null == params ? void 0 : params.id, null !== (_b = null !== (_a = null == params ? void 0 : params.timeline) && void 0 !== _a ? _a : this.stage && this.stage.getTimeline()) && void 0 !== _b ? _b : timeline_1.defaultTimeline, null == params ? void 0 : params.slience);
20
+ if (animate.bind(this), params) {
21
+ const {onStart: onStart, onEnd: onEnd, onRemove: onRemove} = params;
22
+ null != onStart && animate.onStart(onStart), null != onEnd && animate.onEnd(onEnd),
23
+ null != onRemove && animate.onRemove(onRemove);
24
+ }
25
+ return this.animates.set(animate.id, animate), animate.onRemove((() => {
26
+ animate.stop(), this.animates.delete(animate.id);
27
+ })), null === (_c = this.stage) || void 0 === _c || _c.ticker.start(), animate;
28
+ }
29
+ computeAnimatedAttribute() {
30
+ this.animatedAttribute || (this.animatedAttribute = {}, this.animates.forEach((animate => {
31
+ animate.getLoop() !== 1 / 0 && Object.assign(this.animatedAttribute, animate.getEndProps());
32
+ })));
33
+ }
34
+ createTimeline() {
35
+ return new timeline_1.DefaultTimeline;
36
+ }
37
+ createTicker(stage) {
38
+ return new default_ticker_1.DefaultTicker(stage);
39
+ }
40
+ getFinalAttribute() {
41
+ const finalAttribute = {};
42
+ return Object.assign(finalAttribute, this.attribute, this.animatedAttribute), finalAttribute;
43
+ }
44
+ }
45
+
46
+ exports.AnimateExtension = AnimateExtension;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/animate-extension.ts"],"names":[],"mappings":";;;AASA,uCAAoC;AACpC,yCAA8D;AAC9D,4DAAwD;AAGxD,MAAa,gBAAgB;IAA7B;QACE,sBAAiB,GAA+B,IAAI,CAAC;IAkEvD,CAAC;IA9DC,aAAa,CAAC,QAAiB,KAAK;QAClC,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,iBAA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jB,CAAC;IAES,wBAAwB;QAChC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC3B,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;YAE5B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;gBAC9B,IAAI,OAAO,CAAC,OAAO,EAAE,KAAK,QAAQ,EAAE;oBAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;iBAC9D;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,0BAAe,EAAE,CAAC;IAC/B,CAAC;IAED,YAAY,CAAC,KAAU;QACrB,OAAO,IAAI,8BAAa,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAES,iBAAiB;QACzB,MAAM,cAAc,GAAG,EAAE,CAAC;QAC1B,MAAM,CAAC,MAAM,CAAC,cAAc,EAAG,IAAY,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC/E,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAnED,4CAmEC","file":"animate-extension.js","sourcesContent":["// 1. 支持animate函数\n// 2. 支持animates map\n// 2. 支持animatedAttribute 为所有动画的最终结果(loop为INFINITY的动画不算)\n// 3. 支持finalAttribute 为所有动画的最终结果(animatedAttribute 合并了 graphic.attribute之后的最终结果)\n// 3. 重载Graphic的getAttributes方法,根据参数getAttributes(final = true)返回finalAttribute = {}; merge(finalAttribute, graphic.attribute, animatedAttribute),\n// animatedAttribute为所有动画的最终结果(loop为INFINITY的动画不算)\n\nimport type { IGraphicAnimateParams } from '@visactor/vrender-core';\nimport type { IAnimate } from './intreface/animate';\nimport { Animate } from './animate';\nimport { DefaultTimeline, defaultTimeline } from './timeline';\nimport { DefaultTicker } from './ticker/default-ticker';\n\n// 基于性能考虑,每次调用animate函数,都会设置animatedAttribute为null,每次getAttributes(true)会根据animatedAttribute属性判断是否需要重新计算animatedAttribute。\nexport class AnimateExtension {\n animatedAttribute: Record<string, any> | null = null;\n\n declare animates: Map<string | number, IAnimate>;\n\n getAttributes(final: boolean = false) {\n if (final) {\n this.computeAnimatedAttribute();\n return this.getFinalAttribute();\n }\n return (this as any).attribute;\n }\n\n animate(params?: IGraphicAnimateParams) {\n if (!this.animates) {\n this.animates = new Map();\n }\n const animate = new Animate(\n params?.id,\n params?.timeline ?? ((this as any).stage && (this as any).stage.getTimeline()) ?? defaultTimeline,\n params?.slience\n );\n\n animate.bind(this as any);\n if (params) {\n const { onStart, onEnd, onRemove } = params;\n onStart != null && animate.onStart(onStart);\n onEnd != null && animate.onEnd(onEnd);\n onRemove != null && animate.onRemove(onRemove);\n }\n this.animates.set(animate.id, animate);\n animate.onRemove(() => {\n animate.stop();\n this.animates.delete(animate.id);\n });\n\n // TODO 考虑性能问题\n (this as any).stage?.ticker.start();\n\n return animate;\n }\n\n protected computeAnimatedAttribute() {\n if (!this.animatedAttribute) {\n this.animatedAttribute = {};\n\n this.animates.forEach(animate => {\n if (animate.getLoop() !== Infinity) {\n Object.assign(this.animatedAttribute, animate.getEndProps());\n }\n });\n }\n }\n\n createTimeline() {\n return new DefaultTimeline();\n }\n\n createTicker(stage: any) {\n return new DefaultTicker(stage);\n }\n\n protected getFinalAttribute() {\n const finalAttribute = {};\n Object.assign(finalAttribute, (this as any).attribute, this.animatedAttribute);\n return finalAttribute;\n }\n}\n"]}
@@ -0,0 +1,71 @@
1
+ import type { IAnimate, IStep, ICustomAnimate } from './intreface/animate';
2
+ import type { EasingType } from './intreface/easing';
3
+ import { AnimateStatus } from './intreface/type';
4
+ import type { ITimeline } from './intreface/timeline';
5
+ import { type IGraphic } from '@visactor/vrender-core';
6
+ export declare class Animate implements IAnimate {
7
+ readonly id: string | number;
8
+ status: AnimateStatus;
9
+ target: IGraphic;
10
+ _onStart?: (() => void)[];
11
+ _onFrame?: ((step: IStep, ratio: number) => void)[];
12
+ _onEnd?: (() => void)[];
13
+ _onRemove?: (() => void)[];
14
+ private _timeline;
15
+ private _startTime;
16
+ private _duration;
17
+ private _totalDuration;
18
+ private _loopCount;
19
+ private _currentLoop;
20
+ private _bounce;
21
+ private _firstStep;
22
+ private _lastStep;
23
+ private _startProps;
24
+ private _endProps;
25
+ private _preventAttrs;
26
+ priority: number;
27
+ protected currentTime: number;
28
+ slience?: boolean;
29
+ interpolateUpdateFunction: ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void) | null;
30
+ constructor(id?: string | number, timeline?: ITimeline, slience?: boolean);
31
+ getStartProps(): Record<string, any>;
32
+ getEndProps(): Record<string, any>;
33
+ setTimeline(timeline: ITimeline): void;
34
+ getTimeline(): ITimeline;
35
+ get timeline(): ITimeline;
36
+ bind(target: IGraphic): this;
37
+ to(props: Record<string, any>, duration?: number, easing?: EasingType): this;
38
+ wait(delay: number): this;
39
+ protected updateStepAfterAppend(step: IStep): void;
40
+ parseStepProps(step: IStep): void;
41
+ reSyncProps(): void;
42
+ from(props: Record<string, any>, duration?: number, easing?: EasingType): this;
43
+ play(customAnimate: ICustomAnimate): this;
44
+ pause(): void;
45
+ resume(): void;
46
+ onStart(cb?: () => void): void;
47
+ onEnd(cb?: () => void): void;
48
+ onFrame(cb?: (step: IStep, ratio: number) => void): void;
49
+ onRemove(cb?: () => void): void;
50
+ preventAttr(key: string): void;
51
+ preventAttrs(keys: string[]): void;
52
+ validAttr(key: string): boolean;
53
+ runCb(cb: (a: IAnimate, step: IStep) => void): IAnimate;
54
+ startAt(t: number): this;
55
+ customInterpolate(key: string, ratio: number, from: any, to: any, target: IGraphic, ret: Record<string, any>): boolean;
56
+ getFromValue(): Record<string, any>;
57
+ getToValue(): Record<string, any>;
58
+ stop(type?: 'start' | 'end' | Record<string, any>): void;
59
+ release(): void;
60
+ getDuration(): number;
61
+ getStartTime(): number;
62
+ afterAll(list: IAnimate[]): this;
63
+ after(animate: IAnimate): this;
64
+ parallel(animate: IAnimate): this;
65
+ loop(n: number | boolean): this;
66
+ bounce(b: boolean): this;
67
+ advance(delta: number): void;
68
+ updateDuration(): void;
69
+ getTotalDuration(): number;
70
+ getLoop(): number;
71
+ }
package/cjs/animate.js ADDED
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.Animate = void 0;
6
+
7
+ const type_1 = require("./intreface/type"), step_1 = require("./step"), vrender_core_1 = require("@visactor/vrender-core"), timeline_1 = require("./timeline");
8
+
9
+ class Animate {
10
+ constructor(id = vrender_core_1.Generator.GenAutoIncrementId(), timeline = timeline_1.defaultTimeline, slience) {
11
+ this.id = id, this.status = type_1.AnimateStatus.INITIAL, this._timeline = timeline,
12
+ timeline.addAnimate(this), this.slience = slience, this._startTime = 0, this._duration = 0,
13
+ this._totalDuration = 0, this._loopCount = 0, this._currentLoop = 0, this._bounce = !1,
14
+ this._firstStep = null, this._lastStep = null, this._startProps = {}, this._endProps = {},
15
+ this._preventAttrs = new Set, this.currentTime = 0, this.interpolateUpdateFunction = null,
16
+ this.priority = 0;
17
+ }
18
+ getStartProps() {
19
+ return this._startProps;
20
+ }
21
+ getEndProps() {
22
+ return this._endProps;
23
+ }
24
+ setTimeline(timeline) {
25
+ this._timeline = timeline;
26
+ }
27
+ getTimeline() {
28
+ return this._timeline;
29
+ }
30
+ get timeline() {
31
+ return this._timeline;
32
+ }
33
+ bind(target) {
34
+ return this.target = target, this.target.onAnimateBind && !this.slience && this.target.onAnimateBind(this),
35
+ this.target.animationAttribute || (this.target.animationAttribute = {}), this;
36
+ }
37
+ to(props, duration = 300, easing = "linear") {
38
+ const step = new step_1.Step(type_1.AnimateStepType.to, props, duration, easing);
39
+ return this.updateStepAfterAppend(step), step.bind(this.target, this), this;
40
+ }
41
+ wait(delay) {
42
+ const step = new step_1.WaitStep(type_1.AnimateStepType.wait, {}, delay, "linear");
43
+ return this.updateStepAfterAppend(step), step.bind(this.target, this), this;
44
+ }
45
+ updateStepAfterAppend(step) {
46
+ this._firstStep ? (this._lastStep.append(step), this._lastStep = step) : (this._firstStep = step,
47
+ this._lastStep = step), this.parseStepProps(step), this.updateDuration();
48
+ }
49
+ parseStepProps(step) {
50
+ this._lastStep && (step.propKeys = step.propKeys || Object.keys(step.props), Object.keys(this._endProps).forEach((key => {
51
+ var _a;
52
+ step.props[key] = null !== (_a = step.props[key]) && void 0 !== _a ? _a : this._endProps[key];
53
+ })), step.propKeys.forEach((key => {
54
+ this._endProps[key] = step.props[key];
55
+ })));
56
+ }
57
+ reSyncProps() {
58
+ if (!this._lastStep) return;
59
+ this._endProps = {};
60
+ let currentStep = this._firstStep;
61
+ for (;currentStep; ) Object.keys(this._endProps).forEach((key => {
62
+ var _a;
63
+ currentStep.props[key] = null !== (_a = currentStep.props[key]) && void 0 !== _a ? _a : this._endProps[key];
64
+ })), currentStep.propKeys.forEach((key => {
65
+ this._endProps[key] = currentStep.props[key];
66
+ })), currentStep = currentStep.next;
67
+ }
68
+ from(props, duration = 300, easing = "linear") {
69
+ const step = new step_1.Step(type_1.AnimateStepType.from, props, duration, easing);
70
+ return this._firstStep ? (this._lastStep.append(step), this._lastStep = step) : (this._firstStep = step,
71
+ this._lastStep = step), this.updateDuration(), this;
72
+ }
73
+ play(customAnimate) {
74
+ return this.updateStepAfterAppend(customAnimate), customAnimate.bind(this.target, this),
75
+ this;
76
+ }
77
+ pause() {
78
+ this.status === type_1.AnimateStatus.RUNNING && (this.status = type_1.AnimateStatus.PAUSED);
79
+ }
80
+ resume() {
81
+ this.status === type_1.AnimateStatus.PAUSED && (this.status = type_1.AnimateStatus.RUNNING);
82
+ }
83
+ onStart(cb) {
84
+ var _a;
85
+ cb ? (this._onStart || (this._onStart = []), this._onStart.push(cb)) : (null === (_a = this._onStart) || void 0 === _a || _a.forEach((cb => cb())),
86
+ Object.keys(this._endProps).forEach((key => {
87
+ this._startProps[key] = this.target.getComputedAttribute(key);
88
+ })));
89
+ }
90
+ onEnd(cb) {
91
+ var _a;
92
+ cb ? (this._onEnd || (this._onEnd = []), this._onEnd.push(cb)) : null === (_a = this._onEnd) || void 0 === _a || _a.forEach((cb => cb()));
93
+ }
94
+ onFrame(cb) {
95
+ cb && (this._onFrame || (this._onFrame = []), this._onFrame.push(cb));
96
+ }
97
+ onRemove(cb) {
98
+ var _a;
99
+ cb ? (this._onRemove || (this._onRemove = []), this._onRemove.push(cb)) : null === (_a = this._onRemove) || void 0 === _a || _a.forEach((cb => cb()));
100
+ }
101
+ preventAttr(key) {
102
+ this._preventAttrs.add(key), delete this._startProps[key], delete this._endProps[key];
103
+ let step = this._firstStep;
104
+ for (;step; ) step.deleteSelfAttr(key), step = step.next;
105
+ }
106
+ preventAttrs(keys) {
107
+ keys.forEach((key => this._preventAttrs.add(key)));
108
+ }
109
+ validAttr(key) {
110
+ return !this._preventAttrs.has(key);
111
+ }
112
+ runCb(cb) {
113
+ var _a;
114
+ return null === (_a = this._lastStep) || void 0 === _a || _a.onEnd(cb), this;
115
+ }
116
+ startAt(t) {
117
+ return this._startTime = t, this;
118
+ }
119
+ customInterpolate(key, ratio, from, to, target, ret) {
120
+ return !1;
121
+ }
122
+ getFromValue() {
123
+ return this._startProps;
124
+ }
125
+ getToValue() {
126
+ return this._endProps;
127
+ }
128
+ stop(type) {
129
+ this.status = type_1.AnimateStatus.END, this.onEnd(), this.target && ("start" === type ? this.target.setAttributes(this._startProps) : "end" === type ? this.target.setAttributes(this._endProps) : type && this.target.setAttributes(type));
130
+ }
131
+ release() {
132
+ this.status = type_1.AnimateStatus.END, this._onRemove && this._onRemove.forEach((cb => cb())),
133
+ this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [];
134
+ }
135
+ getDuration() {
136
+ return this._duration;
137
+ }
138
+ getStartTime() {
139
+ return this._startTime;
140
+ }
141
+ afterAll(list) {
142
+ if (!list || 0 === list.length) return this;
143
+ let maxEndTime = 0;
144
+ return list.forEach((animate => {
145
+ const endTime = animate.getStartTime() + animate.getTotalDuration();
146
+ maxEndTime = Math.max(maxEndTime, endTime);
147
+ })), this.startAt(maxEndTime);
148
+ }
149
+ after(animate) {
150
+ if (!animate) return this;
151
+ const endTime = animate.getStartTime() + animate.getTotalDuration();
152
+ return this.startAt(endTime);
153
+ }
154
+ parallel(animate) {
155
+ return animate ? (this.startAt(animate.getStartTime()), this) : this;
156
+ }
157
+ loop(n) {
158
+ return !0 === n ? n = 1 / 0 : !1 === n && (n = 0), this._loopCount = n, this.updateDuration(),
159
+ this;
160
+ }
161
+ bounce(b) {
162
+ return this._bounce = b, this;
163
+ }
164
+ advance(delta) {
165
+ var _a;
166
+ if (this.status === type_1.AnimateStatus.END) return void console.warn("aaa 动画已经结束,不能推进");
167
+ const nextTime = this.currentTime + delta;
168
+ if (nextTime < this._startTime) return void (this.currentTime = nextTime);
169
+ if (nextTime >= this._startTime + this._totalDuration) return null === (_a = this._lastStep) || void 0 === _a || _a.onEnd(),
170
+ this.onEnd(), void (this.status = type_1.AnimateStatus.END);
171
+ this.status = type_1.AnimateStatus.RUNNING, this.currentTime <= this._startTime && this.onStart(),
172
+ this.currentTime = nextTime;
173
+ let cycleTime = nextTime - this._startTime, newLoop = !1, bounceTime = !1;
174
+ if (this._loopCount > 0) {
175
+ cycleTime = (nextTime - this._startTime) % this._duration;
176
+ const currentLoop = Math.floor((nextTime - this._startTime) / this._duration);
177
+ newLoop = currentLoop > this._currentLoop, this._currentLoop = currentLoop, bounceTime = this._bounce && currentLoop % 2 == 1,
178
+ bounceTime && (cycleTime = this._duration - cycleTime);
179
+ }
180
+ newLoop && !bounceTime && this.target.setAttributes(this._startProps);
181
+ let targetStep = null;
182
+ if (this._lastStep === this._firstStep) targetStep = this._firstStep; else {
183
+ let currentStep = this._firstStep;
184
+ for (;currentStep; ) {
185
+ const stepStartTime = currentStep.getStartTime(), stepDuration = currentStep.getDuration();
186
+ if (cycleTime >= stepStartTime && cycleTime <= stepStartTime + stepDuration) {
187
+ targetStep = currentStep;
188
+ break;
189
+ }
190
+ currentStep = currentStep.next;
191
+ }
192
+ }
193
+ if (!targetStep) return;
194
+ const ratio = (cycleTime - targetStep.getStartTime()) / targetStep.getDuration(), isEnd = ratio >= 1;
195
+ targetStep.update(isEnd, ratio, {}), isEnd && targetStep.onEnd();
196
+ }
197
+ updateDuration() {
198
+ this._lastStep ? (this._duration = this._lastStep.getStartTime() + this._lastStep.getDuration(),
199
+ this._totalDuration = this._duration * (this._loopCount + 1)) : this._duration = 0;
200
+ }
201
+ getTotalDuration() {
202
+ return this._totalDuration;
203
+ }
204
+ getLoop() {
205
+ return this._loopCount;
206
+ }
207
+ }
208
+
209
+ exports.Animate = Animate;
210
+ //# sourceMappingURL=animate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/animate.ts"],"names":[],"mappings":";;;AAEA,2CAAkE;AAClE,iCAAwC;AAExC,yDAAkE;AAClE,yCAA6C;AAE7C,MAAa,OAAO;IAyClB,YACE,KAAsB,wBAAS,CAAC,kBAAkB,EAAE,EACpD,WAAsB,0BAAe,EACrC,OAAiB;QAEjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,oBAAa,CAAC,OAAO,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QAExB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB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AW,CAAC;oBACzB,MAAM;iBACP;gBAED,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC;aAChC;SACF;QAGD,IAAI,CAAC,UAAU,EAAE;YAGf,OAAO;SACR;QAGD,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC;QAChD,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;QAE9C,MAAM,KAAK,GAAG,CAAC,SAAS,GAAG,aAAa,CAAC,GAAG,YAAY,CAAC;QAIzD,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC;QACzB,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAGpC,IAAI,KAAK,EAAE;YACT,UAAU,CAAC,KAAK,EAAE,CAAC;SAEpB;IAMH,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YACnB,OAAO;SACR;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QAC9E,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AApqBD,0BAoqBC","file":"animate.js","sourcesContent":["import type { IAnimate, IStep, ICustomAnimate } from './intreface/animate';\nimport type { EasingType } from './intreface/easing';\nimport { AnimateStatus, AnimateStepType } from './intreface/type';\nimport { Step, WaitStep } from './step';\nimport type { ITimeline } from './intreface/timeline';\nimport { Generator, type IGraphic } from '@visactor/vrender-core';\nimport { defaultTimeline } from './timeline';\n\nexport class Animate implements IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n target: IGraphic;\n\n // 回调函数列表\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n // 时间控制\n private _timeline: ITimeline;\n private _startTime: number;\n private _duration: number;\n private _totalDuration: number;\n\n // 动画控制\n // private _reversed: boolean;\n private _loopCount: number;\n private _currentLoop: number;\n private _bounce: boolean;\n\n // 链表头节点和尾节点\n private _firstStep: IStep | null;\n private _lastStep: IStep | null;\n\n // 初始属性和屏蔽的属性\n private _startProps: Record<string, any>;\n private _endProps: Record<string, any>;\n private _preventAttrs: Set<string>;\n // 优先级,用于判定是否能被后续的动画preventAttr\n declare priority: number;\n\n protected currentTime: number;\n slience?: boolean;\n\n interpolateUpdateFunction:\n | ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void)\n | null;\n\n constructor(\n id: string | number = Generator.GenAutoIncrementId(),\n timeline: ITimeline = defaultTimeline,\n slience?: boolean\n ) {\n this.id = id;\n this.status = AnimateStatus.INITIAL;\n this._timeline = timeline;\n timeline.addAnimate(this);\n this.slience = slience;\n this._startTime = 0;\n this._duration = 0;\n this._totalDuration = 0;\n // this._reversed = false;\n this._loopCount = 0;\n this._currentLoop = 0;\n this._bounce = false;\n this._firstStep = null;\n this._lastStep = null;\n this._startProps = {};\n this._endProps = {};\n this._preventAttrs = new Set();\n this.currentTime = 0;\n this.interpolateUpdateFunction = null;\n this.priority = 0;\n }\n\n /**\n * 获取开始属性\n */\n getStartProps(): Record<string, any> {\n return this._startProps;\n }\n\n /**\n * 获取结束属性\n */\n getEndProps(): Record<string, any> {\n return this._endProps;\n }\n\n /**\n * 设置时间线\n */\n setTimeline(timeline: ITimeline): void {\n this._timeline = timeline;\n }\n\n /**\n * 获取时间线\n */\n getTimeline(): ITimeline {\n return this._timeline;\n }\n\n /**\n * 时间线属性访问器\n */\n get timeline(): ITimeline {\n return this._timeline;\n }\n\n /**\n * 绑定目标图形\n */\n bind(target: IGraphic): this {\n this.target = target;\n\n if (this.target.onAnimateBind && !this.slience) {\n this.target.onAnimateBind(this as any);\n }\n // 添加一个animationAttribute属性,用于存储动画过程中的属性\n if (!this.target.animationAttribute) {\n this.target.animationAttribute = {};\n }\n return this;\n }\n\n /**\n * 动画步骤:to\n * 添加一个to步骤,这会在当前状态到指定状态间进行插值\n */\n to(props: Record<string, any>, duration: number = 300, easing: EasingType = 'linear'): this {\n // 创建新的step\n const step = new Step(AnimateStepType.to, props, duration, easing);\n\n this.updateStepAfterAppend(step);\n\n step.bind(this.target, this);\n\n return this;\n }\n\n /**\n * 等待延迟\n */\n wait(delay: number): this {\n // 创建新的wait step\n const step = new WaitStep(AnimateStepType.wait, {}, delay, 'linear');\n\n // 如果是第一个step\n this.updateStepAfterAppend(step);\n\n step.bind(this.target, this);\n\n return this;\n }\n\n protected updateStepAfterAppend(step: IStep): void {\n // 如果是第一个step\n if (!this._firstStep) {\n this._firstStep = step;\n this._lastStep = step;\n } else {\n // 添加到链表末尾\n this._lastStep.append(step);\n this._lastStep = step;\n }\n\n this.parseStepProps(step);\n\n this.updateDuration();\n }\n\n /**\n * 解析step的props\n * 1. 预先获取step的propKeys并保存\n * 2. 将截止目前的最新props设置到step.props中,这样该props上的属性就是最终的属性了,跳帧时直接设置即可\n * 3. 同步到_endProps中,保存这个Animate实例的最终props\n * 4. 给step的props的原型链上绑定Animate的_startProps,这样在下一个step查找fromProps的时候,一定能拿得到值\n */\n parseStepProps(step: IStep) {\n if (!this._lastStep) {\n return;\n }\n\n /* 预设置step的属性,基于性能考虑,实现比较复杂 */\n // step.propKeys为真实的props属性的key\n step.propKeys = step.propKeys || Object.keys(step.props);\n // step.props为包含前序step的props的最终props,用于跳帧等场景,可以直接设置\n Object.keys(this._endProps).forEach(key => {\n step.props[key] = step.props[key] ?? this._endProps[key];\n });\n // 将最终的props设置到step.props中\n step.propKeys.forEach(key => {\n this._endProps[key] = step.props[key];\n });\n // 给step的props的原型链上绑定Animate的_startProps\n // 下一个step在查找上一个step.props(也就是找到它的fromProps)的时候,就能拿到初始的props了\n // 比如:\n // rect.animate().to({ x: 100 }, 1000, 'linear').to({ y: 100 }, 1000, 'linear');\n // 在第二个step查找fromProps的时候,就能拿到第一个step的endProps中的y值(在原型链上)\n // TODO 由于会有其他animate的干扰,所以不能直接设置原型链\n // Object.setPrototypeOf(step.props, this._startProps);\n }\n\n /**\n * 重新同步和计算props,用于内部某些step发生了变更后,重新计算自身\n * 性能较差,不要频繁调用\n * @returns\n */\n reSyncProps() {\n if (!this._lastStep) {\n return;\n }\n this._endProps = {};\n let currentStep: IStep = this._firstStep;\n // 从前向后寻找当前时间所在的step\n while (currentStep) {\n // step.props为包含前序step的props的最终props,用于跳帧等场景,可以直接设置\n // eslint-disable-next-line no-loop-func\n Object.keys(this._endProps).forEach(key => {\n currentStep.props[key] = currentStep.props[key] ?? this._endProps[key];\n });\n // 将最终的props设置到step.props中\n // eslint-disable-next-line no-loop-func\n currentStep.propKeys.forEach(key => {\n this._endProps[key] = currentStep.props[key];\n });\n // 给step的props的原型链上绑定Animate的_startProps\n // 下一个step在查找上一个step.props(也就是找到它的fromProps)的时候,就能拿到初始的props了\n // 比如:\n // rect.animate().to({ x: 100 }, 1000, 'linear').to({ y: 100 }, 1000, 'linear');\n // 在第二个step查找fromProps的时候,就能拿到第一个step的endProps中的y值(在原型链上)\n // TODO 由于会有其他animate的干扰,所以不能直接设置原型链\n // Object.setPrototypeOf(currentStep.props, this._startProps);\n currentStep = currentStep.next;\n }\n }\n\n /**\n * 动画步骤:from\n * 添加一个from步骤,这会将目标属性先设置为指定值,然后过渡到当前状态\n * 【注意】这可能会导致动画跳变,请谨慎使用\n */\n from(props: Record<string, any>, duration: number = 300, easing: EasingType = 'linear'): this {\n // 创建新的step\n const step = new Step(AnimateStepType.from, props, duration, easing);\n\n // 如果是第一个step\n if (!this._firstStep) {\n this._firstStep = step;\n this._lastStep = step;\n } else {\n // 添加到链表末尾\n this._lastStep.append(step);\n this._lastStep = step;\n }\n\n this.updateDuration();\n\n return this;\n }\n\n /**\n * 自定义动画\n */\n play(customAnimate: ICustomAnimate): this {\n this.updateStepAfterAppend(customAnimate);\n\n customAnimate.bind(this.target, this);\n\n return this;\n }\n\n /**\n * 暂停动画\n */\n pause(): void {\n if (this.status === AnimateStatus.RUNNING) {\n this.status = AnimateStatus.PAUSED;\n }\n }\n\n /**\n * 恢复动画\n */\n resume(): void {\n if (this.status === AnimateStatus.PAUSED) {\n this.status = AnimateStatus.RUNNING;\n }\n }\n\n /**\n * 注册开始回调\n */\n onStart(cb?: () => void): void {\n if (cb) {\n if (!this._onStart) {\n this._onStart = [];\n }\n this._onStart.push(cb);\n } else {\n this._onStart?.forEach(cb => cb());\n // 设置开始属性,Animate不会重复执行start所以不需要判断firstStart\n Object.keys(this._endProps).forEach(key => {\n this._startProps[key] = this.target.getComputedAttribute(key);\n });\n }\n }\n\n /**\n * 注册结束回调\n */\n onEnd(cb?: () => void): void {\n if (cb) {\n if (!this._onEnd) {\n this._onEnd = [];\n }\n this._onEnd.push(cb);\n } else {\n this._onEnd?.forEach(cb => cb());\n }\n }\n\n /**\n * 注册帧回调\n */\n onFrame(cb?: (step: IStep, ratio: number) => void): void {\n if (cb) {\n if (!this._onFrame) {\n this._onFrame = [];\n }\n this._onFrame.push(cb);\n }\n }\n\n /**\n * 注册移除回调\n */\n onRemove(cb?: () => void): void {\n if (cb) {\n if (!this._onRemove) {\n this._onRemove = [];\n }\n this._onRemove.push(cb);\n } else {\n this._onRemove?.forEach(cb => cb());\n }\n }\n\n /**\n * 屏蔽单个属性\n */\n preventAttr(key: string): void {\n this._preventAttrs.add(key);\n // 从所有step中移除该属性,并从自身的_startProps和_endProps中移除该属性\n delete this._startProps[key];\n delete this._endProps[key];\n let step = this._firstStep;\n while (step) {\n step.deleteSelfAttr(key);\n step = step.next;\n }\n }\n\n /**\n * 屏蔽多个属性\n */\n preventAttrs(keys: string[]): void {\n keys.forEach(key => this._preventAttrs.add(key));\n }\n\n /**\n * 检查属性是否合法(未被屏蔽)\n */\n validAttr(key: string): boolean {\n return !this._preventAttrs.has(key);\n }\n\n /**\n * 运行自定义回调\n */\n runCb(cb: (a: IAnimate, step: IStep) => void): IAnimate {\n this._lastStep?.onEnd(cb);\n return this;\n }\n\n /**\n * 设置动画开始时间\n */\n startAt(t: number): this {\n this._startTime = t;\n\n return this;\n }\n\n /**\n * 自定义插值函数,返回false表示没有匹配上\n */\n customInterpolate(\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IGraphic,\n ret: Record<string, any>\n ): boolean {\n // 默认无自定义插值,可由子类重写\n return false;\n }\n\n /**\n * 获取起始值,该起始值为animate的起始值,并不一定为step的起始值\n */\n getFromValue(): Record<string, any> {\n return this._startProps;\n }\n\n /**\n * 获取结束值\n */\n getToValue(): Record<string, any> {\n return this._endProps;\n }\n\n /**\n * 停止动画\n */\n stop(type?: 'start' | 'end' | Record<string, any>): void {\n // TODO 有些动画可能一添加就被删除\n // if (this.status === AnimateStatus.END) {\n // return;\n // }\n\n this.status = AnimateStatus.END;\n\n this.onEnd();\n\n if (!this.target) {\n return;\n }\n\n if (type === 'start') {\n // 设置为开始状态\n this.target.setAttributes(this._startProps);\n } else if (type === 'end') {\n // 设置为结束状态\n this.target.setAttributes(this._endProps);\n } else if (type) {\n // 设置为自定义状态\n this.target.setAttributes(type);\n }\n }\n\n /**\n * 释放动画资源\n */\n release(): void {\n this.status = AnimateStatus.END;\n\n // 触发移除回调\n if (this._onRemove) {\n this._onRemove.forEach(cb => cb());\n }\n\n // 清空回调\n this._onStart = [];\n this._onFrame = [];\n this._onEnd = [];\n this._onRemove = [];\n }\n\n /**\n * 获取动画持续时间\n */\n getDuration(): number {\n return this._duration;\n }\n\n /**\n * 获取动画开始时间\n */\n getStartTime(): number {\n return this._startTime;\n }\n\n /**\n * 在所有动画完成后执行\n */\n afterAll(list: IAnimate[]): this {\n if (!list || list.length === 0) {\n return this;\n }\n\n // 计算所有动画结束的最大时间点\n let maxEndTime = 0;\n list.forEach(animate => {\n const endTime = animate.getStartTime() + animate.getTotalDuration();\n maxEndTime = Math.max(maxEndTime, endTime);\n });\n\n // 设置当前动画的开始时间为最大结束时间\n return this.startAt(maxEndTime);\n }\n\n /**\n * 在指定动画完成后执行\n */\n after(animate: IAnimate): this {\n if (!animate) {\n return this;\n }\n\n // 计算指定动画结束的时间点\n const endTime = animate.getStartTime() + animate.getTotalDuration();\n\n // 设置当前动画的开始时间为结束时间\n return this.startAt(endTime);\n }\n\n /**\n * 并行执行动画\n */\n parallel(animate: IAnimate): this {\n if (!animate) {\n return this;\n }\n\n // 设置指定动画的开始时间为当前动画的开始时间\n this.startAt(animate.getStartTime());\n\n return this;\n }\n\n // /**\n // * 设置动画是否反转\n // */\n // reversed(r: boolean): this {\n // this._reversed = r;\n // return this;\n // }\n\n /**\n * 设置动画循环次数,如果传入true,则无限循环,如果传入false,则不循环\n */\n loop(n: number | boolean): this {\n if (n === true) {\n n = Infinity;\n } else if (n === false) {\n n = 0;\n }\n this._loopCount = n;\n this.updateDuration();\n return this;\n }\n\n /**\n * 设置动画是否反弹\n */\n bounce(b: boolean): this {\n this._bounce = b;\n return this;\n }\n\n /**\n * 推进动画\n */\n advance(delta: number): void {\n if (this.status === AnimateStatus.END) {\n console.warn('aaa 动画已经结束,不能推进');\n return;\n }\n const nextTime = this.currentTime + delta;\n // 如果还没开始,直接return\n if (nextTime < this._startTime) {\n this.currentTime = nextTime;\n return;\n }\n // 如果已经结束,设置状态后return\n if (nextTime >= this._startTime + this._totalDuration) {\n this._lastStep?.onEnd();\n this.onEnd();\n this.status = AnimateStatus.END;\n return;\n }\n\n this.status = AnimateStatus.RUNNING;\n\n // 如果是第一次运行,触发开始回调\n if (this.currentTime <= this._startTime) {\n this.onStart();\n }\n this.currentTime = nextTime;\n\n let cycleTime = nextTime - this._startTime;\n let newLoop = false;\n let bounceTime = false;\n if (this._loopCount > 0) {\n cycleTime = (nextTime - this._startTime) % this._duration;\n const currentLoop = Math.floor((nextTime - this._startTime) / this._duration);\n newLoop = currentLoop > this._currentLoop;\n this._currentLoop = currentLoop;\n\n bounceTime = this._bounce && currentLoop % 2 === 1;\n if (bounceTime) {\n cycleTime = this._duration - cycleTime;\n }\n }\n\n // 如果是新的循环,重置为初始状态\n if (newLoop && !bounceTime) {\n this.target.setAttributes(this._startProps);\n }\n\n // 选择起始步骤和遍历方向\n let targetStep: IStep | null = null;\n\n if (this._lastStep === this._firstStep) {\n targetStep = this._firstStep;\n } else {\n let currentStep: IStep = this._firstStep;\n // 从前向后寻找当前时间所在的step\n while (currentStep) {\n const stepStartTime = currentStep.getStartTime();\n const stepDuration = currentStep.getDuration();\n const stepEndTime = stepStartTime + stepDuration;\n\n // 找到当前周期时间所在的step\n if (cycleTime >= stepStartTime && cycleTime <= stepEndTime) {\n targetStep = currentStep;\n break;\n }\n\n currentStep = currentStep.next;\n }\n }\n\n // 如果没找到目标step(可能是所有step都执行完了,但整体动画还没结束,这正常是不存在的)\n if (!targetStep) {\n // this.currentTime = nextTime;\n // console.warn('动画出现问题');\n return;\n }\n\n // 计算当前step的进度比例(基于当前step内的相对时间)\n const stepStartTime = targetStep.getStartTime();\n const stepDuration = targetStep.getDuration();\n\n const ratio = (cycleTime - stepStartTime) / stepDuration;\n // // 限制ratio在0-1之间\n // ratio = Math.max(0, Math.min(1, ratio));\n\n const isEnd = ratio >= 1;\n targetStep.update(isEnd, ratio, {});\n\n // 如果step执行完毕\n if (isEnd) {\n targetStep.onEnd();\n // 不立即调用onFinish,让动画系统来决定何时结束\n }\n\n // 触发帧回调\n // if (this._onFrame) {\n // this._onFrame.forEach(cb => cb(targetStep, ratio));\n // }\n }\n\n updateDuration(): void {\n if (!this._lastStep) {\n this._duration = 0;\n return;\n }\n\n this._duration = this._lastStep.getStartTime() + this._lastStep.getDuration();\n this._totalDuration = this._duration * (this._loopCount + 1);\n }\n\n getTotalDuration(): number {\n return this._totalDuration;\n }\n\n getLoop(): number {\n return this._loopCount;\n }\n}\n"]}
@@ -0,0 +1,53 @@
1
+ import type { IGraphic, IGroup } from '@visactor/vrender-core';
2
+ import { ACustomAnimate } from './custom-animate';
3
+ import type { EasingType } from '../intreface/easing';
4
+ export declare class ClipGraphicAnimate extends ACustomAnimate<any> {
5
+ private _group?;
6
+ private _clipGraphic?;
7
+ protected clipFromAttribute?: any;
8
+ protected clipToAttribute?: any;
9
+ private _lastClip?;
10
+ private _lastPath?;
11
+ constructor(from: any, to: any, duration: number, easing: EasingType, params: {
12
+ group: IGroup;
13
+ clipGraphic: IGraphic;
14
+ });
15
+ onBind(): void;
16
+ onEnd(): void;
17
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
18
+ }
19
+ export declare class ClipAngleAnimate extends ClipGraphicAnimate {
20
+ constructor(from: any, to: any, duration: number, easing: EasingType, params: {
21
+ group: IGroup;
22
+ center?: {
23
+ x: number;
24
+ y: number;
25
+ };
26
+ startAngle?: number;
27
+ radius?: number;
28
+ orient?: 'clockwise' | 'anticlockwise';
29
+ animationType?: 'in' | 'out';
30
+ });
31
+ }
32
+ export declare class ClipRadiusAnimate extends ClipGraphicAnimate {
33
+ constructor(from: any, to: any, duration: number, easing: EasingType, params: {
34
+ group: IGroup;
35
+ center?: {
36
+ x: number;
37
+ y: number;
38
+ };
39
+ startRadius?: number;
40
+ endRadius?: number;
41
+ animationType?: 'in' | 'out';
42
+ });
43
+ }
44
+ export declare class ClipDirectionAnimate extends ClipGraphicAnimate {
45
+ constructor(from: any, to: any, duration: number, easing: EasingType, params: {
46
+ group: IGroup;
47
+ direction?: 'x' | 'y';
48
+ orient?: 'positive' | 'negative';
49
+ width?: number;
50
+ height?: number;
51
+ animationType?: 'in' | 'out';
52
+ });
53
+ }