@visactor/vrender-animate 0.23.0-alpha.2 → 1.0.0-alpha.1

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 (283) hide show
  1. package/cjs/animate-extension.d.ts +11 -5
  2. package/cjs/animate-extension.js +20 -12
  3. package/cjs/animate-extension.js.map +1 -1
  4. package/cjs/animate.d.ts +1 -5
  5. package/cjs/animate.js +17 -15
  6. package/cjs/animate.js.map +1 -1
  7. package/cjs/component/component-animate-extension.d.ts +1 -0
  8. package/cjs/component/component-animate-extension.js +1 -0
  9. package/cjs/component/component-animate-extension.js.map +1 -0
  10. package/cjs/component/component-animator.d.ts +22 -0
  11. package/cjs/component/component-animator.js +67 -0
  12. package/cjs/component/component-animator.js.map +1 -0
  13. package/cjs/component/index.d.ts +1 -0
  14. package/cjs/component/index.js +21 -0
  15. package/cjs/component/index.js.map +1 -0
  16. package/cjs/custom/clip-graphic.d.ts +1 -1
  17. package/cjs/custom/clip-graphic.js.map +1 -1
  18. package/cjs/custom/clip.d.ts +1 -1
  19. package/cjs/custom/clip.js.map +1 -1
  20. package/cjs/custom/common.d.ts +1 -2
  21. package/cjs/custom/common.js +17 -12
  22. package/cjs/custom/common.js.map +1 -1
  23. package/cjs/custom/custom-animate.d.ts +7 -3
  24. package/cjs/custom/custom-animate.js +12 -1
  25. package/cjs/custom/custom-animate.js.map +1 -1
  26. package/cjs/custom/fade.d.ts +1 -1
  27. package/cjs/custom/fade.js.map +1 -1
  28. package/cjs/custom/from-to.d.ts +9 -0
  29. package/cjs/custom/from-to.js +38 -0
  30. package/cjs/custom/from-to.js.map +1 -0
  31. package/cjs/custom/group-fade.d.ts +8 -14
  32. package/cjs/custom/group-fade.js +7 -49
  33. package/cjs/custom/group-fade.js.map +1 -1
  34. package/cjs/custom/growAngle.d.ts +10 -5
  35. package/cjs/custom/growAngle.js +34 -16
  36. package/cjs/custom/growAngle.js.map +1 -1
  37. package/cjs/custom/growCenter.d.ts +1 -2
  38. package/cjs/custom/growCenter.js +14 -10
  39. package/cjs/custom/growCenter.js.map +1 -1
  40. package/cjs/custom/growHeight.d.ts +1 -3
  41. package/cjs/custom/growHeight.js +13 -9
  42. package/cjs/custom/growHeight.js.map +1 -1
  43. package/cjs/custom/growPoints.d.ts +1 -2
  44. package/cjs/custom/growPoints.js +24 -20
  45. package/cjs/custom/growPoints.js.map +1 -1
  46. package/cjs/custom/growRadius.d.ts +4 -5
  47. package/cjs/custom/growRadius.js +22 -19
  48. package/cjs/custom/growRadius.js.map +1 -1
  49. package/cjs/custom/growWidth.d.ts +1 -3
  50. package/cjs/custom/growWidth.js +13 -9
  51. package/cjs/custom/growWidth.js.map +1 -1
  52. package/cjs/custom/input-text.d.ts +1 -2
  53. package/cjs/custom/input-text.js.map +1 -1
  54. package/cjs/custom/label-item-animate.d.ts +7 -0
  55. package/cjs/custom/label-item-animate.js +219 -0
  56. package/cjs/custom/label-item-animate.js.map +1 -0
  57. package/cjs/custom/move.d.ts +92 -0
  58. package/cjs/custom/move.js +131 -0
  59. package/cjs/custom/move.js.map +1 -0
  60. package/cjs/custom/number.d.ts +1 -2
  61. package/cjs/custom/number.js.map +1 -1
  62. package/cjs/custom/poptip-animate.d.ts +7 -0
  63. package/cjs/custom/poptip-animate.js +107 -0
  64. package/cjs/custom/poptip-animate.js.map +1 -0
  65. package/cjs/custom/register.js +27 -2
  66. package/cjs/custom/register.js.map +1 -1
  67. package/cjs/custom/richtext/input-richtext.d.ts +33 -0
  68. package/cjs/custom/richtext/input-richtext.js +70 -0
  69. package/cjs/custom/richtext/input-richtext.js.map +1 -0
  70. package/cjs/custom/richtext/output-richtext.d.ts +37 -0
  71. package/cjs/custom/richtext/output-richtext.js +94 -0
  72. package/cjs/custom/richtext/output-richtext.js.map +1 -0
  73. package/cjs/custom/richtext/slide-out-richtext.d.ts +38 -0
  74. package/cjs/custom/richtext/slide-out-richtext.js +146 -0
  75. package/cjs/custom/richtext/slide-out-richtext.js.map +1 -0
  76. package/cjs/custom/richtext/slide-richtext.d.ts +36 -0
  77. package/cjs/custom/richtext/slide-richtext.js +144 -0
  78. package/cjs/custom/richtext/slide-richtext.js.map +1 -0
  79. package/cjs/custom/rotate.d.ts +33 -0
  80. package/cjs/custom/rotate.js +76 -0
  81. package/cjs/custom/rotate.js.map +1 -0
  82. package/cjs/custom/scale.d.ts +6 -2
  83. package/cjs/custom/scale.js +27 -14
  84. package/cjs/custom/scale.js.map +1 -1
  85. package/cjs/custom/sphere.js +1 -2
  86. package/cjs/custom/state.d.ts +1 -1
  87. package/cjs/custom/state.js.map +1 -1
  88. package/cjs/custom/story.d.ts +128 -0
  89. package/cjs/custom/story.js +347 -0
  90. package/cjs/custom/story.js.map +1 -0
  91. package/cjs/custom/tag-points.d.ts +2 -3
  92. package/cjs/custom/tag-points.js +16 -4
  93. package/cjs/custom/tag-points.js.map +1 -1
  94. package/cjs/custom/update.d.ts +2 -2
  95. package/cjs/custom/update.js +10 -2
  96. package/cjs/custom/update.js.map +1 -1
  97. package/cjs/executor/animate-executor.d.ts +7 -6
  98. package/cjs/executor/animate-executor.js +82 -38
  99. package/cjs/executor/animate-executor.js.map +1 -1
  100. package/cjs/executor/executor.d.ts +9 -3
  101. package/cjs/executor/executor.js.map +1 -1
  102. package/cjs/index.d.ts +5 -6
  103. package/cjs/index.js +17 -5
  104. package/cjs/index.js.map +1 -1
  105. package/cjs/interpolate/store.d.ts +4 -2
  106. package/cjs/interpolate/store.js +7 -2
  107. package/cjs/interpolate/store.js.map +1 -1
  108. package/cjs/register.js +1 -5
  109. package/cjs/register.js.map +1 -1
  110. package/cjs/state/animation-state.d.ts +20 -2
  111. package/cjs/state/animation-state.js +48 -4
  112. package/cjs/state/animation-state.js.map +1 -1
  113. package/cjs/state/graphic-extension.d.ts +7 -1
  114. package/cjs/state/graphic-extension.js +20 -0
  115. package/cjs/state/graphic-extension.js.map +1 -1
  116. package/cjs/step.d.ts +3 -4
  117. package/cjs/step.js +15 -9
  118. package/cjs/step.js.map +1 -1
  119. package/cjs/ticker/default-ticker.d.ts +10 -6
  120. package/cjs/ticker/default-ticker.js +33 -31
  121. package/cjs/ticker/default-ticker.js.map +1 -1
  122. package/cjs/ticker/manual-ticker.d.ts +1 -1
  123. package/cjs/ticker/manual-ticker.js.map +1 -1
  124. package/cjs/timeline.d.ts +1 -2
  125. package/cjs/timeline.js.map +1 -1
  126. package/dist/index.es.js +2422 -448
  127. package/es/animate-extension.d.ts +11 -5
  128. package/es/animate-extension.js +21 -11
  129. package/es/animate-extension.js.map +1 -1
  130. package/es/animate.d.ts +1 -5
  131. package/es/animate.js +6 -6
  132. package/es/animate.js.map +1 -1
  133. package/es/component/component-animate-extension.d.ts +1 -0
  134. package/es/component/component-animate-extension.js +1 -0
  135. package/es/component/component-animate-extension.js.map +1 -0
  136. package/es/component/component-animator.d.ts +22 -0
  137. package/es/component/component-animator.js +59 -0
  138. package/es/component/component-animator.js.map +1 -0
  139. package/es/component/index.d.ts +1 -0
  140. package/es/component/index.js +2 -0
  141. package/es/component/index.js.map +1 -0
  142. package/es/custom/clip-graphic.d.ts +1 -1
  143. package/es/custom/clip-graphic.js.map +1 -1
  144. package/es/custom/clip.d.ts +1 -1
  145. package/es/custom/clip.js.map +1 -1
  146. package/es/custom/common.d.ts +1 -2
  147. package/es/custom/common.js +17 -12
  148. package/es/custom/common.js.map +1 -1
  149. package/es/custom/custom-animate.d.ts +7 -3
  150. package/es/custom/custom-animate.js +9 -0
  151. package/es/custom/custom-animate.js.map +1 -1
  152. package/es/custom/fade.d.ts +1 -1
  153. package/es/custom/fade.js.map +1 -1
  154. package/es/custom/from-to.d.ts +9 -0
  155. package/es/custom/from-to.js +30 -0
  156. package/es/custom/from-to.js.map +1 -0
  157. package/es/custom/group-fade.d.ts +8 -14
  158. package/es/custom/group-fade.js +7 -49
  159. package/es/custom/group-fade.js.map +1 -1
  160. package/es/custom/growAngle.d.ts +10 -5
  161. package/es/custom/growAngle.js +35 -14
  162. package/es/custom/growAngle.js.map +1 -1
  163. package/es/custom/growCenter.d.ts +1 -2
  164. package/es/custom/growCenter.js +14 -10
  165. package/es/custom/growCenter.js.map +1 -1
  166. package/es/custom/growHeight.d.ts +1 -3
  167. package/es/custom/growHeight.js +14 -10
  168. package/es/custom/growHeight.js.map +1 -1
  169. package/es/custom/growPoints.d.ts +1 -2
  170. package/es/custom/growPoints.js +23 -20
  171. package/es/custom/growPoints.js.map +1 -1
  172. package/es/custom/growRadius.d.ts +4 -5
  173. package/es/custom/growRadius.js +22 -17
  174. package/es/custom/growRadius.js.map +1 -1
  175. package/es/custom/growWidth.d.ts +1 -3
  176. package/es/custom/growWidth.js +14 -10
  177. package/es/custom/growWidth.js.map +1 -1
  178. package/es/custom/input-text.d.ts +1 -2
  179. package/es/custom/input-text.js.map +1 -1
  180. package/es/custom/label-item-animate.d.ts +7 -0
  181. package/es/custom/label-item-animate.js +213 -0
  182. package/es/custom/label-item-animate.js.map +1 -0
  183. package/es/custom/move.d.ts +92 -0
  184. package/es/custom/move.js +116 -0
  185. package/es/custom/move.js.map +1 -0
  186. package/es/custom/number.d.ts +1 -2
  187. package/es/custom/number.js.map +1 -1
  188. package/es/custom/poptip-animate.d.ts +7 -0
  189. package/es/custom/poptip-animate.js +101 -0
  190. package/es/custom/poptip-animate.js.map +1 -0
  191. package/es/custom/register.js +38 -1
  192. package/es/custom/register.js.map +1 -1
  193. package/es/custom/richtext/input-richtext.d.ts +33 -0
  194. package/es/custom/richtext/input-richtext.js +64 -0
  195. package/es/custom/richtext/input-richtext.js.map +1 -0
  196. package/es/custom/richtext/output-richtext.d.ts +37 -0
  197. package/es/custom/richtext/output-richtext.js +88 -0
  198. package/es/custom/richtext/output-richtext.js.map +1 -0
  199. package/es/custom/richtext/slide-out-richtext.d.ts +38 -0
  200. package/es/custom/richtext/slide-out-richtext.js +140 -0
  201. package/es/custom/richtext/slide-out-richtext.js.map +1 -0
  202. package/es/custom/richtext/slide-richtext.d.ts +36 -0
  203. package/es/custom/richtext/slide-richtext.js +138 -0
  204. package/es/custom/richtext/slide-richtext.js.map +1 -0
  205. package/es/custom/rotate.d.ts +33 -0
  206. package/es/custom/rotate.js +62 -0
  207. package/es/custom/rotate.js.map +1 -0
  208. package/es/custom/scale.d.ts +6 -2
  209. package/es/custom/scale.js +27 -14
  210. package/es/custom/scale.js.map +1 -1
  211. package/es/custom/sphere.js +1 -2
  212. package/es/custom/state.d.ts +1 -1
  213. package/es/custom/state.js.map +1 -1
  214. package/es/custom/story.d.ts +128 -0
  215. package/es/custom/story.js +323 -0
  216. package/es/custom/story.js.map +1 -0
  217. package/es/custom/tag-points.d.ts +2 -3
  218. package/es/custom/tag-points.js +17 -5
  219. package/es/custom/tag-points.js.map +1 -1
  220. package/es/custom/update.d.ts +2 -2
  221. package/es/custom/update.js +10 -2
  222. package/es/custom/update.js.map +1 -1
  223. package/es/executor/animate-executor.d.ts +7 -6
  224. package/es/executor/animate-executor.js +80 -38
  225. package/es/executor/animate-executor.js.map +1 -1
  226. package/es/executor/executor.d.ts +9 -3
  227. package/es/executor/executor.js.map +1 -1
  228. package/es/index.d.ts +5 -6
  229. package/es/index.js +6 -10
  230. package/es/index.js.map +1 -1
  231. package/es/interpolate/store.d.ts +4 -2
  232. package/es/interpolate/store.js +7 -3
  233. package/es/interpolate/store.js.map +1 -1
  234. package/es/register.js +0 -8
  235. package/es/register.js.map +1 -1
  236. package/es/state/animation-state.d.ts +20 -2
  237. package/es/state/animation-state.js +48 -2
  238. package/es/state/animation-state.js.map +1 -1
  239. package/es/state/graphic-extension.d.ts +7 -1
  240. package/es/state/graphic-extension.js +20 -0
  241. package/es/state/graphic-extension.js.map +1 -1
  242. package/es/step.d.ts +3 -4
  243. package/es/step.js +16 -10
  244. package/es/step.js.map +1 -1
  245. package/es/ticker/default-ticker.d.ts +10 -6
  246. package/es/ticker/default-ticker.js +25 -25
  247. package/es/ticker/default-ticker.js.map +1 -1
  248. package/es/ticker/manual-ticker.d.ts +1 -1
  249. package/es/ticker/manual-ticker.js.map +1 -1
  250. package/es/timeline.d.ts +1 -2
  251. package/es/timeline.js +1 -1
  252. package/es/timeline.js.map +1 -1
  253. package/package.json +5 -5
  254. package/cjs/intreface/animate.d.ts +0 -91
  255. package/cjs/intreface/animate.js +0 -10
  256. package/cjs/intreface/animate.js.map +0 -1
  257. package/cjs/intreface/easing.d.ts +0 -3
  258. package/cjs/intreface/easing.js +0 -6
  259. package/cjs/intreface/easing.js.map +0 -1
  260. package/cjs/intreface/ticker.d.ts +0 -37
  261. package/cjs/intreface/ticker.js +0 -10
  262. package/cjs/intreface/ticker.js.map +0 -1
  263. package/cjs/intreface/timeline.d.ts +0 -17
  264. package/cjs/intreface/timeline.js +0 -6
  265. package/cjs/intreface/timeline.js.map +0 -1
  266. package/cjs/intreface/type.d.ts +0 -13
  267. package/cjs/intreface/type.js +0 -15
  268. package/cjs/intreface/type.js.map +0 -1
  269. package/es/intreface/animate.d.ts +0 -91
  270. package/es/intreface/animate.js +0 -6
  271. package/es/intreface/animate.js.map +0 -1
  272. package/es/intreface/easing.d.ts +0 -3
  273. package/es/intreface/easing.js +0 -2
  274. package/es/intreface/easing.js.map +0 -1
  275. package/es/intreface/ticker.d.ts +0 -37
  276. package/es/intreface/ticker.js +0 -6
  277. package/es/intreface/ticker.js.map +0 -1
  278. package/es/intreface/timeline.d.ts +0 -17
  279. package/es/intreface/timeline.js +0 -2
  280. package/es/intreface/timeline.js.map +0 -1
  281. package/es/intreface/type.d.ts +0 -13
  282. package/es/intreface/type.js +0 -14
  283. package/es/intreface/type.js.map +0 -1
@@ -10,6 +10,8 @@ class InterpolateUpdateStore {
10
10
  constructor() {
11
11
  this.opacity = (key, from, to, ratio, step, target) => {
12
12
  target.attribute.opacity = (0, number_1.interpolateNumber)(from, to, ratio);
13
+ }, this.baseOpacity = (key, from, to, ratio, step, target) => {
14
+ target.attribute.baseOpacity = (0, number_1.interpolateNumber)(from, to, ratio);
13
15
  }, this.fillOpacity = (key, from, to, ratio, step, target) => {
14
16
  target.attribute.fillOpacity = (0, number_1.interpolateNumber)(from, to, ratio);
15
17
  }, this.strokeOpacity = (key, from, to, ratio, step, target) => {
@@ -27,11 +29,11 @@ class InterpolateUpdateStore {
27
29
  }, this.fill = (key, from, to, ratio, step, target) => {
28
30
  target.attribute.fill = (0, vrender_core_1.interpolateColor)(from, to, ratio, !1);
29
31
  }, this.fillPure = (key, from, to, ratio, step, target) => {
30
- target.attribute.fill = (0, vrender_core_1.interpolatePureColorArrayToStr)(step.fromParsedProps.fill, step.toParsedProps.fill, ratio);
32
+ target.attribute.fill = step.fromParsedProps.fill ? (0, vrender_core_1.interpolatePureColorArrayToStr)(step.fromParsedProps.fill, step.toParsedProps.fill, ratio) : step.toParsedProps.fill;
31
33
  }, this.stroke = (key, from, to, ratio, step, target) => {
32
34
  target.attribute.stroke = (0, vrender_core_1.interpolateColor)(from, to, ratio, !1);
33
35
  }, this.strokePure = (key, from, to, ratio, step, target) => {
34
- target.attribute.stroke = (0, vrender_core_1.interpolatePureColorArrayToStr)(step.fromParsedProps.stroke, step.toParsedProps.stroke, ratio);
36
+ target.attribute.stroke = step.fromParsedProps.stroke ? (0, vrender_core_1.interpolatePureColorArrayToStr)(step.fromParsedProps.stroke, step.toParsedProps.stroke, ratio) : step.toParsedProps.stroke;
35
37
  }, this.width = (key, from, to, ratio, step, target) => {
36
38
  target.attribute.width = (0, number_1.interpolateNumber)(from, to, ratio), target.addUpdateBoundTag();
37
39
  }, this.height = (key, from, to, ratio, step, target) => {
@@ -68,6 +70,9 @@ class InterpolateUpdateStore {
68
70
  target.addUpdateBoundTag();
69
71
  }, this.size = (key, from, to, ratio, step, target) => {
70
72
  target.attribute.size = (0, number_1.interpolateNumber)(from, to, ratio), target.addUpdateBoundTag();
73
+ }, this.points = (key, from, to, ratio, step, target) => {
74
+ target.attribute.points = (0, vrender_core_1.pointsInterpolation)(from, to, ratio),
75
+ target.addUpdateBoundTag();
71
76
  };
72
77
  }
73
78
  }
@@ -1 +1 @@
1
- {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AAK,IAAI,CAAC,MAAM,EAAE;QAChF,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAClC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBACzB,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM;aACP;YACD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACpB;QACD,IAAI,KAAK,EAAE;YACR,MAAM,CAAC,SAAiB,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;SAC3C;QACD,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAtBD,0DAsBC","file":"store.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport { interpolateColor, interpolatePureColorArrayToStr } from '@visactor/vrender-core';\nimport { interpolateNumber } from './number';\nimport type { IStep } from '../intreface/animate';\n\n// 直接设置,触发 隐藏类(Hidden Class)优化:\n/**\n *\nconst a = { type: 1 };\nconst ITERATIONS = 1e7; // 测试次数\n\n// 动态生成 keys 数组(确保引擎无法静态推断 key)\nconst keys = [];\nfor (let i = 0; i < ITERATIONS; i++) {\n // 通过条件确保 key 动态变化(但实际始终为 'type',避免属性缺失的开销)\n keys.push(Math.random() < 0 ? 'other' : 'type');\n}\n\n// 测试字面量访问\nfunction testLiteral() {\n let sum = 0;\n for (let i = 0; i < ITERATIONS; i++) {\n const key = keys[i]; // 读取 key(与动态测试完全一致)\n sum += a.type; // 差异仅在此处:使用字面量访问\n }\n return sum;\n}\n\n// 测试变量动态访问\nfunction testDynamic() {\n let sum = 0;\n for (let i = 0; i < ITERATIONS; i++) {\n const key = keys[i]; // 读取 key(与字面量测试完全一致)\n sum += a[key]; // 差异仅在此处:使用变量访问\n }\n return sum;\n}\n\n// 预热(避免 JIT 编译影响)\ntestLiteral();\ntestDynamic();\n\n// 正式测试\nconsole.time('literal');\ntestLiteral();\nconsole.timeEnd('literal');\n\nconsole.time('dynamic');\ntestDynamic();\nconsole.timeEnd('dynamic');\n\n\n// out:\n// literal: 7.1259765625 ms\n// dynamic: 9.322998046875 ms\n */\n\nexport class InterpolateUpdateStore {\n opacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.opacity = interpolateNumber(from, to, ratio);\n };\n fillOpacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.fillOpacity = interpolateNumber(from, to, ratio);\n };\n strokeOpacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.strokeOpacity = interpolateNumber(from, to, ratio);\n };\n zIndex = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.zIndex = interpolateNumber(from, to, ratio);\n };\n backgroundOpacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.backgroundOpacity = interpolateNumber(from, to, ratio);\n };\n shadowOffsetX = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.shadowOffsetX = interpolateNumber(from, to, ratio);\n };\n shadowOffsetY = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.shadowOffsetY = interpolateNumber(from, to, ratio);\n };\n shadowBlur = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.shadowBlur = interpolateNumber(from, to, ratio);\n };\n fill = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.fill = interpolateColor(from, to, ratio, false) as any;\n };\n fillPure = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.fill = interpolatePureColorArrayToStr(\n step.fromParsedProps.fill,\n step.toParsedProps.fill,\n ratio\n ) as any;\n };\n stroke = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.stroke = interpolateColor(from, to, ratio, false);\n };\n strokePure = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.stroke = interpolatePureColorArrayToStr(\n step.fromParsedProps.stroke,\n step.toParsedProps.stroke,\n ratio\n ) as any;\n };\n\n // 需要更新Bounds\n width = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).width = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n height = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).height = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n x = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.x = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n y = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.y = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n angle = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.angle = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n scaleX = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.scaleX = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n scaleY = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.scaleY = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n lineWidth = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.lineWidth = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n startAngle = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).startAngle = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n endAngle = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).endAngle = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n radius = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).radius = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n outerRadius = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).outerRadius = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n innerRadius = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).innerRadius = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n size = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).size = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n}\n\nexport const interpolateUpdateStore = new InterpolateUpdateStore();\n\nexport function commonInterpolateUpdate(key: string, from: any, to: any, ratio: number, step: IStep, target: IGraphic) {\n if (Number.isFinite(to) && Number.isFinite(from)) {\n (target.attribute as any)[key] = from + (to - from) * ratio;\n return true;\n } else if (Array.isArray(to) && Array.isArray(from) && to.length === from.length) {\n const nextList = [];\n let valid = true;\n for (let i = 0; i < to.length; i++) {\n const v = from[i];\n const val = v + (to[i] - v) * ratio;\n if (!Number.isFinite(val)) {\n valid = false;\n break;\n }\n nextList.push(val);\n }\n if (valid) {\n (target.attribute as any)[key] = nextList;\n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AAG,CAAC,CAAC;SACpB;QACD,IAAI,KAAK,EAAE;YACR,MAAM,CAAC,SAAiB,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;SAC3C;QACD,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAtBD,0DAsBC","file":"store.js","sourcesContent":["import type { IGraphic, IStep } from '@visactor/vrender-core';\nimport { interpolateColor, interpolatePureColorArrayToStr, pointsInterpolation } from '@visactor/vrender-core';\nimport { interpolateNumber } from './number';\nimport type { IPointLike } from '@visactor/vutils';\n\n// 直接设置,触发 隐藏类(Hidden Class)优化:\n/**\n *\nconst a = { type: 1 };\nconst ITERATIONS = 1e7; // 测试次数\n\n// 动态生成 keys 数组(确保引擎无法静态推断 key)\nconst keys = [];\nfor (let i = 0; i < ITERATIONS; i++) {\n // 通过条件确保 key 动态变化(但实际始终为 'type',避免属性缺失的开销)\n keys.push(Math.random() < 0 ? 'other' : 'type');\n}\n\n// 测试字面量访问\nfunction testLiteral() {\n let sum = 0;\n for (let i = 0; i < ITERATIONS; i++) {\n const key = keys[i]; // 读取 key(与动态测试完全一致)\n sum += a.type; // 差异仅在此处:使用字面量访问\n }\n return sum;\n}\n\n// 测试变量动态访问\nfunction testDynamic() {\n let sum = 0;\n for (let i = 0; i < ITERATIONS; i++) {\n const key = keys[i]; // 读取 key(与字面量测试完全一致)\n sum += a[key]; // 差异仅在此处:使用变量访问\n }\n return sum;\n}\n\n// 预热(避免 JIT 编译影响)\ntestLiteral();\ntestDynamic();\n\n// 正式测试\nconsole.time('literal');\ntestLiteral();\nconsole.timeEnd('literal');\n\nconsole.time('dynamic');\ntestDynamic();\nconsole.timeEnd('dynamic');\n\n\n// out:\n// literal: 7.1259765625 ms\n// dynamic: 9.322998046875 ms\n */\n\nexport class InterpolateUpdateStore {\n opacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.opacity = interpolateNumber(from, to, ratio);\n };\n baseOpacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).baseOpacity = interpolateNumber(from, to, ratio);\n };\n fillOpacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.fillOpacity = interpolateNumber(from, to, ratio);\n };\n strokeOpacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.strokeOpacity = interpolateNumber(from, to, ratio);\n };\n zIndex = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.zIndex = interpolateNumber(from, to, ratio);\n };\n backgroundOpacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.backgroundOpacity = interpolateNumber(from, to, ratio);\n };\n shadowOffsetX = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.shadowOffsetX = interpolateNumber(from, to, ratio);\n };\n shadowOffsetY = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.shadowOffsetY = interpolateNumber(from, to, ratio);\n };\n shadowBlur = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.shadowBlur = interpolateNumber(from, to, ratio);\n };\n fill = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.fill = interpolateColor(from, to, ratio, false) as any;\n };\n fillPure = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.fill = step.fromParsedProps.fill\n ? (interpolatePureColorArrayToStr(step.fromParsedProps.fill, step.toParsedProps.fill, ratio) as any)\n : step.toParsedProps.fill;\n };\n stroke = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.stroke = interpolateColor(from, to, ratio, false);\n };\n strokePure = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.stroke = step.fromParsedProps.stroke\n ? (interpolatePureColorArrayToStr(step.fromParsedProps.stroke, step.toParsedProps.stroke, ratio) as any)\n : step.toParsedProps.stroke;\n };\n\n // 需要更新Bounds\n width = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).width = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n height = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).height = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n x = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.x = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n y = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.y = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n angle = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.angle = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n scaleX = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.scaleX = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n scaleY = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.scaleY = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n lineWidth = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.lineWidth = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n startAngle = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).startAngle = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n endAngle = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).endAngle = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n radius = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).radius = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n outerRadius = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).outerRadius = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n innerRadius = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).innerRadius = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n size = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).size = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n points = (key: string, from: IPointLike[], to: IPointLike[], ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).points = pointsInterpolation(from, to, ratio);\n target.addUpdateBoundTag();\n };\n}\n\nexport const interpolateUpdateStore = new InterpolateUpdateStore();\n\nexport function commonInterpolateUpdate(key: string, from: any, to: any, ratio: number, step: IStep, target: IGraphic) {\n if (Number.isFinite(to) && Number.isFinite(from)) {\n (target.attribute as any)[key] = from + (to - from) * ratio;\n return true;\n } else if (Array.isArray(to) && Array.isArray(from) && to.length === from.length) {\n const nextList = [];\n let valid = true;\n for (let i = 0; i < to.length; i++) {\n const v = from[i];\n const val = v + (to[i] - v) * ratio;\n if (!Number.isFinite(val)) {\n valid = false;\n break;\n }\n nextList.push(val);\n }\n if (valid) {\n (target.attribute as any)[key] = nextList;\n }\n return true;\n }\n return false;\n}\n"]}
package/cjs/register.js CHANGED
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.registerAnimate = void 0;
6
6
 
7
- const vrender_core_1 = require("@visactor/vrender-core"), animate_1 = require("./animate"), timeline_1 = require("./timeline"), default_ticker_1 = require("./ticker/default-ticker"), vutils_1 = require("@visactor/vutils"), graphic_extension_1 = require("./state/graphic-extension"), animate_extension_1 = require("./animate-extension");
7
+ const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), graphic_extension_1 = require("./state/graphic-extension"), animate_extension_1 = require("./animate-extension");
8
8
 
9
9
  function registerAnimate() {
10
- vrender_core_1.Graphic.Animate || (vrender_core_1.Graphic.Animate = animate_1.Animate),
11
- vrender_core_1.Graphic.Timeline || (vrender_core_1.Graphic.Timeline = timeline_1.DefaultTimeline),
12
- vrender_core_1.Graphic.defaultTimeline || (vrender_core_1.Graphic.defaultTimeline = timeline_1.defaultTimeline),
13
- vrender_core_1.Graphic.Ticker || (vrender_core_1.Graphic.Ticker = default_ticker_1.DefaultTicker),
14
10
  (0, vutils_1.mixin)(vrender_core_1.Graphic, graphic_extension_1.GraphicStateExtension),
15
11
  (0, vutils_1.mixin)(vrender_core_1.Graphic, animate_extension_1.AnimateExtension);
16
12
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/register.ts"],"names":[],"mappings":";;;AAAA,yDAAiD;AACjD,uCAAoC;AACpC,yCAA8D;AAC9D,4DAAwD;AACxD,6CAAyC;AACzC,iEAAkE;AAClE,2DAAuD;AAEvD,SAAgB,eAAe;IAC7B,IAAI,CAAE,sBAAe,CAAC,OAAO,EAAE;QAC5B,sBAAe,CAAC,OAAO,GAAG,iBAAO,CAAC;KACpC;IACD,IAAI,CAAE,sBAAe,CAAC,QAAQ,EAAE;QAC7B,sBAAe,CAAC,QAAQ,GAAG,0BAAe,CAAC;KAC7C;IACD,IAAI,CAAE,sBAAe,CAAC,eAAe,EAAE;QACpC,sBAAe,CAAC,eAAe,GAAG,0BAAe,CAAC;KACpD;IACD,IAAI,CAAE,sBAAe,CAAC,MAAM,EAAE;QAC3B,sBAAe,CAAC,MAAM,GAAG,8BAAa,CAAC;KACzC;IAGD,IAAA,cAAK,EAAC,sBAAO,EAAE,yCAAqB,CAAC,CAAC;IACtC,IAAA,cAAK,EAAC,sBAAO,EAAE,oCAAgB,CAAC,CAAC;AACnC,CAAC;AAjBD,0CAiBC","file":"register.js","sourcesContent":["import { Graphic } from '@visactor/vrender-core';\nimport { Animate } from './animate';\nimport { defaultTimeline, DefaultTimeline } from './timeline';\nimport { DefaultTicker } from './ticker/default-ticker';\nimport { mixin } from '@visactor/vutils';\nimport { GraphicStateExtension } from './state/graphic-extension';\nimport { AnimateExtension } from './animate-extension';\n\nexport function registerAnimate() {\n if (!(Graphic as any).Animate) {\n (Graphic as any).Animate = Animate;\n }\n if (!(Graphic as any).Timeline) {\n (Graphic as any).Timeline = DefaultTimeline;\n }\n if (!(Graphic as any).defaultTimeline) {\n (Graphic as any).defaultTimeline = defaultTimeline;\n }\n if (!(Graphic as any).Ticker) {\n (Graphic as any).Ticker = DefaultTicker;\n }\n\n // Mix in animation state methods to Graphic prototype\n mixin(Graphic, GraphicStateExtension);\n mixin(Graphic, AnimateExtension);\n}\n"]}
1
+ {"version":3,"sources":["../src/register.ts"],"names":[],"mappings":";;;AAAA,yDAAiD;AACjD,6CAAyC;AACzC,iEAAkE;AAClE,2DAAuD;AAEvD,SAAgB,eAAe;IAE7B,IAAA,cAAK,EAAC,sBAAO,EAAE,yCAAqB,CAAC,CAAC;IACtC,IAAA,cAAK,EAAC,sBAAO,EAAE,oCAAgB,CAAC,CAAC;AACnC,CAAC;AAJD,0CAIC","file":"register.js","sourcesContent":["import { Graphic } from '@visactor/vrender-core';\nimport { mixin } from '@visactor/vutils';\nimport { GraphicStateExtension } from './state/graphic-extension';\nimport { AnimateExtension } from './animate-extension';\n\nexport function registerAnimate() {\n // Mix in animation state methods to Graphic prototype\n mixin(Graphic, GraphicStateExtension);\n mixin(Graphic, AnimateExtension);\n}\n"]}
@@ -2,6 +2,19 @@ import type { IGraphic } from '@visactor/vrender-core';
2
2
  import type { IAnimationState } from './types';
3
3
  import type { IAnimationConfig } from '../executor/executor';
4
4
  import { AnimateExecutor } from '../executor/animate-executor';
5
+ export declare const AnimationStates: {
6
+ APPEAR: string;
7
+ DISAPPEAR: string;
8
+ UPDATE: string;
9
+ HIGHLIGHT: string;
10
+ UNHIGHLIGHT: string;
11
+ SELECT: string;
12
+ UNSELECT: string;
13
+ HOVER: string;
14
+ UNHOVER: string;
15
+ ACTIVE: string;
16
+ INACTIVE: string;
17
+ };
5
18
  export declare class AnimationStateStore {
6
19
  graphic: IGraphic;
7
20
  constructor(graphic: IGraphic);
@@ -11,14 +24,19 @@ export declare class AnimationStateStore {
11
24
  }
12
25
  interface IStateInfo {
13
26
  state: string;
14
- animationConfig: IAnimationConfig;
27
+ animationConfig: IAnimationConfig | IAnimationConfig[];
15
28
  executor: AnimateExecutor;
16
29
  }
17
30
  export declare class AnimationStateManager {
18
31
  protected graphic: IGraphic;
19
32
  stateList: IStateInfo[] | null;
20
33
  constructor(graphic: IGraphic);
21
- applyState(nextState: string[], animationConfig: IAnimationState[], callback?: (empty?: boolean) => void): void;
34
+ applyState(nextState: string[], animationConfig: (IAnimationState | IAnimationState[])[], callback?: (empty?: boolean) => void): void;
35
+ applyAppearState(animationConfig: IAnimationConfig, callback?: () => void): void;
36
+ applyDisappearState(animationConfig: IAnimationConfig, callback?: () => void): void;
37
+ applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): void;
38
+ applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): void;
39
+ applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): void;
22
40
  stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void;
23
41
  clearState(): void;
24
42
  }
@@ -2,9 +2,23 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.AnimationStateManager = exports.AnimationStateStore = void 0;
5
+ }), exports.AnimationStateManager = exports.AnimationStateStore = exports.AnimationStates = void 0;
6
6
 
7
- const animation_states_registry_1 = require("./animation-states-registry"), animate_executor_1 = require("../executor/animate-executor");
7
+ const animation_states_registry_1 = require("./animation-states-registry"), animate_executor_1 = require("../executor/animate-executor"), vutils_1 = require("@visactor/vutils");
8
+
9
+ exports.AnimationStates = {
10
+ APPEAR: "appear",
11
+ DISAPPEAR: "disappear",
12
+ UPDATE: "update",
13
+ HIGHLIGHT: "highlight",
14
+ UNHIGHLIGHT: "unhighlight",
15
+ SELECT: "select",
16
+ UNSELECT: "unselect",
17
+ HOVER: "hover",
18
+ UNHOVER: "unhover",
19
+ ACTIVE: "active",
20
+ INACTIVE: "inactive"
21
+ };
8
22
 
9
23
  class AnimationStateStore {
10
24
  constructor(graphic) {
@@ -37,7 +51,7 @@ class AnimationStateManager {
37
51
  result.allowTransition = result.allowTransition && _result.allowTransition;
38
52
  })), result.allowTransition && (shouldApplyState.push({
39
53
  state: state,
40
- animationConfig: animationConfig[index].animation,
54
+ animationConfig: (0, vutils_1.isArray)(animationConfig[index]) ? animationConfig[index].map((item => item.animation)) : animationConfig[index].animation,
41
55
  executor: new animate_executor_1.AnimateExecutor(this.graphic)
42
56
  }), this.stateList.forEach((currState => {
43
57
  registry.isTransitionAllowed(currState.state, state, this.graphic).stopOriginalTransition && shouldStopState.push(currState);
@@ -45,7 +59,7 @@ class AnimationStateManager {
45
59
  })) : nextState.forEach(((state, index) => {
46
60
  shouldApplyState.push({
47
61
  state: state,
48
- animationConfig: animationConfig[index].animation,
62
+ animationConfig: (0, vutils_1.isArray)(animationConfig[index]) ? animationConfig[index].map((item => item.animation)) : animationConfig[index].animation,
49
63
  executor: new animate_executor_1.AnimateExecutor(this.graphic)
50
64
  });
51
65
  })), shouldStopState.forEach((state => {
@@ -63,6 +77,36 @@ class AnimationStateManager {
63
77
  this.stateList ? this.stateList = this.stateList.filter((state => !shouldStopState.includes(state))) : this.stateList = [],
64
78
  this.stateList.push(...shouldApplyState);
65
79
  }
80
+ applyAppearState(animationConfig, callback) {
81
+ this.applyState([ exports.AnimationStates.APPEAR ], [ {
82
+ name: exports.AnimationStates.APPEAR,
83
+ animation: animationConfig
84
+ } ], callback);
85
+ }
86
+ applyDisappearState(animationConfig, callback) {
87
+ this.applyState([ exports.AnimationStates.DISAPPEAR ], [ {
88
+ name: exports.AnimationStates.DISAPPEAR,
89
+ animation: animationConfig
90
+ } ], callback);
91
+ }
92
+ applyUpdateState(animationConfig, callback) {
93
+ this.applyState([ exports.AnimationStates.UPDATE ], [ {
94
+ name: exports.AnimationStates.UPDATE,
95
+ animation: animationConfig
96
+ } ], callback);
97
+ }
98
+ applyHighlightState(animationConfig, callback) {
99
+ this.applyState([ exports.AnimationStates.HIGHLIGHT ], [ {
100
+ name: exports.AnimationStates.HIGHLIGHT,
101
+ animation: animationConfig
102
+ } ], callback);
103
+ }
104
+ applyUnhighlightState(animationConfig, callback) {
105
+ this.applyState([ exports.AnimationStates.UNHIGHLIGHT ], [ {
106
+ name: exports.AnimationStates.UNHIGHLIGHT,
107
+ animation: animationConfig
108
+ } ], callback);
109
+ }
66
110
  stopState(state, type) {
67
111
  var _a;
68
112
  const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find((stateInfo => stateInfo.state === state));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/state/animation-state.ts"],"names":[],"mappings":";;;AAEA,2EAA0E;AAE1E,mEAA+D;AAE/D,MAAa,mBAAmB;IAG9B,YAAY,OAAiB;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAMD,aAAa,CAAC,KAAsB;QAClC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,WAAW;;QACT,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AArBD,kDAqBC;AASD,MAAa,qBAAqB;IAOhC,YAAY,OAAiB;QAF7B,cA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AK,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,EAAE;wBACjD,QAAQ,CAAC,KAAK,CAAC,CAAC;qBACjB;gBACH,CAAC,CAAC,CAAC;aACJ;SACF;aAAM,IAAI,QAAQ,EAAE;YAEnB,QAAQ,CAAC,IAAI,CAAC,CAAC;SAChB;QAED,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;SACnF;aAAM;YACL,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;SACrB;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC;IAC3C,CAAC;IAED,SAAS,CAAC,KAAa,EAAE,IAA4C;;QACnE,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAC/E,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC/B;IACH,CAAC;IAED,UAAU;;QAER,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO,CAAC,KAAK,CAAC,EAAE;YAC9B,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CAKF;AAvHD,sDAuHC","file":"animation-state.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationTransitionRegistry } from './animation-states-registry';\nimport type { IAnimationConfig } from '../executor/executor';\nimport { AnimateExecutor } from '../executor/animate-executor';\n\nexport class AnimationStateStore {\n graphic: IGraphic;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // 动画状态配置\n // 并不是所有图元都有(只有mark才有),所以在应用状态的时候,需要额外传入\n states?: Map<string, IAnimationState>;\n\n registerState(state: IAnimationState): void {\n if (!this.states) {\n this.states = new Map();\n }\n this.states.set(state.name, state);\n }\n\n clearStates(): void {\n this.states?.clear();\n }\n}\n\n// 一个状态对应一个执行器,每个图元都有一一对应\ninterface IStateInfo {\n state: string;\n animationConfig: IAnimationConfig;\n executor: AnimateExecutor;\n}\n\nexport class AnimationStateManager {\n protected graphic: IGraphic;\n\n // 当前状态\n // TODO(注意,这里无法了解动画的顺序,既有串行也有并行,具体在执行的时候确定,执行之后就无法获取串行或并行配置了)\n stateList: IStateInfo[] | null = null;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // TODO 这里因为只有状态变更才会调用,所以代码写的比较宽松,如果有性能问题需要优化\n /**\n * 应用状态\n * @param nextState 下一个状态数组,如果传入数组,那么状态是串行的。但是每次applyState都会立即执行动画,也就是applyState和applyState之间是并行\n * @param animationConfig 动画配置\n * @param callback 动画结束后的回调函数,参数empty为true表示没有动画需要执行直接调的回调\n */\n applyState(nextState: string[], animationConfig: IAnimationState[], callback?: (empty?: boolean) => void): void {\n const registry = AnimationTransitionRegistry.getInstance();\n\n // TODO 这里指判断第一个状态,后续如果需要的话要循环判断\n // 检查是否需要停止当前状态,以及下一个状态是否需要应用\n const shouldStopState: IStateInfo[] = [];\n const shouldApplyState: IStateInfo[] = [];\n if (!(this.stateList && this.stateList.length)) {\n nextState.forEach((state, index) => {\n shouldApplyState.push({\n state,\n animationConfig: animationConfig[index].animation,\n executor: new AnimateExecutor(this.graphic)\n });\n });\n } else {\n // const _stateList = this.stateList[0];\n nextState.forEach((state, index) => {\n // 遍历this.stateList,获取result,只要有一个是false,那这个result就是false\n const result: { allowTransition: boolean; stopOriginalTransition: boolean } = {\n allowTransition: true,\n stopOriginalTransition: true\n };\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n result.allowTransition = result.allowTransition && _result.allowTransition;\n });\n // 所有状态都允许过渡,则添加到shouldApplyState\n if (result.allowTransition) {\n shouldApplyState.push({\n state,\n animationConfig: animationConfig[index].animation,\n executor: new AnimateExecutor(this.graphic)\n });\n // 允许过渡的话,需要重新遍历this.stateList,获取stopOriginalTransition\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n if (_result.stopOriginalTransition) {\n shouldStopState.push(currState);\n }\n });\n }\n });\n }\n\n // 停止动画\n shouldStopState.forEach(state => {\n state.executor.stop();\n });\n\n // 立即应用动画,串行的应用\n if (shouldApplyState.length) {\n shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);\n // 如果下一个状态存在,那么下一个状态的动画在当前状态动画结束后立即执行\n for (let i = 0; i < shouldApplyState.length; i++) {\n const nextState = shouldApplyState[i + 1];\n const currentState = shouldApplyState[i];\n currentState.executor.onEnd(() => {\n if (nextState) {\n nextState.executor.execute(nextState.animationConfig);\n }\n // 删除这个状态\n this.stateList = this.stateList.filter(state => state !== currentState);\n\n // 如果是最后一个状态且有回调,则调用回调\n if (i === shouldApplyState.length - 1 && callback) {\n callback(false);\n }\n });\n }\n } else if (callback) {\n // 如果没有需要应用的动画状态,直接调用回调\n callback(true);\n }\n\n if (this.stateList) {\n this.stateList = this.stateList.filter(state => !shouldStopState.includes(state));\n } else {\n this.stateList = [];\n }\n this.stateList.push(...shouldApplyState);\n }\n\n stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void {\n const stateInfo = this.stateList?.find(stateInfo => stateInfo.state === state);\n if (stateInfo) {\n stateInfo.executor.stop(type);\n }\n }\n\n clearState(): void {\n // 清空状态\n this.stateList?.forEach(state => {\n state.executor.stop();\n });\n this.stateList = null;\n }\n\n // getstateList(): string[] | null {\n // return this.stateList;\n // }\n}\n"]}
1
+ {"version":3,"sources":["../src/state/animation-state.ts"],"names":[],"mappings":";;;AAEA,2E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CAAC,SAAS,CAAC,EAC3B,CAAC,EAAE,IAAI,EAAE,uBAAe,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,EACjE,QAAQ,CACT,CAAC;IACJ,CAAC;IAOD,qBAAqB,CAAC,eAAiC,EAAE,QAAqB;QAC5E,IAAI,CAAC,UAAU,CACb,CAAC,uBAAe,CAAC,WAAW,CAAC,EAC7B,CAAC,EAAE,IAAI,EAAE,uBAAe,CAAC,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,EACnE,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,KAAa,EAAE,IAA4C;;QACnE,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAC/E,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC/B;IACH,CAAC;IAED,UAAU;;QAER,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO,CAAC,KAAK,CAAC,EAAE;YAC9B,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CAKF;AAxLD,sDAwLC","file":"animation-state.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationTransitionRegistry } from './animation-states-registry';\nimport type { IAnimationConfig } from '../executor/executor';\nimport { AnimateExecutor } from '../executor/animate-executor';\nimport { isArray } from '@visactor/vutils';\n\n// Standard animation state names\nexport const AnimationStates = {\n APPEAR: 'appear',\n DISAPPEAR: 'disappear',\n UPDATE: 'update',\n HIGHLIGHT: 'highlight',\n UNHIGHLIGHT: 'unhighlight',\n SELECT: 'select',\n UNSELECT: 'unselect',\n HOVER: 'hover',\n UNHOVER: 'unhover',\n ACTIVE: 'active',\n INACTIVE: 'inactive'\n};\n\nexport class AnimationStateStore {\n graphic: IGraphic;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // 动画状态配置\n // 并不是所有图元都有(只有mark才有),所以在应用状态的时候,需要额外传入\n states?: Map<string, IAnimationState>;\n\n registerState(state: IAnimationState): void {\n if (!this.states) {\n this.states = new Map();\n }\n this.states.set(state.name, state);\n }\n\n clearStates(): void {\n this.states?.clear();\n }\n}\n\n// 一个状态对应一个执行器,每个图元都有一一对应\ninterface IStateInfo {\n state: string;\n animationConfig: IAnimationConfig | IAnimationConfig[];\n executor: AnimateExecutor;\n}\n\nexport class AnimationStateManager {\n protected graphic: IGraphic;\n\n // 当前状态\n // TODO(注意,这里无法了解动画的顺序,既有串行也有并行,具体在执行的时候确定,执行之后就无法获取串行或并行配置了)\n stateList: IStateInfo[] | null = null;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // TODO 这里因为只有状态变更才会调用,所以代码写的比较宽松,如果有性能问题需要优化\n /**\n * 应用状态\n * @param nextState 下一个状态数组,如果传入数组,那么状态是串行的。但是每次applyState都会立即执行动画,也就是applyState和applyState之间是并行\n * @param animationConfig 动画配置\n * @param callback 动画结束后的回调函数,参数empty为true表示没有动画需要执行直接调的回调\n */\n applyState(\n nextState: string[],\n animationConfig: (IAnimationState | IAnimationState[])[],\n callback?: (empty?: boolean) => void\n ): void {\n const registry = AnimationTransitionRegistry.getInstance();\n\n // TODO 这里指判断第一个状态,后续如果需要的话要循环判断\n // 检查是否需要停止当前状态,以及下一个状态是否需要应用\n const shouldStopState: IStateInfo[] = [];\n const shouldApplyState: IStateInfo[] = [];\n if (!(this.stateList && this.stateList.length)) {\n nextState.forEach((state, index) => {\n shouldApplyState.push({\n state,\n animationConfig: isArray(animationConfig[index])\n ? (animationConfig[index] as IAnimationState[]).map(item => item.animation)\n : (animationConfig[index] as IAnimationState).animation,\n executor: new AnimateExecutor(this.graphic)\n });\n });\n } else {\n // const _stateList = this.stateList[0];\n nextState.forEach((state, index) => {\n // 遍历this.stateList,获取result,只要有一个是false,那这个result就是false\n const result: { allowTransition: boolean; stopOriginalTransition: boolean } = {\n allowTransition: true,\n stopOriginalTransition: true\n };\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n result.allowTransition = result.allowTransition && _result.allowTransition;\n });\n // 所有状态都允许过渡,则添加到shouldApplyState\n if (result.allowTransition) {\n shouldApplyState.push({\n state,\n animationConfig: isArray(animationConfig[index])\n ? (animationConfig[index] as IAnimationState[]).map(item => item.animation)\n : (animationConfig[index] as IAnimationState).animation,\n executor: new AnimateExecutor(this.graphic)\n });\n // 允许过渡的话,需要重新遍历this.stateList,获取stopOriginalTransition\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n if (_result.stopOriginalTransition) {\n shouldStopState.push(currState);\n }\n });\n }\n });\n }\n\n // 停止动画\n shouldStopState.forEach(state => {\n state.executor.stop();\n });\n\n // 立即应用动画,串行的应用\n if (shouldApplyState.length) {\n shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);\n // 如果下一个状态存在,那么下一个状态的动画在当前状态动画结束后立即执行\n for (let i = 0; i < shouldApplyState.length; i++) {\n const nextState = shouldApplyState[i + 1];\n const currentState = shouldApplyState[i];\n currentState.executor.onEnd(() => {\n if (nextState) {\n nextState.executor.execute(nextState.animationConfig);\n }\n // 删除这个状态\n this.stateList = this.stateList.filter(state => state !== currentState);\n\n // 如果是最后一个状态且有回调,则调用回调\n if (i === shouldApplyState.length - 1 && callback) {\n callback(false);\n }\n });\n }\n } else if (callback) {\n // 如果没有需要应用的动画状态,直接调用回调\n callback(true);\n }\n\n if (this.stateList) {\n this.stateList = this.stateList.filter(state => !shouldStopState.includes(state));\n } else {\n this.stateList = [];\n }\n this.stateList.push(...shouldApplyState);\n }\n\n /**\n * Apply a standard appear animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyAppearState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState([AnimationStates.APPEAR], [{ name: AnimationStates.APPEAR, animation: animationConfig }], callback);\n }\n\n /**\n * Apply a standard disappear animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyDisappearState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.DISAPPEAR],\n [{ name: AnimationStates.DISAPPEAR, animation: animationConfig }],\n callback\n );\n }\n\n /**\n * Apply a standard update animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState([AnimationStates.UPDATE], [{ name: AnimationStates.UPDATE, animation: animationConfig }], callback);\n }\n\n /**\n * Apply a standard highlight animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.HIGHLIGHT],\n [{ name: AnimationStates.HIGHLIGHT, animation: animationConfig }],\n callback\n );\n }\n\n /**\n * Apply a standard unhighlight animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.UNHIGHLIGHT],\n [{ name: AnimationStates.UNHIGHLIGHT, animation: animationConfig }],\n callback\n );\n }\n\n stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void {\n const stateInfo = this.stateList?.find(stateInfo => stateInfo.state === state);\n if (stateInfo) {\n stateInfo.executor.stop(type);\n }\n }\n\n clearState(): void {\n // 清空状态\n this.stateList?.forEach(state => {\n state.executor.stop();\n });\n this.stateList = null;\n }\n\n // getstateList(): string[] | null {\n // return this.stateList;\n // }\n}\n"]}
@@ -1,11 +1,17 @@
1
1
  import type { IGraphic } from '@visactor/vrender-core';
2
2
  import type { IAnimationState } from './types';
3
3
  import { AnimationStateManager, AnimationStateStore } from './animation-state';
4
+ import type { IAnimationConfig } from '../executor/executor';
4
5
  export declare class GraphicStateExtension {
5
6
  _getAnimationStateManager(graphic: IGraphic): AnimationStateManager;
6
7
  _getAnimationStateStore(graphic: IGraphic): AnimationStateStore;
7
8
  registerAnimationState(state: IAnimationState): this;
8
- applyAnimationState(state: string[], animationConfig: IAnimationState[], callback?: (empty?: boolean) => void): this;
9
+ applyAnimationState(state: string[], animationConfig: (IAnimationState | IAnimationState[])[], callback?: (empty?: boolean) => void): this;
10
+ applyAppearState(animationConfig: IAnimationConfig, callback?: () => void): this;
11
+ applyDisappearState(animationConfig: IAnimationConfig, callback?: () => void): this;
12
+ applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): this;
13
+ applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): this;
14
+ applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): this;
9
15
  stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any>): this;
10
16
  clearAnimationStates(): this;
11
17
  static extend(graphic: IGraphic): IGraphic;
@@ -22,6 +22,26 @@ class GraphicStateExtension {
22
22
  return this._getAnimationStateManager(this).applyState(state, animationConfig, callback),
23
23
  this;
24
24
  }
25
+ applyAppearState(animationConfig, callback) {
26
+ return this._getAnimationStateManager(this).applyAppearState(animationConfig, callback),
27
+ this;
28
+ }
29
+ applyDisappearState(animationConfig, callback) {
30
+ return this._getAnimationStateManager(this).applyDisappearState(animationConfig, callback),
31
+ this;
32
+ }
33
+ applyUpdateState(animationConfig, callback) {
34
+ return this._getAnimationStateManager(this).applyUpdateState(animationConfig, callback),
35
+ this;
36
+ }
37
+ applyHighlightState(animationConfig, callback) {
38
+ return this._getAnimationStateManager(this).applyHighlightState(animationConfig, callback),
39
+ this;
40
+ }
41
+ applyUnhighlightState(animationConfig, callback) {
42
+ return this._getAnimationStateManager(this).applyUnhighlightState(animationConfig, callback),
43
+ this;
44
+ }
25
45
  stopAnimationState(state, type) {
26
46
  return this._getAnimationStateManager(this).stopState(state, type), this;
27
47
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/state/graphic-extension.ts"],"names":[],"mappings":";;;AAEA,uDAA+E;AAK/E,MAAa,qBAAqB;IAChC,yBAAyB,CAAC,OAAiB;QACzC,IAAI,CAAE,OAAe,CAAC,sBAAsB,EAAE;YAE3C,OAAe,CAAC,sBAAsB,GAAG,IAAI,uCAAqB,CAAC,OAAO,CAAC,CAAC;SAC9E;QACD,OAAQ,OAAe,CAAC,sBAAsB,CAAC;IACjD,CAAC;IACD,uBAAuB,CAAC,OAAiB;QACvC,IAAI,CAAE,OAAe,CAAC,oBAAoB,EAAE;YAEzC,OAAe,CAAC,oBAAoB,GAAG,IAAI,qCAAmB,CAAC,OAAO,CAAC,CAAC;SAC1E;QACD,OAAQ,OAAe,CAAC,oBAAoB,CAAC;IAC/C,CAAC;IAKD,sBAAsB,CAAC,KAAsB;QAC3C,IAAI,CAAC,uBAAuB,CAAC,IAA2B,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,mBAAmB,CAAC,KAAe,EAAE,eAAkC,EAAE,QAAoC;QAC3G,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;QACzG,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,kBAAkB,CAAC,KAAa,EAAE,IAA4C;QAC5E,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,oBAAoB;QAClB,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,UAAU,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;IAYD,MAAM,CAAC,MAAM,CAAC,OAAiB;QAC7B,MAAM,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAC9C,SAAS,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA/DD,sDA+DC","file":"graphic-extension.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationStateManager, AnimationStateStore } from './animation-state';\n\n/**\n * 将动画状态方法作为混入扩展 Graphic 的类\n */\nexport class GraphicStateExtension {\n _getAnimationStateManager(graphic: IGraphic): AnimationStateManager {\n if (!(graphic as any)._animationStateManager) {\n // Create the appropriate manager type based on whether this is a group\n (graphic as any)._animationStateManager = new AnimationStateManager(graphic);\n }\n return (graphic as any)._animationStateManager;\n }\n _getAnimationStateStore(graphic: IGraphic): AnimationStateStore {\n if (!(graphic as any)._animationStateStore) {\n // Create the appropriate manager type based on whether this is a group\n (graphic as any)._animationStateStore = new AnimationStateStore(graphic);\n }\n return (graphic as any)._animationStateStore;\n }\n\n /**\n * 注册一个动画状态\n */\n registerAnimationState(state: IAnimationState): this {\n this._getAnimationStateStore(this as unknown as IGraphic).registerState(state);\n return this;\n }\n\n /**\n * 应用一个动画状态到图形\n */\n applyAnimationState(state: string[], animationConfig: IAnimationState[], callback?: (empty?: boolean) => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyState(state, animationConfig, callback);\n return this;\n }\n\n /**\n * 停止一个动画状态\n */\n stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any>): this {\n this._getAnimationStateManager(this as unknown as IGraphic).stopState(state, type);\n return this;\n }\n\n /**\n * 清除图形上的所有动画状态\n */\n clearAnimationStates(): this {\n this._getAnimationStateManager(this as unknown as IGraphic).clearState();\n return this;\n }\n\n // /**\n // * 获取图形当前的动画状态\n // */\n // getCurrentAnimationState(): string[] | null {\n // return this._getAnimationStateManager(this as unknown as IGraphic).getCurrentState();\n // }\n\n /**\n * 继承\n */\n static extend(graphic: IGraphic): IGraphic {\n const extension = new GraphicStateExtension();\n extension._getAnimationStateManager(graphic);\n return graphic;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/state/graphic-extension.ts"],"names":[],"mappings":";;;AAEA,uDAA+E;AAM/E,MAAa,qBAAqB;IAChC,yBAAyB,CAAC,OAAiB;QACzC,IAAI,CAAE,OAAe,CAAC,sBAAsB,EAAE;YAE3C,OAAe,CAAC,sBAAsB,GAAG,IAAI,uCAAqB,CAAC,OAAO,CAAC,CAAC;SAC9E;QACD,OAAQ,OAAe,CAAC,sBAAsB,CAAC;IACjD,CAAC;IACD,uBAAuB,CAAC,OAAiB;QACvC,IAAI,CAAE,OAAe,CAAC,oBAAoB,EAAE;YAEzC,OAAe,CAAC,oBAAoB,GAAG,IAAI,qCAAmB,CAAC,OAAO,CAAC,CAAC;SAC1E;QACD,OAAQ,OAAe,CAAC,oBAAoB,CAAC;IAC/C,CAAC;IAKD,sBAAsB,CAAC,KAAsB;QAC3C,IAAI,CAAC,uBAAuB,CAAC,IAA2B,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,mBAAmB,CACjB,KAAe,EACf,eAAwD,EACxD,QAAoC;QAEpC,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;QACzG,OAAO,IAAI,CAAC;IACd,CAAC;IAOD,gBAAgB,CAAC,eAAiC,EAAE,QAAqB;QACvE,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,gBAAgB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QACxG,OAAO,IAAI,CAAC;IACd,CAAC;IAOD,mBAAmB,CAAC,eAAiC,EAAE,QAAqB;QAC1E,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,mBAAmB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAC3G,OAAO,IAAI,CAAC;IACd,CAAC;IAOD,gBAAgB,CAAC,eAAiC,EAAE,QAAqB;QACvE,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,gBAAgB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QACxG,OAAO,IAAI,CAAC;IACd,CAAC;IAOD,mBAAmB,CAAC,eAAiC,EAAE,QAAqB;QAC1E,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,mBAAmB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAC3G,OAAO,IAAI,CAAC;IACd,CAAC;IAOD,qBAAqB,CAAC,eAAiC,EAAE,QAAqB;QAC5E,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,qBAAqB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAC7G,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,kBAAkB,CAAC,KAAa,EAAE,IAA4C;QAC5E,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,oBAAoB;QAClB,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,UAAU,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;IAYD,MAAM,CAAC,MAAM,CAAC,OAAiB;QAC7B,MAAM,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAC9C,SAAS,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AArHD,sDAqHC","file":"graphic-extension.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationStateManager, AnimationStateStore } from './animation-state';\nimport type { IAnimationConfig } from '../executor/executor';\n\n/**\n * 将动画状态方法作为混入扩展 Graphic 的类\n */\nexport class GraphicStateExtension {\n _getAnimationStateManager(graphic: IGraphic): AnimationStateManager {\n if (!(graphic as any)._animationStateManager) {\n // Create the appropriate manager type based on whether this is a group\n (graphic as any)._animationStateManager = new AnimationStateManager(graphic);\n }\n return (graphic as any)._animationStateManager;\n }\n _getAnimationStateStore(graphic: IGraphic): AnimationStateStore {\n if (!(graphic as any)._animationStateStore) {\n // Create the appropriate manager type based on whether this is a group\n (graphic as any)._animationStateStore = new AnimationStateStore(graphic);\n }\n return (graphic as any)._animationStateStore;\n }\n\n /**\n * 注册一个动画状态\n */\n registerAnimationState(state: IAnimationState): this {\n this._getAnimationStateStore(this as unknown as IGraphic).registerState(state);\n return this;\n }\n\n /**\n * 应用一个动画状态到图形\n */\n applyAnimationState(\n state: string[],\n animationConfig: (IAnimationState | IAnimationState[])[],\n callback?: (empty?: boolean) => void\n ): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyState(state, animationConfig, callback);\n return this;\n }\n\n /**\n * 应用出现动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyAppearState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyAppearState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用消失动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyDisappearState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyDisappearState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用更新动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyUpdateState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用高亮动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyHighlightState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用取消高亮动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyUnhighlightState(animationConfig, callback);\n return this;\n }\n\n /**\n * 停止一个动画状态\n */\n stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any>): this {\n this._getAnimationStateManager(this as unknown as IGraphic).stopState(state, type);\n return this;\n }\n\n /**\n * 清除图形上的所有动画状态\n */\n clearAnimationStates(): this {\n this._getAnimationStateManager(this as unknown as IGraphic).clearState();\n return this;\n }\n\n // /**\n // * 获取图形当前的动画状态\n // */\n // getCurrentAnimationState(): string[] | null {\n // return this._getAnimationStateManager(this as unknown as IGraphic).getCurrentState();\n // }\n\n /**\n * 继承\n */\n static extend(graphic: IGraphic): IGraphic {\n const extension = new GraphicStateExtension();\n extension._getAnimationStateManager(graphic);\n return graphic;\n }\n}\n"]}
package/cjs/step.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import { type IGraphic } from '@visactor/vrender-core';
2
- import type { IAnimate, IStep } from './intreface/animate';
3
- import type { EasingType, EasingTypeFunc } from './intreface/easing';
4
- import type { IAnimateStepType } from './intreface/type';
1
+ import { type IGraphic, type IAnimate, type IStep, type EasingType, type EasingTypeFunc, type IAnimateStepType } from '@visactor/vrender-core';
5
2
  export declare class Step implements IStep {
3
+ id: number;
6
4
  type: IAnimateStepType;
7
5
  prev?: IStep;
8
6
  duration: number;
@@ -41,6 +39,7 @@ export declare class Step implements IStep {
41
39
  getEndProps(): Record<string, any>;
42
40
  getFromProps(): Record<string, any>;
43
41
  getMergedEndProps(): Record<string, any> | void;
42
+ stop(): void;
44
43
  }
45
44
  export declare class WaitStep extends Step {
46
45
  constructor(type: IAnimateStepType, props: Record<string, any>, duration: number, easing: EasingType);
package/cjs/step.js CHANGED
@@ -12,7 +12,7 @@ class Step {
12
12
  constructor(type, props, duration, easing) {
13
13
  this._startTime = 0, this._hasFirstRun = !1, this.type = type, this.props = props,
14
14
  this.duration = duration, this.easing = easing ? "function" == typeof easing ? easing : easing_1.Easing[easing] : easing_1.Easing.linear,
15
- "wait" === type && (this.onUpdate = noop);
15
+ "wait" === type && (this.onUpdate = noop), this.id = vrender_core_1.Generator.GenAutoIncrementId();
16
16
  }
17
17
  bind(target, animate) {
18
18
  this.target = target, this.animate = animate, this.onBind();
@@ -40,13 +40,12 @@ class Step {
40
40
  const funcs = [];
41
41
  this.propKeys.forEach((key => {
42
42
  if ("fill" === key || "stroke" === key) {
43
- const from = this.getLastProps()[key], to = this.props[key];
43
+ const from = this.fromProps[key], to = this.props[key];
44
44
  if ((0, vutils_1.isString)(from) && (0, vutils_1.isString)(to)) {
45
45
  const fromArray = vrender_core_1.ColorStore.Get(from, vrender_core_1.ColorType.Color255), toArray = vrender_core_1.ColorStore.Get(to, vrender_core_1.ColorType.Color255);
46
46
  this.fromParsedProps || (this.fromParsedProps = {}), this.toParsedProps || (this.toParsedProps = {}),
47
- this.fromParsedProps[key] = fromArray, this.toParsedProps[key] = toArray;
48
- }
49
- funcs.push(store_1.interpolateUpdateStore["fill" === key ? "fillPure" : "strokePure"]);
47
+ this.fromParsedProps[key] = fromArray, this.toParsedProps[key] = toArray, funcs.push(store_1.interpolateUpdateStore["fill" === key ? "fillPure" : "strokePure"]);
48
+ } else store_1.interpolateUpdateStore[key] ? funcs.push(store_1.interpolateUpdateStore[key]) : funcs.push(store_1.commonInterpolateUpdate);
50
49
  } else store_1.interpolateUpdateStore[key] ? funcs.push(store_1.interpolateUpdateStore[key]) : funcs.push(store_1.commonInterpolateUpdate);
51
50
  })), this.interpolateUpdateFunctions = funcs;
52
51
  }
@@ -59,9 +58,15 @@ class Step {
59
58
  onBind() {}
60
59
  onFirstRun() {}
61
60
  onStart() {
62
- this._hasFirstRun || (this._hasFirstRun = !0, this.fromProps = this.getLastProps(),
63
- this.determineInterpolateUpdateFunction(), this.tryPreventConflict(), this.trySyncStartProps(),
64
- this.onFirstRun());
61
+ if (!this._hasFirstRun) {
62
+ this._hasFirstRun = !0, this.fromProps = this.getLastProps();
63
+ const startProps = this.animate.getStartProps();
64
+ this.propKeys && this.propKeys.forEach((key => {
65
+ var _a;
66
+ this.fromProps[key] = null !== (_a = this.fromProps[key]) && void 0 !== _a ? _a : startProps[key];
67
+ })), this.determineInterpolateUpdateFunction(), this.tryPreventConflict(), this.trySyncStartProps(),
68
+ this.onFirstRun();
69
+ }
65
70
  }
66
71
  tryPreventConflict() {
67
72
  const animate = this.animate;
@@ -95,7 +100,7 @@ class Step {
95
100
  }
96
101
  onUpdate(end, ratio, out) {}
97
102
  onEnd(cb) {
98
- cb ? this._endCb = cb : this._endCb && (this.target.setAttributes(this.props), this._endCb(this.animate, this));
103
+ this.target.setAttributes(this.props), cb ? this._endCb = cb : this._endCb && this._endCb(this.animate, this);
99
104
  }
100
105
  getEndProps() {
101
106
  return this.props;
@@ -106,6 +111,7 @@ class Step {
106
111
  getMergedEndProps() {
107
112
  return this.getEndProps();
108
113
  }
114
+ stop() {}
109
115
  }
110
116
 
111
117
  exports.Step = Step;
package/cjs/step.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/step.ts"],"names":[],"mappings":";;;AAAA,yDAA8E;AAI9E,2CAAwC;AACxC,+CAAsF;AACtF,6CAA4C;AAE5C,SAAS,IAAI;AAEb,CAAC;AAED,MAAa,IAAI;IA4Bf,YAAY,IAAsB,EAAE,KAA0B,EAAE,QAAgB,EAAE,MAAkB;QAL1F,eAAU,GAAW,CAAC,CAAC;QACjC,iBAAY,GAAY,KAAK,CAAC;QAK5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,MAAM,GAAG,OAAO,MAAM,KAAK,UAAU,CA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AAC,SAAS,CAAC;IACxB,CAAC;IAMD,iBAAiB;QACf,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;CACF;AAhRD,oBAgRC;AAED,MAAa,QAAS,SAAQ,IAAI;IAChC,YAAY,IAAsB,EAAE,KAA0B,EAAE,QAAgB,EAAE,MAAkB;QAClG,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;IAEjB,CAAC;IAED,kCAAkC;QAChC,OAAO;IACT,CAAC;CACF;AAbD,4BAaC","file":"step.js","sourcesContent":["import { ColorStore, ColorType, type IGraphic } from '@visactor/vrender-core';\nimport type { IAnimate, IStep } from './intreface/animate';\nimport type { EasingType, EasingTypeFunc } from './intreface/easing';\nimport type { IAnimateStepType } from './intreface/type';\nimport { Easing } from './utils/easing';\nimport { commonInterpolateUpdate, interpolateUpdateStore } from './interpolate/store';\nimport { isString } from '@visactor/vutils';\n\nfunction noop() {\n //...\n}\n\nexport class Step implements IStep {\n type: IAnimateStepType;\n prev?: IStep;\n duration: number;\n next?: IStep;\n props?: Record<string, any>;\n propKeys?: string[];\n interpolateUpdateFunctions?: ((\n key: string,\n from: number,\n to: number,\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => void)[];\n easing: EasingTypeFunc;\n animate: IAnimate;\n target: IGraphic;\n fromProps: Record<string, any>;\n fromParsedProps: Record<string, any>;\n toParsedProps: Record<string, any>;\n\n // 内部状态\n protected _startTime: number = 0;\n _hasFirstRun: boolean = false;\n\n protected _endCb?: (animate: IAnimate, step: IStep) => void;\n\n constructor(type: IAnimateStepType, props: Record<string, any>, duration: number, easing: EasingType) {\n this.type = type;\n this.props = props;\n this.duration = duration;\n // 设置缓动函数\n if (easing) {\n this.easing = typeof easing === 'function' ? easing : Easing[easing];\n } else {\n this.easing = Easing.linear;\n }\n if (type === 'wait') {\n this.onUpdate = noop;\n }\n }\n\n bind(target: IGraphic, animate: IAnimate): void {\n this.target = target;\n this.animate = animate;\n this.onBind();\n }\n\n append(step: IStep): void {\n this.next = step;\n step.prev = this;\n\n // 更新绝对时间\n step.setStartTime(this.getStartTime() + this.duration, false);\n }\n\n // 更新下游节点的开始时间\n private updateDownstreamStartTimes(): void {\n let currentStep = this.next;\n let currentStartTime = this._startTime + this.duration;\n\n while (currentStep) {\n currentStep.setStartTime(currentStartTime, false);\n currentStartTime += currentStep.duration;\n currentStep = currentStep.next;\n }\n this.animate.updateDuration();\n }\n\n getLastProps(): any {\n if (this.prev) {\n return this.prev.props || {};\n }\n return this.animate.getStartProps();\n }\n\n setDuration(duration: number, updateDownstream: boolean = true): void {\n this.duration = duration;\n\n // 如果有后续节点,更新所有后续节点的开始时间\n if (updateDownstream) {\n this.updateDownstreamStartTimes();\n }\n }\n\n getDuration(): number {\n return this.duration;\n }\n\n determineInterpolateUpdateFunction(): void {\n // 根据属性类型确定插值更新函数\n // 这里可以进行优化,例如缓存不同类型属性的插值更新函数\n if (!this.props) {\n return;\n }\n\n const funcs: ((key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void)[] = [];\n this.propKeys.forEach(key => {\n // 普通颜色特殊处理,需要提前解析成number[]\n if (key === 'fill' || key === 'stroke') {\n const from = this.getLastProps()[key];\n const to = this.props[key];\n if (isString(from) && isString(to)) {\n const fromArray = ColorStore.Get(from, ColorType.Color255);\n const toArray = ColorStore.Get(to, ColorType.Color255);\n if (!this.fromParsedProps) {\n this.fromParsedProps = {};\n }\n if (!this.toParsedProps) {\n this.toParsedProps = {};\n }\n this.fromParsedProps[key] = fromArray;\n this.toParsedProps[key] = toArray;\n }\n funcs.push((interpolateUpdateStore as any)[key === 'fill' ? 'fillPure' : 'strokePure']);\n } else if ((interpolateUpdateStore as any)[key]) {\n funcs.push((interpolateUpdateStore as any)[key]);\n } else {\n funcs.push(commonInterpolateUpdate);\n }\n });\n this.interpolateUpdateFunctions = funcs;\n }\n\n setStartTime(time: number, updateDownstream: boolean = true): void {\n this._startTime = time;\n if (updateDownstream) {\n this.updateDownstreamStartTimes();\n }\n }\n\n getStartTime(): number {\n return this._startTime;\n }\n\n onBind(): void {\n // 在第一次绑定到Animate的时候触发\n }\n\n /**\n * 首次运行逻辑\n * 如果跳帧了就不一定会执行\n */\n onFirstRun(): void {\n // 首次运行逻辑\n }\n\n /**\n * 开始执行的时候调用\n * 如果跳帧了就不一定会执行\n */\n onStart(): void {\n if (!this._hasFirstRun) {\n this._hasFirstRun = true;\n // 获取上一步的属性值作为起始值\n this.fromProps = this.getLastProps();\n this.determineInterpolateUpdateFunction();\n this.tryPreventConflict();\n this.trySyncStartProps();\n this.onFirstRun();\n }\n }\n\n protected tryPreventConflict(): void {\n // 屏蔽掉之前动画冲突的属性\n const animate = this.animate;\n const target = this.target;\n target.animates.forEach((a: any) => {\n if (a === animate || a.priority > animate.priority) {\n return;\n }\n const fromProps = a.getStartProps();\n this.propKeys.forEach(key => {\n if (fromProps[key] != null) {\n a.preventAttr(key);\n }\n });\n });\n }\n\n /**\n * 删除自身属性,会直接从props等内容里删除掉\n */\n deleteSelfAttr(key: string): void {\n delete this.props[key];\n // fromProps在动画开始时才会计算,这时可能不在\n this.fromProps && delete this.fromProps[key];\n const index = this.propKeys.indexOf(key);\n if (index !== -1) {\n this.propKeys.splice(index, 1);\n this.interpolateUpdateFunctions?.splice(index, 1);\n }\n }\n\n /**\n * 尝试同步startProps,因为当前animate的startProps仅包含当前animate的信息,不排除过程中有其他animate的干扰\n * 所以为了避免属性突变,需要确保startProps的属性值是最新的\n */\n trySyncStartProps(): void {\n this.propKeys.forEach(key => {\n this.fromProps[key] = this.animate.target.getComputedAttribute(key);\n });\n }\n\n /**\n * 更新执行的时候调用\n * 如果跳帧了就不一定会执行\n */\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n // TODO 需要修复,只有在开始的时候才调用\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 onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n // ...\n }\n\n /**\n * 结束执行的时候调用\n * 如果跳帧了就不一定会执行\n */\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n if (cb) {\n this._endCb = cb;\n } else if (this._endCb) {\n this.target.setAttributes(this.props);\n this._endCb(this.animate, this);\n }\n }\n\n /**\n * 获取结束的属性,包含前序的终值,是merge过的\n * @returns\n */\n getEndProps(): Record<string, any> {\n return this.props;\n }\n\n /**\n * 获取开始的属性,是前序的终值\n * @returns\n */\n getFromProps(): Record<string, any> {\n return this.fromProps;\n }\n\n /**\n * 获取结束的属性,包含前序的终值,是merge过的,同getEndProps\n * @returns\n */\n getMergedEndProps(): Record<string, any> | void {\n return this.getEndProps();\n }\n}\n\nexport class WaitStep extends Step {\n constructor(type: IAnimateStepType, props: Record<string, any>, duration: number, easing: EasingType) {\n super(type, props, duration, easing);\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n this.onStart();\n // 其他的不执行\n }\n\n determineInterpolateUpdateFunction(): void {\n return;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/step.ts"],"names":[],"mappings":";;;AAAA,yDAUgC;AAChC,2CAAwC;AACxC,+CAAsF;AACtF,6CAA4C;AAE5C,SAAS,IAAI;AAEb,CAAC;AAED,MAAa,IAAI;IA6Bf,YAAY,IAAsB,EAAE,KAA0B,EAAE,QAAgB,EAA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AE,CAAC;IAEjB,CAAC;IAED,kCAAkC;QAChC,OAAO;IACT,CAAC;CACF;AAbD,4BAaC","file":"step.js","sourcesContent":["import {\n ColorStore,\n ColorType,\n Generator,\n type IGraphic,\n type IAnimate,\n type IStep,\n type EasingType,\n type EasingTypeFunc,\n type IAnimateStepType\n} from '@visactor/vrender-core';\nimport { Easing } from './utils/easing';\nimport { commonInterpolateUpdate, interpolateUpdateStore } from './interpolate/store';\nimport { isString } from '@visactor/vutils';\n\nfunction noop() {\n //...\n}\n\nexport class Step implements IStep {\n id: number;\n type: IAnimateStepType;\n prev?: IStep;\n duration: number;\n next?: IStep;\n props?: Record<string, any>;\n propKeys?: string[];\n interpolateUpdateFunctions?: ((\n key: string,\n from: number,\n to: number,\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => void)[];\n easing: EasingTypeFunc;\n animate: IAnimate;\n target: IGraphic;\n fromProps: Record<string, any>;\n fromParsedProps: Record<string, any>;\n toParsedProps: Record<string, any>;\n\n // 内部状态\n protected _startTime: number = 0;\n _hasFirstRun: boolean = false;\n\n protected _endCb?: (animate: IAnimate, step: IStep) => void;\n\n constructor(type: IAnimateStepType, props: Record<string, any>, duration: number, easing: EasingType) {\n this.type = type;\n this.props = props;\n this.duration = duration;\n // 设置缓动函数\n if (easing) {\n this.easing = typeof easing === 'function' ? easing : Easing[easing];\n } else {\n this.easing = Easing.linear;\n }\n if (type === 'wait') {\n this.onUpdate = noop;\n }\n this.id = Generator.GenAutoIncrementId();\n }\n\n bind(target: IGraphic, animate: IAnimate): void {\n this.target = target;\n this.animate = animate;\n this.onBind();\n }\n\n append(step: IStep): void {\n this.next = step;\n step.prev = this;\n\n // 更新绝对时间\n step.setStartTime(this.getStartTime() + this.duration, false);\n }\n\n // 更新下游节点的开始时间\n private updateDownstreamStartTimes(): void {\n let currentStep = this.next;\n let currentStartTime = this._startTime + this.duration;\n\n while (currentStep) {\n currentStep.setStartTime(currentStartTime, false);\n currentStartTime += currentStep.duration;\n currentStep = currentStep.next;\n }\n this.animate.updateDuration();\n }\n\n getLastProps(): any {\n if (this.prev) {\n return this.prev.props || {};\n }\n return this.animate.getStartProps();\n }\n\n setDuration(duration: number, updateDownstream: boolean = true): void {\n this.duration = duration;\n\n // 如果有后续节点,更新所有后续节点的开始时间\n if (updateDownstream) {\n this.updateDownstreamStartTimes();\n }\n }\n\n getDuration(): number {\n return this.duration;\n }\n\n determineInterpolateUpdateFunction(): void {\n // 根据属性类型确定插值更新函数\n // 这里可以进行优化,例如缓存不同类型属性的插值更新函数\n if (!this.props) {\n return;\n }\n\n const funcs: ((key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void)[] = [];\n this.propKeys.forEach(key => {\n // 普通颜色特殊处理,需要提前解析成number[]\n if (key === 'fill' || key === 'stroke') {\n const from = this.fromProps[key];\n const to = this.props[key];\n if (isString(from) && isString(to)) {\n const fromArray = ColorStore.Get(from, ColorType.Color255);\n const toArray = ColorStore.Get(to, ColorType.Color255);\n if (!this.fromParsedProps) {\n this.fromParsedProps = {};\n }\n if (!this.toParsedProps) {\n this.toParsedProps = {};\n }\n this.fromParsedProps[key] = fromArray;\n this.toParsedProps[key] = toArray;\n funcs.push((interpolateUpdateStore as any)[key === 'fill' ? 'fillPure' : 'strokePure']);\n } else if ((interpolateUpdateStore as any)[key]) {\n funcs.push((interpolateUpdateStore as any)[key]);\n } else {\n funcs.push(commonInterpolateUpdate);\n }\n } else if ((interpolateUpdateStore as any)[key]) {\n funcs.push((interpolateUpdateStore as any)[key]);\n } else {\n funcs.push(commonInterpolateUpdate);\n }\n });\n this.interpolateUpdateFunctions = funcs;\n }\n\n setStartTime(time: number, updateDownstream: boolean = true): void {\n this._startTime = time;\n if (updateDownstream) {\n this.updateDownstreamStartTimes();\n }\n }\n\n getStartTime(): number {\n return this._startTime;\n }\n\n onBind(): void {\n // 在第一次绑定到Animate的时候触发\n }\n\n /**\n * 首次运行逻辑\n * 如果跳帧了就不一定会执行\n */\n onFirstRun(): void {\n // 首次运行逻辑\n }\n\n /**\n * 开始执行的时候调用\n * 如果跳帧了就不一定会执行\n */\n onStart(): void {\n if (!this._hasFirstRun) {\n this._hasFirstRun = true;\n // 获取上一步的属性值作为起始值\n this.fromProps = this.getLastProps();\n const startProps = this.animate.getStartProps();\n this.propKeys &&\n this.propKeys.forEach(key => {\n this.fromProps[key] = this.fromProps[key] ?? startProps[key];\n });\n this.determineInterpolateUpdateFunction();\n this.tryPreventConflict();\n this.trySyncStartProps();\n this.onFirstRun();\n }\n }\n\n protected tryPreventConflict(): void {\n // 屏蔽掉之前动画冲突的属性\n const animate = this.animate;\n const target = this.target;\n target.animates.forEach((a: any) => {\n if (a === animate || a.priority > animate.priority) {\n return;\n }\n const fromProps = a.getStartProps();\n this.propKeys.forEach(key => {\n if (fromProps[key] != null) {\n a.preventAttr(key);\n }\n });\n });\n }\n\n /**\n * 删除自身属性,会直接从props等内容里删除掉\n */\n deleteSelfAttr(key: string): void {\n delete this.props[key];\n // fromProps在动画开始时才会计算,这时可能不在\n this.fromProps && delete this.fromProps[key];\n const index = this.propKeys.indexOf(key);\n if (index !== -1) {\n this.propKeys.splice(index, 1);\n this.interpolateUpdateFunctions?.splice(index, 1);\n }\n }\n\n /**\n * 尝试同步startProps,因为当前animate的startProps仅包含当前animate的信息,不排除过程中有其他animate的干扰\n * 所以为了避免属性突变,需要确保startProps的属性值是最新的\n */\n trySyncStartProps(): void {\n this.propKeys.forEach(key => {\n this.fromProps[key] = this.animate.target.getComputedAttribute(key);\n });\n }\n\n /**\n * 更新执行的时候调用\n * 如果跳帧了就不一定会执行\n */\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n // TODO 需要修复,只有在开始的时候才调用\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 onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n // ...\n }\n\n /**\n * 结束执行的时候调用\n * 如果跳帧了就不一定会执行\n */\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n this.target.setAttributes(this.props);\n if (cb) {\n this._endCb = cb;\n } else if (this._endCb) {\n this._endCb(this.animate, this);\n }\n }\n\n /**\n * 获取结束的属性,包含前序的终值,是merge过的\n * @returns\n */\n getEndProps(): Record<string, any> {\n return this.props;\n }\n\n /**\n * 获取开始的属性,是前序的终值\n * @returns\n */\n getFromProps(): Record<string, any> {\n return this.fromProps;\n }\n\n /**\n * 获取结束的属性,包含前序的终值,是merge过的,同getEndProps\n * @returns\n */\n getMergedEndProps(): Record<string, any> | void {\n return this.getEndProps();\n }\n\n stop(): void {\n // ...\n }\n}\n\nexport class WaitStep extends Step {\n constructor(type: IAnimateStepType, props: Record<string, any>, duration: number, easing: EasingType) {\n super(type, props, duration, easing);\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n this.onStart();\n // 其他的不执行\n }\n\n determineInterpolateUpdateFunction(): void {\n return;\n }\n}\n"]}
@@ -1,18 +1,21 @@
1
1
  import { EventEmitter } from '@visactor/vutils';
2
- import type { IStage } from '@visactor/vrender-core';
3
- import { type ITickHandler, type ITicker, STATUS } from '../intreface/ticker';
4
- import type { ITimeline } from '../intreface/timeline';
2
+ import type { IStage, ITimeline } from '@visactor/vrender-core';
3
+ import { type ITickHandler, type ITicker, STATUS } from '@visactor/vrender-core';
5
4
  export declare class DefaultTicker extends EventEmitter implements ITicker {
6
5
  protected interval: number;
7
6
  protected tickerHandler: ITickHandler;
8
7
  protected status: STATUS;
9
8
  protected lastFrameTime: number;
10
- protected lastExecutionTime: number;
11
9
  protected tickCounts: number;
12
10
  protected stage: IStage;
13
11
  timelines: ITimeline[];
14
12
  autoStop: boolean;
13
+ protected _jitter: number;
14
+ protected timeOffset: number;
15
+ _lastTickTime: number;
16
+ protected frameTimeHistory: number[];
15
17
  constructor(stage: IStage);
18
+ computeTimeOffsetAndJitter(): void;
16
19
  init(): void;
17
20
  addTimeline(timeline: ITimeline): void;
18
21
  remTimeline(timeline: ITimeline): void;
@@ -32,8 +35,9 @@ export declare class DefaultTicker extends EventEmitter implements ITicker {
32
35
  stop(): void;
33
36
  trySyncTickStatus(): void;
34
37
  release(): void;
38
+ protected checkSkip: (delta: number) => boolean;
35
39
  protected handleTick: (handler: ITickHandler, params?: {
36
40
  once?: boolean;
37
- }) => void;
38
- protected _handlerTick: () => void;
41
+ }) => boolean;
42
+ protected _handlerTick: (delta: number) => void;
39
43
  }