@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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/custom/sphere.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,qDAAkD;AAUlD,MAAa,qBAAsB,SAAQ,+BAAmB;IAK5D,OAAO;QACL,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QACtF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/C,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/D,IAAI,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE;YACzB,KAAK,GAAG,YAAG,GAAG,KAAK,CAAC;SACrB;QACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,MAAM;QACJ,OAAO;IACT,CAAC;IAED,KAAK;QACH,OAAO;IACT,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,IAAI,IAAI,CAAC,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GAAG,CAAC,KAAK,CAAC;QAE5B,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;CACF;AApDD,sDAoDC","file":"sphere.js","sourcesContent":["import { pi, pi2 } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ntype RotateSphereParams =\n | {\n center: { x: number; y: number; z: number };\n r: number;\n cb?: (out: any) => void;\n }\n | (() => any);\n\nexport class RotateBySphereAnimate extends ACustomAnimate<any> {\n declare params: RotateSphereParams;\n declare theta: number;\n declare phi: number;\n\n onStart(): void {\n const { center, r } = typeof this.params === 'function' ? this.params() : this.params;\n const startX = this.target.getComputedAttribute('x');\n const startY = this.target.getComputedAttribute('y');\n const startZ = this.target.getComputedAttribute('z');\n const phi = Math.acos((startY - center.y) / r);\n let theta = Math.acos((startX - center.x) / r / Math.sin(phi));\n if (startZ - center.z < 0) {\n theta = pi2 - theta;\n }\n this.theta = theta;\n this.phi = phi;\n }\n\n onBind() {\n return;\n }\n\n onEnd() {\n return;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (this.phi == null || this.theta == null) {\n return;\n }\n const { center, r, cb } = typeof this.params === 'function' ? this.params() : this.params;\n const deltaAngle = Math.PI * 2 * ratio;\n const theta = this.theta + deltaAngle;\n const phi = this.phi;\n const x = r * Math.sin(phi) * Math.cos(theta) + center.x;\n const y = r * Math.cos(phi) + center.y;\n const z = r * Math.sin(phi) * Math.sin(theta) + center.z;\n out.x = x;\n out.y = y;\n out.z = z;\n // out.beta = phi;\n out.alpha = theta + pi / 2;\n while (out.alpha > pi2) {\n out.alpha -= pi2;\n }\n out.alpha = pi2 - out.alpha;\n\n out.zIndex = out.z * -10000;\n\n cb && cb(out);\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { EasingType } from '../intreface/easing';
2
+ import { ACustomAnimate } from './custom-animate';
3
+ export interface IUpdateAnimationOptions {
4
+ diffAttrs: Record<string, any>;
5
+ animationState: string;
6
+ diffState: string;
7
+ data: Record<string, any>[];
8
+ }
9
+ export declare class State extends ACustomAnimate<Record<string, number>> {
10
+ valid: boolean;
11
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: IUpdateAnimationOptions);
12
+ update(end: boolean, ratio: number, out: Record<string, any>): void;
13
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.State = void 0;
6
+
7
+ const custom_animate_1 = require("./custom-animate");
8
+
9
+ class State extends custom_animate_1.ACustomAnimate {
10
+ constructor(from, to, duration, easing, params) {
11
+ super(from, to, duration, easing, params);
12
+ }
13
+ update(end, ratio, out) {
14
+ if (this.onStart(), !this.props || !this.propKeys) return;
15
+ const easedRatio = this.easing(ratio);
16
+ this.animate.interpolateUpdateFunction ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target) : this.interpolateUpdateFunctions.forEach(((func, index) => {
17
+ if (!this.animate.validAttr(this.propKeys[index])) return;
18
+ const key = this.propKeys[index];
19
+ func(key, this.fromProps[key], this.props[key], easedRatio, this, this.target);
20
+ })), this.onUpdate(end, easedRatio, out);
21
+ }
22
+ }
23
+
24
+ exports.State = State;
25
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/custom/state.ts"],"names":[],"mappings":";;;AAEA,qDAAkD;AAclD,MAAa,KAAM,SAAQ,+BAAsC;IAG/D,YAAY,IAAU,EAAE,EAAQ,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAAgC;QACtG,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACjC,OAAO;SACR;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,yBAAyB;YACpC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YACnG,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBAEtD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;oBACjD,OAAO;iBACR;gBACD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACtC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAChC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/D,CAAC,CAAC,CAAC;QACP,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;CACF;AA5BD,sBA4BC","file":"state.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IUpdateAnimationOptions {\n diffAttrs: Record<string, any>;\n animationState: string;\n diffState: string;\n data: Record<string, any>[];\n}\n\n/**\n * 文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n */\nexport class State extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IUpdateAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n this.onStart();\n if (!this.props || !this.propKeys) {\n return;\n }\n // 应用缓动函数\n const easedRatio = this.easing(ratio);\n this.animate.interpolateUpdateFunction\n ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target)\n : this.interpolateUpdateFunctions.forEach((func, index) => {\n // 如果这个属性被屏蔽了,直接跳过\n if (!this.animate.validAttr(this.propKeys[index])) {\n return;\n }\n const key = this.propKeys[index];\n const fromValue = this.fromProps[key];\n const toValue = this.props[key];\n func(key, fromValue, toValue, easedRatio, this, this.target);\n });\n this.onUpdate(end, easedRatio, out);\n }\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import type { IPointLike } from '@visactor/vutils';
2
+ import { ACustomAnimate } from './custom-animate';
3
+ import type { ISegment } from '@visactor/vrender-core';
4
+ import type { EasingType } from '../intreface/easing';
5
+ export declare class TagPointsUpdate extends ACustomAnimate<{
6
+ points?: IPointLike[];
7
+ segments?: ISegment[];
8
+ }> {
9
+ protected fromPoints: IPointLike[];
10
+ protected toPoints: IPointLike[];
11
+ protected points: IPointLike[];
12
+ protected interpolatePoints: [IPointLike, IPointLike][];
13
+ protected newPointAnimateType: 'grow' | 'appear' | 'clip';
14
+ protected clipRange: number;
15
+ protected shrinkClipRange: number;
16
+ protected clipRangeByDimension: 'x' | 'y';
17
+ protected segmentsCache: number[];
18
+ constructor(from: any, to: any, duration: number, easing: EasingType, params?: {
19
+ newPointAnimateType?: 'grow' | 'appear' | 'clip';
20
+ clipRangeByDimension?: 'x' | 'y';
21
+ });
22
+ private getPoints;
23
+ onBind(): void;
24
+ onFirstRun(): void;
25
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
26
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.TagPointsUpdate = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils"), custom_animate_1 = require("./custom-animate"), vrender_core_1 = require("@visactor/vrender-core");
8
+
9
+ class TagPointsUpdate extends custom_animate_1.ACustomAnimate {
10
+ constructor(from, to, duration, easing, params) {
11
+ var _a, _b;
12
+ super(from, to, duration, easing, params), this.newPointAnimateType = null !== (_a = null == params ? void 0 : params.newPointAnimateType) && void 0 !== _a ? _a : "grow",
13
+ this.clipRangeByDimension = null !== (_b = null == params ? void 0 : params.clipRangeByDimension) && void 0 !== _b ? _b : "x";
14
+ }
15
+ getPoints(attribute, cache = !1) {
16
+ if (attribute.points) return attribute.points;
17
+ if (attribute.segments) {
18
+ const points = [];
19
+ return this.segmentsCache || (this.segmentsCache = []), attribute.segments.map((segment => {
20
+ var _a, _b;
21
+ segment.points && points.push(...segment.points), cache && this.segmentsCache.push(null !== (_b = null === (_a = segment.points) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0);
22
+ })), points;
23
+ }
24
+ return [];
25
+ }
26
+ onBind() {
27
+ const originFromPoints = this.getPoints(this.from), originToPoints = this.getPoints(this.to, !0);
28
+ this.fromPoints = originFromPoints ? Array.isArray(originFromPoints) ? originFromPoints : [ originFromPoints ] : [],
29
+ this.toPoints = originToPoints ? Array.isArray(originToPoints) ? originToPoints : [ originToPoints ] : [];
30
+ const tagMap = new Map;
31
+ this.fromPoints.forEach((point => {
32
+ point.context && tagMap.set(point.context, point);
33
+ }));
34
+ let firstMatchedPoint, lastMatchedPoint, firstMatchedIndex = 1 / 0, lastMatchedIndex = -1 / 0;
35
+ for (let i = 0; i < this.toPoints.length; i += 1) if (tagMap.has(this.toPoints[i].context)) {
36
+ firstMatchedIndex = i, firstMatchedPoint = tagMap.get(this.toPoints[i].context);
37
+ break;
38
+ }
39
+ for (let i = this.toPoints.length - 1; i >= 0; i -= 1) if (tagMap.has(this.toPoints[i].context)) {
40
+ lastMatchedIndex = i, lastMatchedPoint = tagMap.get(this.toPoints[i].context);
41
+ break;
42
+ }
43
+ "clip" === this.newPointAnimateType && 0 !== this.toPoints.length && (Number.isFinite(lastMatchedIndex) ? (this.clipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension],
44
+ 1 === this.clipRange && (this.shrinkClipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.fromPoints[this.fromPoints.length - 1][this.clipRangeByDimension]),
45
+ (0, vutils_1.isValidNumber)(this.clipRange) ? this.clipRange = (0, vutils_1.clamp)(this.clipRange, 0, 1) : this.clipRange = 0) : this.clipRange = 0);
46
+ let prevMatchedPoint = this.toPoints[0];
47
+ this.interpolatePoints = this.toPoints.map(((point, index) => {
48
+ const matchedPoint = tagMap.get(point.context);
49
+ return matchedPoint ? (prevMatchedPoint = matchedPoint, [ matchedPoint, point ]) : "appear" === this.newPointAnimateType || "clip" === this.newPointAnimateType ? [ point, point ] : index < firstMatchedIndex && firstMatchedPoint ? [ firstMatchedPoint, point ] : index > lastMatchedIndex && lastMatchedPoint ? [ lastMatchedPoint, point ] : [ prevMatchedPoint, point ];
50
+ })), this.points = this.interpolatePoints.map((interpolate => {
51
+ const fromPoint = interpolate[0], toPoint = interpolate[1], newPoint = new vutils_1.Point(fromPoint.x, fromPoint.y, fromPoint.x1, fromPoint.y1);
52
+ return newPoint.defined = toPoint.defined, newPoint.context = toPoint.context, newPoint;
53
+ }));
54
+ }
55
+ onFirstRun() {
56
+ const lastClipRange = this.target.attribute.clipRange;
57
+ (0, vutils_1.isValidNumber)(lastClipRange * this.clipRange) && (this.clipRange *= lastClipRange);
58
+ }
59
+ onUpdate(end, ratio, out) {
60
+ if (this.points = this.points.map(((point, index) => {
61
+ const newPoint = (0, vrender_core_1.pointInterpolation)(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
62
+ return newPoint.context = point.context, newPoint;
63
+ })), this.clipRange) {
64
+ if (this.shrinkClipRange) return void (end ? (out.points = this.toPoints, out.clipRange = 1) : (out.points = this.fromPoints,
65
+ out.clipRange = this.clipRange - (this.clipRange - this.shrinkClipRange) * ratio));
66
+ out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
67
+ }
68
+ if (this.segmentsCache && this.to.segments) {
69
+ let start = 0;
70
+ out.segments = this.to.segments.map(((segment, index) => {
71
+ const end = start + this.segmentsCache[index], points = this.points.slice(start, end);
72
+ return start = end, Object.assign(Object.assign({}, segment), {
73
+ points: points
74
+ });
75
+ }));
76
+ } else out.points = this.points;
77
+ }
78
+ }
79
+
80
+ exports.TagPointsUpdate = TagPointsUpdate;
81
+ //# sourceMappingURL=tag-points.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/custom/tag-points.ts"],"names":[],"mappings":";;;AACA,6CAA+D;AAC/D,qDAAkD;AAElD,yDAA4D;AAG5D,MAAa,eAAgB,SAAQ,+BAAgE;IAWnG,YACE,IAAS,EACT,EAAO,EACP,QAAgB,EAChB,MAAkB,EAClB,MAA+F;;QAE/F,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,mBAAmB,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,mBAAmB,mCAAI,MAAM,CAAC;QACjE,IAAI,CAAC,oBAAoB,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,oBAAoB,mCAAI,GAAG,CAAC;IAClE,CAAC;IAEO,SAAS,CAAC,SAA2B,EAAE,KAAK,GAAG,KAAK;QAC1D,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,OAAO,SAAS,CAAC,MAAM,CAAC;SACzB;QAED,IAAI,SAAS,CAAC,QAAQ,EAAE;YACtB,MAAM,MAAM,GAAG,EAAkB,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;gBACvB,IAAI,CAA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AC,CAAC,CAAC;SACJ;aAAM;YACL,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;SAC1B;IACH,CAAC;CACF;AA5KD,0CA4KC","file":"tag-points.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { clamp, isValidNumber, Point } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\nimport type { ISegment } from '@visactor/vrender-core';\nimport { pointInterpolation } from '@visactor/vrender-core';\nimport type { EasingType } from '../intreface/easing';\n\nexport class TagPointsUpdate extends ACustomAnimate<{ points?: IPointLike[]; segments?: ISegment[] }> {\n protected fromPoints: IPointLike[];\n protected toPoints: IPointLike[];\n protected points: IPointLike[];\n protected interpolatePoints: [IPointLike, IPointLike][];\n protected newPointAnimateType: 'grow' | 'appear' | 'clip';\n protected clipRange: number;\n protected shrinkClipRange: number;\n protected clipRangeByDimension: 'x' | 'y';\n protected segmentsCache: number[];\n\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params?: { newPointAnimateType?: 'grow' | 'appear' | 'clip'; clipRangeByDimension?: 'x' | 'y' }\n ) {\n super(from, to, duration, easing, params);\n this.newPointAnimateType = params?.newPointAnimateType ?? 'grow';\n this.clipRangeByDimension = params?.clipRangeByDimension ?? 'x';\n }\n\n private getPoints(attribute: typeof this.from, cache = false): IPointLike[] {\n if (attribute.points) {\n return attribute.points;\n }\n\n if (attribute.segments) {\n const points = [] as IPointLike[];\n if (!this.segmentsCache) {\n this.segmentsCache = [];\n }\n attribute.segments.map((segment: any) => {\n if (segment.points) {\n points.push(...segment.points);\n }\n if (cache) {\n this.segmentsCache.push(segment.points?.length ?? 0);\n }\n });\n return points;\n }\n return [];\n }\n\n onBind(): void {\n const originFromPoints = this.getPoints(this.from);\n const originToPoints = this.getPoints(this.to, true);\n this.fromPoints = !originFromPoints ? [] : !Array.isArray(originFromPoints) ? [originFromPoints] : originFromPoints;\n this.toPoints = !originToPoints ? [] : !Array.isArray(originToPoints) ? [originToPoints] : originToPoints;\n\n const tagMap = new Map<string, IPointLike>();\n this.fromPoints.forEach(point => {\n if (point.context) {\n tagMap.set(point.context, point);\n }\n });\n let firstMatchedIndex = Infinity;\n let lastMatchedIndex = -Infinity;\n let firstMatchedPoint: IPointLike;\n let lastMatchedPoint: IPointLike;\n for (let i = 0; i < this.toPoints.length; i += 1) {\n if (tagMap.has(this.toPoints[i].context)) {\n firstMatchedIndex = i;\n firstMatchedPoint = tagMap.get(this.toPoints[i].context);\n break;\n }\n }\n for (let i = this.toPoints.length - 1; i >= 0; i -= 1) {\n if (tagMap.has(this.toPoints[i].context)) {\n lastMatchedIndex = i;\n lastMatchedPoint = tagMap.get(this.toPoints[i].context);\n break;\n }\n }\n\n if (this.newPointAnimateType === 'clip') {\n if (this.toPoints.length !== 0) {\n if (Number.isFinite(lastMatchedIndex)) {\n this.clipRange =\n this.toPoints[lastMatchedIndex][this.clipRangeByDimension] /\n this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension];\n if (this.clipRange === 1) {\n this.shrinkClipRange =\n this.toPoints[lastMatchedIndex][this.clipRangeByDimension] /\n this.fromPoints[this.fromPoints.length - 1][this.clipRangeByDimension];\n }\n if (!isValidNumber(this.clipRange)) {\n this.clipRange = 0;\n } else {\n this.clipRange = clamp(this.clipRange, 0, 1);\n }\n } else {\n this.clipRange = 0;\n }\n }\n }\n // TODO: shrink removed points\n // if no point is matched, animation should start from toPoint[0]\n let prevMatchedPoint = this.toPoints[0];\n this.interpolatePoints = this.toPoints.map((point, index) => {\n const matchedPoint = tagMap.get(point.context);\n if (matchedPoint) {\n prevMatchedPoint = matchedPoint;\n return [matchedPoint, point];\n }\n // appear new point\n if (this.newPointAnimateType === 'appear' || this.newPointAnimateType === 'clip') {\n return [point, point];\n }\n // grow new point\n if (index < firstMatchedIndex && firstMatchedPoint) {\n return [firstMatchedPoint, point];\n } else if (index > lastMatchedIndex && lastMatchedPoint) {\n return [lastMatchedPoint, point];\n }\n return [prevMatchedPoint, point];\n });\n this.points = this.interpolatePoints.map(interpolate => {\n const fromPoint = interpolate[0];\n const toPoint = interpolate[1];\n const newPoint = new Point(fromPoint.x, fromPoint.y, fromPoint.x1, fromPoint.y1);\n newPoint.defined = toPoint.defined;\n newPoint.context = toPoint.context;\n return newPoint;\n });\n }\n\n onFirstRun(): void {\n const lastClipRange = (this.target.attribute as any).clipRange;\n if (isValidNumber(lastClipRange * this.clipRange)) {\n this.clipRange *= lastClipRange;\n }\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n // if not create new points, multi points animation might not work well.\n this.points = this.points.map((point, index) => {\n const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);\n newPoint.context = point.context;\n return newPoint;\n });\n if (this.clipRange) {\n if (this.shrinkClipRange) {\n // 折线变短\n if (!end) {\n out.points = this.fromPoints;\n out.clipRange = this.clipRange - (this.clipRange - this.shrinkClipRange) * ratio;\n } else {\n out.points = this.toPoints;\n out.clipRange = 1;\n }\n return;\n }\n out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;\n }\n if (this.segmentsCache && this.to.segments) {\n let start = 0;\n out.segments = this.to.segments.map((segment: any, index: any) => {\n const end = start + this.segmentsCache[index];\n const points = this.points.slice(start, end);\n start = end;\n return {\n ...segment,\n points\n };\n });\n } else {\n out.points = this.points;\n }\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type { EasingType } from '../intreface/easing';
2
+ import { ACustomAnimate } from './custom-animate';
3
+ export interface IUpdateAnimationOptions {
4
+ diffAttrs: Record<string, any>;
5
+ animationState: string;
6
+ diffState: string;
7
+ data: Record<string, any>[];
8
+ }
9
+ export declare class Update extends ACustomAnimate<Record<string, number>> {
10
+ valid: boolean;
11
+ params: IUpdateAnimationOptions;
12
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: IUpdateAnimationOptions);
13
+ update(end: boolean, ratio: number, out: Record<string, any>): void;
14
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.Update = void 0;
6
+
7
+ const custom_animate_1 = require("./custom-animate");
8
+
9
+ class Update extends custom_animate_1.ACustomAnimate {
10
+ constructor(from, to, duration, easing, params) {
11
+ const {diffAttrs: diffAttrs = {}} = params;
12
+ super(from, diffAttrs, duration, easing, params), this.params = params;
13
+ }
14
+ update(end, ratio, out) {
15
+ if (this.onStart(), !this.props || !this.propKeys) return;
16
+ const easedRatio = this.easing(ratio);
17
+ this.animate.interpolateUpdateFunction ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target) : this.interpolateUpdateFunctions.forEach(((func, index) => {
18
+ if (!this.animate.validAttr(this.propKeys[index])) return;
19
+ const key = this.propKeys[index];
20
+ func(key, this.fromProps[key], this.props[key], easedRatio, this, this.target);
21
+ })), this.onUpdate(end, easedRatio, out);
22
+ }
23
+ }
24
+
25
+ exports.Update = Update;
26
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/custom/update.ts"],"names":[],"mappings":";;;AAEA,qDAAkD;AAclD,MAAa,MAAO,SAAQ,+BAAsC;IAIhE,YAAY,IAAU,EAAE,EAAQ,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAAgC;QACtG,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;QAClC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACjC,OAAO;SACR;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,yBAAyB;YACpC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YACnG,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBAEtD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;oBACjD,OAAO;iBACR;gBACD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACtC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAChC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/D,CAAC,CAAC,CAAC;QACP,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;CACF;AA/BD,wBA+BC","file":"update.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IUpdateAnimationOptions {\n diffAttrs: Record<string, any>;\n animationState: string;\n diffState: string;\n data: Record<string, any>[];\n}\n\n/**\n * 文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n */\nexport class Update extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n params: IUpdateAnimationOptions;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IUpdateAnimationOptions) {\n const { diffAttrs = {} } = params;\n super(from, diffAttrs, duration, easing, params);\n this.params = params;\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n this.onStart();\n if (!this.props || !this.propKeys) {\n return;\n }\n // 应用缓动函数\n const easedRatio = this.easing(ratio);\n this.animate.interpolateUpdateFunction\n ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target)\n : this.interpolateUpdateFunctions.forEach((func, index) => {\n // 如果这个属性被屏蔽了,直接跳过\n if (!this.animate.validAttr(this.propKeys[index])) {\n return;\n }\n const key = this.propKeys[index];\n const fromValue = this.fromProps[key];\n const toValue = this.props[key];\n func(key, fromValue, toValue, easedRatio, this, this.target);\n });\n this.onUpdate(end, easedRatio, out);\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import type { IGraphic } from '@visactor/vrender-core';
2
+ import type { IAnimationConfig, IAnimationCustomConstructor } from './executor';
3
+ import type { IAnimate } from '../intreface/animate';
4
+ interface IAnimateExecutor {
5
+ execute: (params: IAnimationConfig) => void;
6
+ executeItem: (params: IAnimationConfig, graphic: IGraphic, index?: number) => IAnimate | null;
7
+ onStart: (cb?: () => void) => void;
8
+ onEnd: (cb?: () => void) => void;
9
+ }
10
+ export declare class AnimateExecutor implements IAnimateExecutor {
11
+ static builtInAnimateMap: Record<string, IAnimationCustomConstructor>;
12
+ static registerBuiltInAnimate(name: string, animate: IAnimationCustomConstructor): void;
13
+ _target: IGraphic;
14
+ private _animates;
15
+ private _startCallbacks;
16
+ private _endCallbacks;
17
+ private _started;
18
+ private _activeCount;
19
+ constructor(target: IGraphic);
20
+ onStart(cb?: () => void): void;
21
+ onEnd(cb?: () => void): void;
22
+ private _trackAnimation;
23
+ parseParams(params: IAnimationConfig): IAnimationConfig;
24
+ execute(params: IAnimationConfig): void;
25
+ private executeTypeConfigItem;
26
+ private _handleRunAnimate;
27
+ private executeTimelineItem;
28
+ private applyTimeSliceToAnimate;
29
+ private createCustomInterpolatorAnimation;
30
+ private createCustomAnimation;
31
+ private createPropsFromChannel;
32
+ private resolveValue;
33
+ executeItem(params: IAnimationConfig, graphic: IGraphic, index?: number, count?: number): IAnimate | null;
34
+ stop(type?: 'start' | 'end' | Record<string, any>): void;
35
+ }
36
+ export {};
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.AnimateExecutor = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils");
8
+
9
+ class AnimateExecutor {
10
+ static registerBuiltInAnimate(name, animate) {
11
+ AnimateExecutor.builtInAnimateMap[name] = animate;
12
+ }
13
+ constructor(target) {
14
+ this._animates = [], this._startCallbacks = [], this._endCallbacks = [], this._started = !1,
15
+ this._activeCount = 0, this._target = target;
16
+ }
17
+ onStart(cb) {
18
+ cb ? (this._startCallbacks.push(cb), this._started && this._activeCount > 0 && cb()) : this._startCallbacks.forEach((cb => {
19
+ cb();
20
+ }));
21
+ }
22
+ onEnd(cb) {
23
+ cb ? this._endCallbacks.push(cb) : this._endCallbacks.forEach((cb => {
24
+ cb();
25
+ }));
26
+ }
27
+ _trackAnimation(animate) {
28
+ this._animates.push(animate), this._activeCount++, 1 !== this._activeCount || this._started || (this._started = !0,
29
+ this.onStart()), animate.onEnd((() => {
30
+ this._activeCount--;
31
+ const index = this._animates.indexOf(animate);
32
+ index >= 0 && this._animates.splice(index, 1), 0 === this._activeCount && this._started && (this._started = !1,
33
+ this.onEnd());
34
+ }));
35
+ }
36
+ parseParams(params) {
37
+ const isTimeline = "timeSlices" in params, totalTime = this.resolveValue(params.totalTime, void 0, void 0), startTime = this.resolveValue(params.startTime, void 0, 0), parsedParams = (0,
38
+ vutils_1.cloneDeep)(params);
39
+ parsedParams.oneByOneDelay = 0, parsedParams.startTime = startTime, parsedParams.totalTime = totalTime;
40
+ const oneByOne = this.resolveValue(params.oneByOne, void 0, !1);
41
+ if (isTimeline) {
42
+ const timeSlices = parsedParams.timeSlices;
43
+ (0, vutils_1.isArray)(timeSlices) || (parsedParams.timeSlices = [ timeSlices ]);
44
+ let sliceTime = 0;
45
+ parsedParams.timeSlices.forEach((slice => {
46
+ slice.delay = this.resolveValue(slice.delay, void 0, 0), slice.delayAfter = this.resolveValue(slice.delayAfter, void 0, 0),
47
+ slice.duration = this.resolveValue(slice.duration, void 0, 300), sliceTime += slice.delay + slice.duration + slice.delayAfter;
48
+ }));
49
+ let oneByOneDelay = 0, oneByOneTime = 0;
50
+ if (oneByOne && (oneByOneTime = Number(oneByOne), oneByOneDelay = oneByOneTime),
51
+ parsedParams.oneByOne = oneByOneTime, parsedParams.oneByOneDelay = oneByOneDelay,
52
+ totalTime) {
53
+ const _totalTime = sliceTime + oneByOneDelay * (this._target.count - 2), scale = totalTime ? totalTime / _totalTime : 1;
54
+ parsedParams.timeSlices.forEach((slice => {
55
+ slice.delay = slice.delay * scale, slice.delayAfter = slice.delayAfter * scale,
56
+ slice.duration = slice.duration * scale;
57
+ })), parsedParams.oneByOne = oneByOneTime * scale, parsedParams.oneByOneDelay = oneByOneDelay * scale,
58
+ parsedParams.startTime = startTime * scale;
59
+ }
60
+ } else {
61
+ const delay = this.resolveValue(params.delay, void 0, 0), delayAfter = this.resolveValue(params.delayAfter, void 0, 0), duration = this.resolveValue(params.duration, void 0, 300);
62
+ let oneByOneDelay = 0, oneByOneTime = 0;
63
+ if (oneByOne && (oneByOneTime = Number(oneByOne), oneByOneDelay = duration + oneByOneTime),
64
+ parsedParams.oneByOne = oneByOneTime, parsedParams.oneByOneDelay = oneByOneDelay,
65
+ totalTime) {
66
+ const _totalTime = delay + delayAfter + duration + oneByOneDelay * (this._target.count - 2), scale = totalTime ? totalTime / _totalTime : 1;
67
+ parsedParams.delay = delay * scale, parsedParams.delayAfter = delayAfter * scale,
68
+ parsedParams.duration = duration * scale, parsedParams.oneByOne = oneByOneTime * scale,
69
+ parsedParams.oneByOneDelay = oneByOneDelay * scale, parsedParams.startTime = startTime;
70
+ }
71
+ }
72
+ return parsedParams;
73
+ }
74
+ execute(params) {
75
+ const isTimeline = "timeSlices" in params;
76
+ let filteredChildren;
77
+ isTimeline && params.partitioner && (filteredChildren = (null != filteredChildren ? filteredChildren : this._target.getChildren()).filter((child => {
78
+ var _a;
79
+ return params.partitioner(null === (_a = child.context) || void 0 === _a ? void 0 : _a.data, child, {});
80
+ }))), isTimeline && params.sort && (filteredChildren = null != filteredChildren ? filteredChildren : this._target.getChildren(),
81
+ filteredChildren.sort(((a, b) => {
82
+ var _a, _b;
83
+ return params.sort(null === (_a = a.context) || void 0 === _a ? void 0 : _a.data, null === (_b = b.context) || void 0 === _b ? void 0 : _b.data, a, b, {});
84
+ })));
85
+ const parsedParams = this.parseParams(params), cb = isTimeline ? (child, index, count) => {
86
+ const animate = this.executeTimelineItem(parsedParams, child, index, count);
87
+ animate && this._trackAnimation(animate);
88
+ } : (child, index, count) => {
89
+ const animate = this.executeTypeConfigItem(parsedParams, child, index, count);
90
+ animate && this._trackAnimation(animate);
91
+ };
92
+ filteredChildren ? filteredChildren.forEach(((child, index) => cb(child, index, filteredChildren.length))) : this._target.count <= 1 ? cb(this._target, 0, 1) : this._target.forEachChildren(((child, index) => cb(child, index, this._target.count - 1)));
93
+ }
94
+ executeTypeConfigItem(params, graphic, index, count) {
95
+ var _a, _b, _c, _d, _e, _f;
96
+ const {type: type, channel: channel, customParameters: customParameters, easing: easing = "linear", delay: delay = 0, delayAfter: delayAfter = 0, duration: duration = 300, startTime: startTime = 0, oneByOneDelay: oneByOneDelay = 0, loop: loop, bounce: bounce, priority: priority = 0, options: options, controlOptions: controlOptions} = params, custom = null !== (_a = params.custom) && void 0 !== _a ? _a : AnimateExecutor.builtInAnimateMap[type], animate = graphic.animate();
97
+ animate.priority = priority;
98
+ const delayValue = delay, datum = null === (_c = null === (_b = graphic.context) || void 0 === _b ? void 0 : _b.data) || void 0 === _c ? void 0 : _c[0], indexKey = null === (_d = graphic.context) || void 0 === _d ? void 0 : _d.indexKey;
99
+ datum && indexKey && (index = null !== (_e = datum[indexKey]) && void 0 !== _e ? _e : index),
100
+ animate.startAt(startTime), animate.wait(index * oneByOneDelay), delayValue > 0 && animate.wait(delayValue);
101
+ const props = null !== (_f = params.to) && void 0 !== _f ? _f : this.createPropsFromChannel(channel, graphic);
102
+ return this._handleRunAnimate(animate, custom, props, duration, easing, customParameters, options, type, graphic),
103
+ oneByOneDelay && animate.wait(oneByOneDelay * (count - index - 1)), delayAfter > 0 && animate.wait(delayAfter),
104
+ loop && loop > 0 && animate.loop(loop), bounce && animate.bounce(!0), animate;
105
+ }
106
+ _handleRunAnimate(animate, custom, props, duration, easing, customParameters, options, type, graphic) {
107
+ if (custom) {
108
+ const customParams = this.resolveValue(customParameters, graphic, {}), objOptions = (0,
109
+ vutils_1.isFunction)(options) ? options.call(null, customParameters.data && customParameters.data[0], graphic, customParameters) : options;
110
+ customParams.options = objOptions, (0, vutils_1.isFunction)(custom) && (/^class\s/.test(Function.prototype.toString.call(custom)) ? this.createCustomAnimation(animate, custom, props, duration, easing, customParams) : this.createCustomInterpolatorAnimation(animate, custom, props, duration, easing, customParams));
111
+ } else "to" === type ? animate.to(props, duration, easing) : "from" === type && animate.from(props, duration, easing);
112
+ }
113
+ executeTimelineItem(params, graphic, index, count) {
114
+ var _a, _b, _c, _d;
115
+ const {timeSlices: timeSlices, startTime: startTime = 0, loop: loop, bounce: bounce, oneByOneDelay: oneByOneDelay, priority: priority, controlOptions: controlOptions} = params, datum = null === (_b = null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b[0], indexKey = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.indexKey;
116
+ datum && indexKey && (index = null !== (_d = datum[indexKey]) && void 0 !== _d ? _d : index);
117
+ const animate = graphic.animate();
118
+ animate.priority = priority, animate.startAt(startTime), animate.wait(index * oneByOneDelay),
119
+ loop && loop > 0 && animate.loop(loop), bounce && animate.bounce(!0);
120
+ return (Array.isArray(timeSlices) ? timeSlices : [ timeSlices ]).forEach((slice => {
121
+ this.applyTimeSliceToAnimate(slice, animate, graphic);
122
+ })), oneByOneDelay && animate.wait(oneByOneDelay * (count - index - 1)), animate;
123
+ }
124
+ applyTimeSliceToAnimate(slice, animate, graphic) {
125
+ const {effects: effects, duration: duration = 300, delay: delay = 0, delayAfter: delayAfter = 0} = slice, delayValue = delay, delayAfterValue = delayAfter;
126
+ delayValue > 0 && animate.wait(delayValue);
127
+ (Array.isArray(effects) ? effects : [ effects ]).forEach((effect => {
128
+ var _a;
129
+ const {type: type = "to", channel: channel, customParameters: customParameters, easing: easing = "linear", options: options} = effect, custom = null !== (_a = effect.custom) && void 0 !== _a ? _a : AnimateExecutor.builtInAnimateMap[type], props = this.createPropsFromChannel(channel, graphic);
130
+ this._handleRunAnimate(animate, custom, props, duration, easing, customParameters, options, type, graphic);
131
+ })), delayAfterValue > 0 && animate.wait(delayAfterValue);
132
+ }
133
+ createCustomInterpolatorAnimation(animate, interpolator, props, duration, easing, customParams) {
134
+ const from = {}, to = props;
135
+ Object.keys(to).forEach((key => {
136
+ from[key] = animate.target.getComputedAttribute(key);
137
+ })), animate.interpolateUpdateFunction = (from, to, ratio, step, target) => {
138
+ interpolator(ratio, from, to, step, target, animate.target, customParams);
139
+ }, animate.to(props, duration, easing);
140
+ }
141
+ createCustomAnimation(animate, CustomAnimateConstructor, props, duration, easing, customParams) {
142
+ const from = {}, to = props;
143
+ Object.keys(to).forEach((key => {
144
+ from[key] = animate.target.getComputedAttribute(key);
145
+ }));
146
+ const customAnimate = new CustomAnimateConstructor(from, to, duration, easing, customParams);
147
+ animate.play(customAnimate);
148
+ }
149
+ createPropsFromChannel(channel, graphic) {
150
+ const props = {};
151
+ return channel ? (Array.isArray(channel) || Object.entries(channel).forEach((([key, config]) => {
152
+ var _a;
153
+ void 0 !== config.to && ("function" == typeof config.to ? props[key] = config.to(null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.data, graphic, {}) : props[key] = config.to);
154
+ })), props) : props;
155
+ }
156
+ resolveValue(value, graphic, defaultValue) {
157
+ var _a;
158
+ return void 0 === value ? defaultValue : "function" == typeof value && graphic ? value(null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.data, graphic, {}) : value;
159
+ }
160
+ executeItem(params, graphic, index = 0, count = 1) {
161
+ if (!graphic) return null;
162
+ let animate = null;
163
+ return animate = "timeSlices" in params ? this.executeTimelineItem(params, graphic, index, count) : this.executeTypeConfigItem(params, graphic, index, count),
164
+ animate && this._trackAnimation(animate), animate;
165
+ }
166
+ stop(type) {
167
+ for (;this._animates.length > 0; ) {
168
+ const animate = this._animates.pop();
169
+ null == animate || animate.stop(type);
170
+ }
171
+ this._animates = [], this._activeCount = 0, this._started && (this._started = !1,
172
+ this.onEnd());
173
+ }
174
+ }
175
+
176
+ exports.AnimateExecutor = AnimateExecutor, AnimateExecutor.builtInAnimateMap = {};
177
+ //# sourceMappingURL=animate-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/executor/animate-executor.ts"],"names":[],"mappings":";;;AAeA,6CAAyE;AASzE,MAAa,eAAe;IAG1B,MAAM,CAAC,sBAAsB,CAAC,IAAY,EAAE,OAAoC;QAC9E,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACpD,CAAC;IAkBD,YAAY,MAAgB;QAbpB,cAAS,GAAe,EAAE,CAAC;QAG3B,oBAAe,GAAmB,EAAE,CAAC;QAErC,kBAAa,GAAmB,EAAE,CAAC;QAGnC,aAAQ,GAAY,KAAK,CAAC;QAG1B,iBAAY,GAAW,CAAC,CAAC;QAG/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAKD,OAAO,CAAC,EAAe;QACrB,IAAI,EAAE,EAAE;YACN,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAG9B,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,YA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E,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SAC7F;QAGD,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;SAC/B;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAKD,IAAI,CAAC,IAA4C;QAE/C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YAChC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;YACrC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;QAGD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QAGtB,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACtB,IAAI,CAAC,KAAK,EAAE,CAAC;SACd;IACH,CAAC;;AA9kBH,0CA+kBC;AA9kBQ,iCAAiB,GAAgD,EAAE,CAAC","file":"animate-executor.js","sourcesContent":["import type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport type {\n IAnimationConfig,\n IAnimationTimeline,\n IAnimationTypeConfig,\n MarkFunctionCallback,\n MarkFunctionValueType,\n IAnimationTimeSlice,\n IAnimationChannelAttrs,\n IAnimationChannelAttributes,\n IAnimationCustomConstructor,\n IAnimationChannelInterpolator\n} from './executor';\nimport type { EasingType } from '../intreface/easing';\nimport type { IAnimate } from '../intreface/animate';\nimport { cloneDeep, isArray, isFunction, scale } from '@visactor/vutils';\n\ninterface IAnimateExecutor {\n execute: (params: IAnimationConfig) => void;\n executeItem: (params: IAnimationConfig, graphic: IGraphic, index?: number) => IAnimate | null;\n onStart: (cb?: () => void) => void;\n onEnd: (cb?: () => void) => void;\n}\n\nexport class AnimateExecutor implements IAnimateExecutor {\n static builtInAnimateMap: Record<string, IAnimationCustomConstructor> = {};\n\n static registerBuiltInAnimate(name: string, animate: IAnimationCustomConstructor) {\n AnimateExecutor.builtInAnimateMap[name] = animate;\n }\n\n declare _target: IGraphic;\n\n // 所有动画实例\n private _animates: IAnimate[] = [];\n\n // 动画开始回调\n private _startCallbacks: (() => void)[] = [];\n // 动画结束回调\n private _endCallbacks: (() => void)[] = [];\n\n // 是否已经开始动画\n private _started: boolean = false;\n\n // 当前正在运行的动画数量\n private _activeCount: number = 0;\n\n constructor(target: IGraphic) {\n this._target = target;\n }\n\n /**\n * 注册一个回调,当动画开始时调用\n */\n onStart(cb?: () => void): void {\n if (cb) {\n this._startCallbacks.push(cb);\n\n // 如果动画已经开始,立即调用回调\n if (this._started && this._activeCount > 0) {\n cb();\n }\n } else {\n this._startCallbacks.forEach(cb => {\n cb();\n });\n }\n }\n\n /**\n * 注册一个回调,当所有动画结束时调用\n */\n onEnd(cb?: () => void): void {\n if (cb) {\n this._endCallbacks.push(cb);\n } else {\n this._endCallbacks.forEach(cb => {\n cb();\n });\n }\n }\n\n /**\n * 跟踪动画并附加生命周期钩子\n */\n private _trackAnimation(animate: IAnimate): void {\n this._animates.push(animate);\n this._activeCount++;\n\n // 如果这是第一个正在运行的动画,触发onStart回调\n if (this._activeCount === 1 && !this._started) {\n this._started = true;\n this.onStart();\n }\n\n // 处理动画完成\n animate.onEnd(() => {\n this._activeCount--;\n\n // 从跟踪的动画中移除\n const index = this._animates.indexOf(animate);\n if (index >= 0) {\n this._animates.splice(index, 1);\n }\n\n // 如果所有动画都已完成,触发onEnd回调\n if (this._activeCount === 0 && this._started) {\n this._started = false;\n this.onEnd();\n }\n });\n }\n\n parseParams(params: IAnimationConfig): IAnimationConfig {\n const isTimeline = 'timeSlices' in params;\n\n const totalTime = this.resolveValue(params.totalTime, undefined, undefined);\n const startTime = this.resolveValue(params.startTime, undefined, 0);\n\n // execute只在mark层面调用,所以性能影响可以忽略\n // TODO 如果后续调用频繁,需要重新修改\n const parsedParams = cloneDeep(params);\n parsedParams.oneByOneDelay = 0;\n parsedParams.startTime = startTime;\n parsedParams.totalTime = totalTime;\n\n const oneByOne = this.resolveValue(params.oneByOne, undefined, false);\n\n if (isTimeline) {\n const timeSlices = (parsedParams as IAnimationTimeline).timeSlices;\n if (!isArray(timeSlices)) {\n (parsedParams as IAnimationTimeline).timeSlices = [timeSlices];\n }\n let sliceTime = 0;\n ((parsedParams as IAnimationTimeline).timeSlices as IAnimationTimeSlice[]).forEach(slice => {\n slice.delay = this.resolveValue(slice.delay, undefined, 0);\n slice.delayAfter = this.resolveValue(slice.delayAfter, undefined, 0);\n slice.duration = this.resolveValue(slice.duration, undefined, 300);\n sliceTime += slice.delay + slice.duration + slice.delayAfter;\n });\n let oneByOneDelay = 0;\n let oneByOneTime = 0;\n if (oneByOne) {\n oneByOneTime = Number(oneByOne);\n oneByOneDelay = oneByOneTime;\n }\n parsedParams.oneByOne = oneByOneTime;\n parsedParams.oneByOneDelay = oneByOneDelay;\n\n if (totalTime) {\n const _totalTime = sliceTime + oneByOneDelay * (this._target.count - 2);\n const scale = totalTime ? totalTime / _totalTime : 1;\n ((parsedParams as IAnimationTimeline).timeSlices as IAnimationTimeSlice[]).forEach(slice => {\n slice.delay = (slice.delay as number) * scale;\n slice.delayAfter = (slice.delayAfter as number) * scale;\n slice.duration = (slice.duration as number) * scale;\n });\n parsedParams.oneByOne = oneByOneTime * scale;\n parsedParams.oneByOneDelay = oneByOneDelay * scale;\n (parsedParams as IAnimationTimeline).startTime = startTime * scale;\n }\n } else {\n const delay = this.resolveValue(params.delay, undefined, 0);\n const delayAfter = this.resolveValue(params.delayAfter, undefined, 0);\n const duration = this.resolveValue(params.duration, undefined, 300);\n\n let oneByOneDelay = 0;\n let oneByOneTime = 0;\n if (oneByOne) {\n oneByOneTime = Number(oneByOne);\n oneByOneDelay = duration + oneByOneTime;\n }\n parsedParams.oneByOne = oneByOneTime;\n parsedParams.oneByOneDelay = oneByOneDelay;\n\n if (totalTime) {\n const _totalTime = delay + delayAfter + duration + oneByOneDelay * (this._target.count - 2);\n const scale = totalTime ? totalTime / _totalTime : 1;\n parsedParams.delay = delay * scale;\n parsedParams.delayAfter = delayAfter * scale;\n parsedParams.duration = duration * scale;\n parsedParams.oneByOne = oneByOneTime * scale;\n parsedParams.oneByOneDelay = oneByOneDelay * scale;\n (parsedParams as IAnimationTypeConfig).startTime = startTime;\n }\n }\n\n return parsedParams;\n }\n\n /**\n * 执行动画,针对一组元素\n */\n execute(params: IAnimationConfig) {\n // 判断是否为timeline配置\n const isTimeline = 'timeSlices' in params;\n\n // 筛选符合条件的子图元\n let filteredChildren: IGraphic[];\n\n // 如果设置了partitioner,则进行筛选\n if (isTimeline && params.partitioner) {\n filteredChildren = (filteredChildren ?? (this._target.getChildren() as IGraphic[])).filter(child => {\n return (params as IAnimationTimeline).partitioner((child.context as any)?.data, child, {});\n });\n }\n\n // 如果需要排序,则进行排序\n if (isTimeline && (params as IAnimationTimeline).sort) {\n filteredChildren = filteredChildren ?? (this._target.getChildren() as IGraphic[]);\n filteredChildren.sort((a, b) => {\n return (params as IAnimationTimeline).sort((a.context as any)?.data, (b.context as any)?.data, a, b, {});\n });\n }\n\n const parsedParams = this.parseParams(params);\n\n const cb = isTimeline\n ? (child: IGraphic, index: number, count: number) => {\n // 执行单个图元的timeline动画\n const animate = this.executeTimelineItem(parsedParams as IAnimationTimeline, child, index, count);\n if (animate) {\n this._trackAnimation(animate);\n }\n }\n : (child: IGraphic, index: number, count: number) => {\n // 执行单个图元的config动画\n const animate = this.executeTypeConfigItem(parsedParams as IAnimationTypeConfig, child, index, count);\n if (animate) {\n this._trackAnimation(animate);\n }\n };\n\n // 执行每个图元的动画\n if (filteredChildren) {\n filteredChildren.forEach((child, index) => cb(child, index, filteredChildren.length));\n } else if (this._target.count <= 1) {\n cb(this._target, 0, 1);\n } else {\n this._target.forEachChildren((child, index) => cb(child as IGraphic, index, this._target.count - 1));\n }\n\n return;\n }\n\n /**\n * 执行 TypeConfig 类型的动画\n */\n private executeTypeConfigItem(\n params: IAnimationTypeConfig,\n graphic: IGraphic,\n index: number,\n count: number\n ): IAnimate {\n const {\n type,\n channel,\n customParameters,\n easing = 'linear',\n delay = 0,\n delayAfter = 0,\n duration = 300,\n startTime = 0,\n oneByOneDelay = 0,\n loop,\n bounce,\n priority = 0,\n options,\n controlOptions\n } = params as any;\n const custom = params.custom ?? AnimateExecutor.builtInAnimateMap[type];\n\n // 创建动画实例\n const animate = graphic.animate() as unknown as IAnimate;\n animate.priority = priority;\n\n const delayValue = delay as number;\n\n // 如果设置了indexKey,则使用indexKey作为index\n const datum = graphic.context?.data?.[0];\n const indexKey = graphic.context?.indexKey;\n if (datum && indexKey) {\n index = datum[indexKey] ?? index;\n }\n\n // 设置开始时间\n animate.startAt(startTime as number);\n animate.wait(index * oneByOneDelay);\n\n // 添加延迟\n if (delayValue > 0) {\n animate.wait(delayValue);\n }\n\n // 根据 channel 配置创建属性对象\n const props = params.to ?? this.createPropsFromChannel(channel, graphic);\n\n this._handleRunAnimate(\n animate,\n custom,\n props,\n duration as number,\n easing,\n customParameters,\n options,\n type,\n graphic\n );\n\n if (oneByOneDelay) {\n animate.wait(oneByOneDelay * (count - index - 1));\n }\n\n // 添加后延迟\n if ((delayAfter as number) > 0) {\n animate.wait(delayAfter as number);\n }\n\n // 设置循环\n if (loop && (loop as number) > 0) {\n animate.loop(loop as number);\n }\n\n // 设置反弹\n if (bounce) {\n animate.bounce(true);\n }\n\n return animate;\n }\n\n private _handleRunAnimate(\n animate: IAnimate,\n custom: IAnimationCustomConstructor | IAnimationChannelInterpolator,\n props: Record<string, any>,\n duration: number,\n easing: EasingType,\n customParameters: any,\n options: any,\n type: string,\n graphic: IGraphic\n ) {\n // 处理自定义动画\n if (custom) {\n const customParams = this.resolveValue(customParameters, graphic, {});\n const objOptions = isFunction(options)\n ? options.call(null, customParameters.data && customParameters.data[0], graphic, customParameters)\n : options;\n customParams.options = objOptions;\n if (isFunction(custom)) {\n if (/^class\\s/.test(Function.prototype.toString.call(custom))) {\n // 自定义动画构造器 - 创建自定义动画类\n this.createCustomAnimation(\n animate,\n custom as IAnimationCustomConstructor,\n props,\n duration as number,\n easing,\n customParams\n );\n } else {\n // 自定义插值器 - 创建自定义插值动画\n this.createCustomInterpolatorAnimation(\n animate,\n custom as IAnimationChannelInterpolator,\n props,\n duration as number,\n easing,\n customParams\n );\n }\n }\n } else if (type === 'to') {\n animate.to(props, duration as number, easing);\n } else if (type === 'from') {\n animate.from(props, duration as number, easing);\n }\n }\n\n /**\n * 执行 Timeline 类型的动画\n */\n private executeTimelineItem(params: IAnimationTimeline, graphic: IGraphic, index: number, count: number): IAnimate {\n const { timeSlices, startTime = 0, loop, bounce, oneByOneDelay, priority, controlOptions } = params as any;\n\n // 如果设置了indexKey,则使用indexKey作为index\n const datum = graphic.context?.data?.[0];\n const indexKey = graphic.context?.indexKey;\n if (datum && indexKey) {\n index = datum[indexKey] ?? index;\n }\n\n // 创建动画实例\n const animate = graphic.animate() as unknown as IAnimate;\n animate.priority = priority;\n\n // 设置开始时间\n animate.startAt(startTime as number);\n animate.wait(index * oneByOneDelay);\n\n // 设置循环\n if (loop && (loop as number) > 0) {\n animate.loop(loop as number);\n }\n\n // 设置反弹\n if (bounce) {\n animate.bounce(true);\n }\n\n // 处理时间切片\n const slices = Array.isArray(timeSlices) ? timeSlices : [timeSlices];\n\n slices.forEach(slice => {\n this.applyTimeSliceToAnimate(slice, animate, graphic);\n });\n\n // 后等待\n if (oneByOneDelay) {\n animate.wait(oneByOneDelay * (count - index - 1));\n }\n\n return animate;\n }\n\n /**\n * 将时间切片应用到动画实例\n */\n private applyTimeSliceToAnimate(slice: IAnimationTimeSlice, animate: IAnimate, graphic: IGraphic) {\n const { effects, duration = 300, delay = 0, delayAfter = 0 } = slice;\n\n // 解析时间参数\n // const durationValue = duration as number;\n const delayValue = delay as number;\n const delayAfterValue = delayAfter as number;\n\n // 添加延迟\n if (delayValue > 0) {\n animate.wait(delayValue);\n }\n\n // 处理动画效果\n const effectsArray = Array.isArray(effects) ? effects : [effects];\n\n effectsArray.forEach(effect => {\n const { type = 'to', channel, customParameters, easing = 'linear', options } = effect;\n\n const custom = effect.custom ?? AnimateExecutor.builtInAnimateMap[type];\n\n // 根据 channel 配置创建属性对象\n const props = this.createPropsFromChannel(channel, graphic);\n this._handleRunAnimate(\n animate,\n custom,\n props,\n duration as number,\n easing,\n customParameters,\n options,\n type,\n graphic\n );\n });\n\n // 添加后延迟\n if (delayAfterValue > 0) {\n animate.wait(delayAfterValue);\n }\n }\n\n /**\n * 创建自定义插值器动画\n */\n private createCustomInterpolatorAnimation(\n animate: IAnimate,\n interpolator: IAnimationChannelInterpolator,\n props: Record<string, any>,\n duration: number,\n easing: EasingType,\n customParams: any\n ) {\n // 获取动画目标的当前属性作为起始值\n const from: Record<string, any> = {};\n const to = props;\n\n // 为每个属性填充起始值\n Object.keys(to).forEach(key => {\n from[key] = animate.target.getComputedAttribute(key);\n });\n\n animate.interpolateUpdateFunction = (from, to, ratio, step, target) => {\n interpolator(ratio, from, to, step, target, animate.target, customParams);\n };\n\n animate.to(props, duration, easing);\n }\n\n /**\n * 创建自定义动画类\n */\n private createCustomAnimation(\n animate: IAnimate,\n CustomAnimateConstructor: IAnimationCustomConstructor,\n props: Record<string, any>,\n duration: number,\n easing: EasingType,\n customParams: any\n ) {\n // 获取动画目标的当前属性作为起始值\n const from: Record<string, any> = {};\n const to = props;\n\n // 为每个属性填充起始值\n Object.keys(to).forEach(key => {\n from[key] = animate.target.getComputedAttribute(key);\n });\n\n // 实例化自定义动画类\n const customAnimate = new CustomAnimateConstructor(from, to, duration, easing, customParams);\n\n // 播放自定义动画\n animate.play(customAnimate);\n }\n\n /**\n * 从 channel 配置创建属性对象\n */\n private createPropsFromChannel(\n channel: IAnimationChannelAttrs | IAnimationChannelAttributes | undefined,\n graphic: IGraphic\n ): Record<string, any> {\n const props: Record<string, any> = {};\n\n if (!channel) {\n return props;\n }\n\n if (!Array.isArray(channel)) {\n // 如果是对象,解析 from/to 配置\n Object.entries(channel).forEach(([key, config]) => {\n if (config.to !== undefined) {\n if (typeof config.to === 'function') {\n props[key] = config.to((graphic.context as any)?.data, graphic, {});\n } else {\n props[key] = config.to;\n }\n }\n });\n }\n\n return props;\n }\n\n /**\n * 解析函数或值类型的配置项\n */\n private resolveValue<T>(value: MarkFunctionValueType<T> | undefined, graphic?: IGraphic, defaultValue?: T): T {\n if (value === undefined) {\n return defaultValue as T;\n }\n\n if (typeof value === 'function' && graphic) {\n return (value as MarkFunctionCallback<T>)((graphic.context as any)?.data, graphic, {});\n }\n\n return value as T;\n }\n\n /**\n * 执行动画(具体执行到内部的单个图元)\n */\n executeItem(params: IAnimationConfig, graphic: IGraphic, index: number = 0, count: number = 1): IAnimate | null {\n if (!graphic) {\n return null;\n }\n\n const isTimeline = 'timeSlices' in params;\n let animate: IAnimate | null = null;\n\n if (isTimeline) {\n // 处理 Timeline 类型的动画配置\n animate = this.executeTimelineItem(params as IAnimationTimeline, graphic, index, count);\n } else {\n // 处理 TypeConfig 类型的动画配置\n animate = this.executeTypeConfigItem(params as IAnimationTypeConfig, graphic, index, count);\n }\n\n // 跟踪动画以进行生命周期管理\n if (animate) {\n this._trackAnimation(animate);\n }\n\n return animate;\n }\n\n /**\n * 停止所有由该执行器管理的动画\n */\n stop(type?: 'start' | 'end' | Record<string, any>): void {\n // animate.stop会从数组里删除,所以需要while循环,不能forEach\n while (this._animates.length > 0) {\n const animate = this._animates.pop();\n animate?.stop(type);\n }\n\n // 清空动画实例数组\n this._animates = [];\n this._activeCount = 0;\n\n // 如果动画正在运行,触发结束回调\n if (this._started) {\n this._started = false;\n this.onEnd();\n }\n }\n}\n"]}
@@ -0,0 +1,69 @@
1
+ import type { IGraphic } from '@visactor/vrender-core';
2
+ import type { EasingType } from '../intreface/easing';
3
+ import type { ACustomAnimate } from '../custom/custom-animate';
4
+ export type MarkFunctionCallback<T> = (datum: any, graphic: IGraphic, parameters: any) => T;
5
+ export type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;
6
+ interface IAnimationParameters {
7
+ [key: string]: any;
8
+ }
9
+ export type IAnimationChannelFunction = (datum: any, element: IGraphic, parameters: IAnimationParameters) => any;
10
+ export type IAnimationChannelAttrs = Record<string, {
11
+ from?: any | IAnimationChannelFunction;
12
+ to?: any | IAnimationChannelFunction;
13
+ }>;
14
+ export type IAnimationChannelAttributes = string[];
15
+ export type IAnimationChannelInterpolator = (ratio: number, from: any, to: any, nextAttributes: any, datum: any, element: IGraphic, parameters: IAnimationParameters) => boolean | void;
16
+ export interface IAnimationCustomConstructor {
17
+ new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;
18
+ }
19
+ export interface IAnimationEffect {
20
+ type?: string;
21
+ channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
22
+ custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
23
+ customParameters?: MarkFunctionValueType<any>;
24
+ easing?: EasingType;
25
+ options?: MarkFunctionValueType<any>;
26
+ }
27
+ export interface IAnimationTimeSlice {
28
+ effects: IAnimationEffect | IAnimationEffect[];
29
+ duration?: MarkFunctionValueType<number>;
30
+ delay?: MarkFunctionValueType<number>;
31
+ delayAfter?: MarkFunctionValueType<number>;
32
+ }
33
+ export interface IAnimationControlOptions {
34
+ stopWhenStateChange?: boolean;
35
+ immediatelyApply?: boolean;
36
+ ignoreLoopFinalAttributes?: boolean;
37
+ }
38
+ export interface IAnimationTypeConfig {
39
+ type?: string;
40
+ channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
41
+ to?: Record<string, any>;
42
+ custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
43
+ customParameters?: MarkFunctionValueType<any>;
44
+ easing?: EasingType;
45
+ delay?: MarkFunctionValueType<number>;
46
+ delayAfter?: MarkFunctionValueType<number>;
47
+ duration?: MarkFunctionValueType<number>;
48
+ oneByOne?: MarkFunctionValueType<boolean | number>;
49
+ startTime?: MarkFunctionValueType<number>;
50
+ totalTime?: MarkFunctionValueType<number>;
51
+ loop?: boolean | number;
52
+ options?: MarkFunctionValueType<any>;
53
+ controlOptions?: IAnimationControlOptions;
54
+ priority?: number;
55
+ }
56
+ export interface IAnimationTimeline {
57
+ id?: string;
58
+ timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];
59
+ startTime?: MarkFunctionValueType<number>;
60
+ totalTime?: MarkFunctionValueType<number>;
61
+ oneByOne?: MarkFunctionValueType<number | boolean>;
62
+ loop?: MarkFunctionValueType<number | boolean>;
63
+ partitioner?: MarkFunctionCallback<boolean>;
64
+ sort?: (datumA: any, datumB: any, elementA: IGraphic, elementB: IGraphic, parameters: any) => number;
65
+ controlOptions?: IAnimationControlOptions;
66
+ priority?: number;
67
+ }
68
+ export type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;
69
+ export {};
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ });
6
+ //# sourceMappingURL=executor.js.map