@visactor/vrender-animate 0.22.4 → 0.22.15-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 (376) hide show
  1. package/cjs/animate-extension.d.ts +12 -5
  2. package/cjs/animate-extension.js +23 -12
  3. package/cjs/animate-extension.js.map +1 -1
  4. package/cjs/animate.d.ts +2 -5
  5. package/cjs/animate.js +23 -18
  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/config/morphing.d.ts +2 -0
  17. package/cjs/config/morphing.js +9 -0
  18. package/cjs/config/morphing.js.map +1 -0
  19. package/cjs/custom/clip-graphic.d.ts +1 -1
  20. package/cjs/custom/clip-graphic.js +2 -2
  21. package/cjs/custom/clip-graphic.js.map +1 -1
  22. package/cjs/custom/clip.d.ts +2 -1
  23. package/cjs/custom/clip.js +9 -1
  24. package/cjs/custom/clip.js.map +1 -1
  25. package/cjs/custom/common.d.ts +1 -3
  26. package/cjs/custom/common.js +21 -17
  27. package/cjs/custom/common.js.map +1 -1
  28. package/cjs/custom/custom-animate.d.ts +7 -3
  29. package/cjs/custom/custom-animate.js +13 -2
  30. package/cjs/custom/custom-animate.js.map +1 -1
  31. package/cjs/custom/fade.d.ts +1 -1
  32. package/cjs/custom/fade.js +7 -2
  33. package/cjs/custom/fade.js.map +1 -1
  34. package/cjs/custom/fromTo.d.ts +10 -0
  35. package/cjs/custom/fromTo.js +42 -0
  36. package/cjs/custom/fromTo.js.map +1 -0
  37. package/cjs/custom/groupFade.d.ts +10 -0
  38. package/cjs/custom/groupFade.js +25 -0
  39. package/cjs/custom/groupFade.js.map +1 -0
  40. package/cjs/custom/growAngle.d.ts +10 -5
  41. package/cjs/custom/growAngle.js +38 -17
  42. package/cjs/custom/growAngle.js.map +1 -1
  43. package/cjs/custom/growCenter.d.ts +1 -2
  44. package/cjs/custom/growCenter.js +16 -10
  45. package/cjs/custom/growCenter.js.map +1 -1
  46. package/cjs/custom/growHeight.d.ts +1 -3
  47. package/cjs/custom/growHeight.js +19 -13
  48. package/cjs/custom/growHeight.js.map +1 -1
  49. package/cjs/custom/growPoints.d.ts +1 -2
  50. package/cjs/custom/growPoints.js +41 -36
  51. package/cjs/custom/growPoints.js.map +1 -1
  52. package/cjs/custom/growRadius.d.ts +4 -5
  53. package/cjs/custom/growRadius.js +22 -18
  54. package/cjs/custom/growRadius.js.map +1 -1
  55. package/cjs/custom/growWidth.d.ts +1 -3
  56. package/cjs/custom/growWidth.js +15 -9
  57. package/cjs/custom/growWidth.js.map +1 -1
  58. package/cjs/custom/input-text.d.ts +1 -2
  59. package/cjs/custom/input-text.js.map +1 -1
  60. package/cjs/custom/label-item-animate.d.ts +7 -0
  61. package/cjs/custom/label-item-animate.js +221 -0
  62. package/cjs/custom/label-item-animate.js.map +1 -0
  63. package/cjs/custom/morphing.d.ts +51 -0
  64. package/cjs/custom/morphing.js +298 -0
  65. package/cjs/custom/morphing.js.map +1 -0
  66. package/cjs/custom/motionPath.d.ts +21 -0
  67. package/cjs/custom/motionPath.js +31 -0
  68. package/cjs/custom/motionPath.js.map +1 -0
  69. package/cjs/custom/move.d.ts +96 -0
  70. package/cjs/custom/move.js +133 -0
  71. package/cjs/custom/move.js.map +1 -0
  72. package/cjs/custom/number.d.ts +1 -2
  73. package/cjs/custom/number.js.map +1 -1
  74. package/cjs/custom/poptip-animate.d.ts +7 -0
  75. package/cjs/custom/poptip-animate.js +109 -0
  76. package/cjs/custom/poptip-animate.js.map +1 -0
  77. package/cjs/custom/register.d.ts +27 -0
  78. package/cjs/custom/register.js +418 -3
  79. package/cjs/custom/register.js.map +1 -1
  80. package/cjs/custom/richtext/input-richtext.d.ts +35 -0
  81. package/cjs/custom/richtext/input-richtext.js +80 -0
  82. package/cjs/custom/richtext/input-richtext.js.map +1 -0
  83. package/cjs/custom/richtext/output-richtext.d.ts +37 -0
  84. package/cjs/custom/richtext/output-richtext.js +94 -0
  85. package/cjs/custom/richtext/output-richtext.js.map +1 -0
  86. package/cjs/custom/richtext/slide-out-richtext.d.ts +38 -0
  87. package/cjs/custom/richtext/slide-out-richtext.js +146 -0
  88. package/cjs/custom/richtext/slide-out-richtext.js.map +1 -0
  89. package/cjs/custom/richtext/slide-richtext.d.ts +36 -0
  90. package/cjs/custom/richtext/slide-richtext.js +144 -0
  91. package/cjs/custom/richtext/slide-richtext.js.map +1 -0
  92. package/cjs/custom/rotate.d.ts +33 -0
  93. package/cjs/custom/rotate.js +79 -0
  94. package/cjs/custom/rotate.js.map +1 -0
  95. package/cjs/custom/scale.d.ts +6 -2
  96. package/cjs/custom/scale.js +32 -17
  97. package/cjs/custom/scale.js.map +1 -1
  98. package/cjs/custom/sphere.d.ts +2 -1
  99. package/cjs/custom/sphere.js +14 -5
  100. package/cjs/custom/sphere.js.map +1 -1
  101. package/cjs/custom/state.d.ts +1 -1
  102. package/cjs/custom/state.js +1 -1
  103. package/cjs/custom/state.js.map +1 -1
  104. package/cjs/custom/story.d.ts +196 -0
  105. package/cjs/custom/story.js +497 -0
  106. package/cjs/custom/story.js.map +1 -0
  107. package/cjs/custom/streamLight.d.ts +27 -0
  108. package/cjs/custom/streamLight.js +161 -0
  109. package/cjs/custom/streamLight.js.map +1 -0
  110. package/cjs/custom/tag-points.d.ts +2 -3
  111. package/cjs/custom/tag-points.js +20 -4
  112. package/cjs/custom/tag-points.js.map +1 -1
  113. package/cjs/custom/update.d.ts +2 -2
  114. package/cjs/custom/update.js +10 -2
  115. package/cjs/custom/update.js.map +1 -1
  116. package/cjs/executor/animate-executor.d.ts +7 -6
  117. package/cjs/executor/animate-executor.js +118 -62
  118. package/cjs/executor/animate-executor.js.map +1 -1
  119. package/cjs/executor/executor.d.ts +9 -3
  120. package/cjs/executor/executor.js.map +1 -1
  121. package/cjs/index.d.ts +8 -8
  122. package/cjs/index.js +50 -18
  123. package/cjs/index.js.map +1 -1
  124. package/cjs/interpolate/store.d.ts +6 -2
  125. package/cjs/interpolate/store.js +13 -2
  126. package/cjs/interpolate/store.js.map +1 -1
  127. package/cjs/register.js +1 -5
  128. package/cjs/register.js.map +1 -1
  129. package/cjs/state/animation-state.d.ts +20 -2
  130. package/cjs/state/animation-state.js +48 -4
  131. package/cjs/state/animation-state.js.map +1 -1
  132. package/cjs/state/animation-states-registry.js +18 -0
  133. package/cjs/state/animation-states-registry.js.map +1 -1
  134. package/cjs/state/graphic-extension.d.ts +7 -1
  135. package/cjs/state/graphic-extension.js +20 -0
  136. package/cjs/state/graphic-extension.js.map +1 -1
  137. package/cjs/step.d.ts +7 -4
  138. package/cjs/step.js +33 -15
  139. package/cjs/step.js.map +1 -1
  140. package/cjs/ticker/default-ticker.d.ts +12 -7
  141. package/cjs/ticker/default-ticker.js +38 -33
  142. package/cjs/ticker/default-ticker.js.map +1 -1
  143. package/cjs/ticker/manual-ticker.d.ts +6 -1
  144. package/cjs/ticker/manual-ticker.js +26 -4
  145. package/cjs/ticker/manual-ticker.js.map +1 -1
  146. package/cjs/timeline.d.ts +14 -7
  147. package/cjs/timeline.js +31 -18
  148. package/cjs/timeline.js.map +1 -1
  149. package/cjs/utils/transform.d.ts +2 -0
  150. package/cjs/utils/transform.js +10 -0
  151. package/cjs/utils/transform.js.map +1 -0
  152. package/dist/index.es.js +3765 -527
  153. package/es/animate-extension.d.ts +12 -5
  154. package/es/animate-extension.js +24 -11
  155. package/es/animate-extension.js.map +1 -1
  156. package/es/animate.d.ts +2 -5
  157. package/es/animate.js +14 -11
  158. package/es/animate.js.map +1 -1
  159. package/es/component/component-animate-extension.d.ts +1 -0
  160. package/es/component/component-animate-extension.js +1 -0
  161. package/es/component/component-animate-extension.js.map +1 -0
  162. package/es/component/component-animator.d.ts +22 -0
  163. package/es/component/component-animator.js +59 -0
  164. package/es/component/component-animator.js.map +1 -0
  165. package/es/component/index.d.ts +1 -0
  166. package/es/component/index.js +2 -0
  167. package/es/component/index.js.map +1 -0
  168. package/es/config/morphing.d.ts +2 -0
  169. package/es/config/morphing.js +5 -0
  170. package/es/config/morphing.js.map +1 -0
  171. package/es/custom/clip-graphic.d.ts +1 -1
  172. package/es/custom/clip-graphic.js +2 -2
  173. package/es/custom/clip-graphic.js.map +1 -1
  174. package/es/custom/clip.d.ts +2 -1
  175. package/es/custom/clip.js +9 -1
  176. package/es/custom/clip.js.map +1 -1
  177. package/es/custom/common.d.ts +1 -3
  178. package/es/custom/common.js +21 -17
  179. package/es/custom/common.js.map +1 -1
  180. package/es/custom/custom-animate.d.ts +7 -3
  181. package/es/custom/custom-animate.js +10 -1
  182. package/es/custom/custom-animate.js.map +1 -1
  183. package/es/custom/fade.d.ts +1 -1
  184. package/es/custom/fade.js +7 -2
  185. package/es/custom/fade.js.map +1 -1
  186. package/es/custom/fromTo.d.ts +10 -0
  187. package/es/custom/fromTo.js +34 -0
  188. package/es/custom/fromTo.js.map +1 -0
  189. package/es/custom/groupFade.d.ts +10 -0
  190. package/es/custom/groupFade.js +15 -0
  191. package/es/custom/groupFade.js.map +1 -0
  192. package/es/custom/growAngle.d.ts +10 -5
  193. package/es/custom/growAngle.js +39 -15
  194. package/es/custom/growAngle.js.map +1 -1
  195. package/es/custom/growCenter.d.ts +1 -2
  196. package/es/custom/growCenter.js +16 -10
  197. package/es/custom/growCenter.js.map +1 -1
  198. package/es/custom/growHeight.d.ts +1 -3
  199. package/es/custom/growHeight.js +20 -14
  200. package/es/custom/growHeight.js.map +1 -1
  201. package/es/custom/growPoints.d.ts +1 -2
  202. package/es/custom/growPoints.js +40 -36
  203. package/es/custom/growPoints.js.map +1 -1
  204. package/es/custom/growRadius.d.ts +4 -5
  205. package/es/custom/growRadius.js +22 -16
  206. package/es/custom/growRadius.js.map +1 -1
  207. package/es/custom/growWidth.d.ts +1 -3
  208. package/es/custom/growWidth.js +16 -10
  209. package/es/custom/growWidth.js.map +1 -1
  210. package/es/custom/input-text.d.ts +1 -2
  211. package/es/custom/input-text.js.map +1 -1
  212. package/es/custom/label-item-animate.d.ts +7 -0
  213. package/es/custom/label-item-animate.js +215 -0
  214. package/es/custom/label-item-animate.js.map +1 -0
  215. package/es/custom/morphing.d.ts +51 -0
  216. package/es/custom/morphing.js +289 -0
  217. package/es/custom/morphing.js.map +1 -0
  218. package/es/custom/motionPath.d.ts +21 -0
  219. package/es/custom/motionPath.js +23 -0
  220. package/es/custom/motionPath.js.map +1 -0
  221. package/es/custom/move.d.ts +96 -0
  222. package/es/custom/move.js +118 -0
  223. package/es/custom/move.js.map +1 -0
  224. package/es/custom/number.d.ts +1 -2
  225. package/es/custom/number.js.map +1 -1
  226. package/es/custom/poptip-animate.d.ts +7 -0
  227. package/es/custom/poptip-animate.js +103 -0
  228. package/es/custom/poptip-animate.js.map +1 -0
  229. package/es/custom/register.d.ts +27 -0
  230. package/es/custom/register.js +48 -1
  231. package/es/custom/register.js.map +1 -1
  232. package/es/custom/richtext/input-richtext.d.ts +35 -0
  233. package/es/custom/richtext/input-richtext.js +74 -0
  234. package/es/custom/richtext/input-richtext.js.map +1 -0
  235. package/es/custom/richtext/output-richtext.d.ts +37 -0
  236. package/es/custom/richtext/output-richtext.js +88 -0
  237. package/es/custom/richtext/output-richtext.js.map +1 -0
  238. package/es/custom/richtext/slide-out-richtext.d.ts +38 -0
  239. package/es/custom/richtext/slide-out-richtext.js +140 -0
  240. package/es/custom/richtext/slide-out-richtext.js.map +1 -0
  241. package/es/custom/richtext/slide-richtext.d.ts +36 -0
  242. package/es/custom/richtext/slide-richtext.js +138 -0
  243. package/es/custom/richtext/slide-richtext.js.map +1 -0
  244. package/es/custom/rotate.d.ts +33 -0
  245. package/es/custom/rotate.js +65 -0
  246. package/es/custom/rotate.js.map +1 -0
  247. package/es/custom/scale.d.ts +6 -2
  248. package/es/custom/scale.js +32 -17
  249. package/es/custom/scale.js.map +1 -1
  250. package/es/custom/sphere.d.ts +2 -1
  251. package/es/custom/sphere.js +14 -5
  252. package/es/custom/sphere.js.map +1 -1
  253. package/es/custom/state.d.ts +1 -1
  254. package/es/custom/state.js +1 -1
  255. package/es/custom/state.js.map +1 -1
  256. package/es/custom/story.d.ts +196 -0
  257. package/es/custom/story.js +468 -0
  258. package/es/custom/story.js.map +1 -0
  259. package/es/custom/streamLight.d.ts +27 -0
  260. package/es/custom/streamLight.js +157 -0
  261. package/es/custom/streamLight.js.map +1 -0
  262. package/es/custom/tag-points.d.ts +2 -3
  263. package/es/custom/tag-points.js +21 -5
  264. package/es/custom/tag-points.js.map +1 -1
  265. package/es/custom/update.d.ts +2 -2
  266. package/es/custom/update.js +10 -2
  267. package/es/custom/update.js.map +1 -1
  268. package/es/executor/animate-executor.d.ts +7 -6
  269. package/es/executor/animate-executor.js +116 -61
  270. package/es/executor/animate-executor.js.map +1 -1
  271. package/es/executor/executor.d.ts +9 -3
  272. package/es/executor/executor.js.map +1 -1
  273. package/es/index.d.ts +8 -8
  274. package/es/index.js +10 -12
  275. package/es/index.js.map +1 -1
  276. package/es/interpolate/store.d.ts +6 -2
  277. package/es/interpolate/store.js +13 -3
  278. package/es/interpolate/store.js.map +1 -1
  279. package/es/register.js +0 -8
  280. package/es/register.js.map +1 -1
  281. package/es/state/animation-state.d.ts +20 -2
  282. package/es/state/animation-state.js +48 -2
  283. package/es/state/animation-state.js.map +1 -1
  284. package/es/state/animation-states-registry.js +18 -0
  285. package/es/state/animation-states-registry.js.map +1 -1
  286. package/es/state/graphic-extension.d.ts +7 -1
  287. package/es/state/graphic-extension.js +20 -0
  288. package/es/state/graphic-extension.js.map +1 -1
  289. package/es/step.d.ts +7 -4
  290. package/es/step.js +34 -16
  291. package/es/step.js.map +1 -1
  292. package/es/ticker/default-ticker.d.ts +12 -7
  293. package/es/ticker/default-ticker.js +30 -27
  294. package/es/ticker/default-ticker.js.map +1 -1
  295. package/es/ticker/manual-ticker.d.ts +6 -1
  296. package/es/ticker/manual-ticker.js +27 -3
  297. package/es/ticker/manual-ticker.js.map +1 -1
  298. package/es/timeline.d.ts +14 -7
  299. package/es/timeline.js +33 -18
  300. package/es/timeline.js.map +1 -1
  301. package/es/utils/transform.d.ts +2 -0
  302. package/es/utils/transform.js +4 -0
  303. package/es/utils/transform.js.map +1 -0
  304. package/package.json +16 -16
  305. package/cjs/custom/group-fade.d.ts +0 -16
  306. package/cjs/custom/group-fade.js +0 -66
  307. package/cjs/custom/group-fade.js.map +0 -1
  308. package/cjs/custom/scale-in.d.ts +0 -13
  309. package/cjs/custom/scale-in.js +0 -57
  310. package/cjs/custom/scale-in.js.map +0 -1
  311. package/cjs/interpolate/executor.d.ts +0 -66
  312. package/cjs/interpolate/executor.js +0 -6
  313. package/cjs/interpolate/executor.js.map +0 -1
  314. package/cjs/intreface/animate.d.ts +0 -91
  315. package/cjs/intreface/animate.js +0 -10
  316. package/cjs/intreface/animate.js.map +0 -1
  317. package/cjs/intreface/easing.d.ts +0 -3
  318. package/cjs/intreface/easing.js +0 -6
  319. package/cjs/intreface/easing.js.map +0 -1
  320. package/cjs/intreface/state.d.ts +0 -35
  321. package/cjs/intreface/state.js +0 -6
  322. package/cjs/intreface/state.js.map +0 -1
  323. package/cjs/intreface/ticker.d.ts +0 -37
  324. package/cjs/intreface/ticker.js +0 -10
  325. package/cjs/intreface/ticker.js.map +0 -1
  326. package/cjs/intreface/timeline.d.ts +0 -17
  327. package/cjs/intreface/timeline.js +0 -6
  328. package/cjs/intreface/timeline.js.map +0 -1
  329. package/cjs/intreface/type.d.ts +0 -13
  330. package/cjs/intreface/type.js +0 -15
  331. package/cjs/intreface/type.js.map +0 -1
  332. package/cjs/state/animation-state-machine.d.ts +0 -22
  333. package/cjs/state/animation-state-machine.js +0 -53
  334. package/cjs/state/animation-state-machine.js.map +0 -1
  335. package/cjs/state/animation-state-queue.d.ts +0 -24
  336. package/cjs/state/animation-state-queue.js +0 -66
  337. package/cjs/state/animation-state-queue.js.map +0 -1
  338. package/cjs/state/animation-state-registry.d.ts +0 -14
  339. package/cjs/state/animation-state-registry.js +0 -53
  340. package/cjs/state/animation-state-registry.js.map +0 -1
  341. package/es/custom/group-fade.d.ts +0 -16
  342. package/es/custom/group-fade.js +0 -56
  343. package/es/custom/group-fade.js.map +0 -1
  344. package/es/custom/scale-in.d.ts +0 -13
  345. package/es/custom/scale-in.js +0 -49
  346. package/es/custom/scale-in.js.map +0 -1
  347. package/es/interpolate/executor.d.ts +0 -66
  348. package/es/interpolate/executor.js +0 -2
  349. package/es/interpolate/executor.js.map +0 -1
  350. package/es/intreface/animate.d.ts +0 -91
  351. package/es/intreface/animate.js +0 -6
  352. package/es/intreface/animate.js.map +0 -1
  353. package/es/intreface/easing.d.ts +0 -3
  354. package/es/intreface/easing.js +0 -2
  355. package/es/intreface/easing.js.map +0 -1
  356. package/es/intreface/state.d.ts +0 -35
  357. package/es/intreface/state.js +0 -2
  358. package/es/intreface/state.js.map +0 -1
  359. package/es/intreface/ticker.d.ts +0 -37
  360. package/es/intreface/ticker.js +0 -6
  361. package/es/intreface/ticker.js.map +0 -1
  362. package/es/intreface/timeline.d.ts +0 -17
  363. package/es/intreface/timeline.js +0 -2
  364. package/es/intreface/timeline.js.map +0 -1
  365. package/es/intreface/type.d.ts +0 -13
  366. package/es/intreface/type.js +0 -14
  367. package/es/intreface/type.js.map +0 -1
  368. package/es/state/animation-state-machine.d.ts +0 -22
  369. package/es/state/animation-state-machine.js +0 -47
  370. package/es/state/animation-state-machine.js.map +0 -1
  371. package/es/state/animation-state-queue.d.ts +0 -24
  372. package/es/state/animation-state-queue.js +0 -58
  373. package/es/state/animation-state-queue.js.map +0 -1
  374. package/es/state/animation-state-registry.d.ts +0 -14
  375. package/es/state/animation-state-registry.js +0 -45
  376. package/es/state/animation-state-registry.js.map +0 -1
@@ -1,15 +1,22 @@
1
- import type { IGraphicAnimateParams } from '@visactor/vrender-core';
2
- import type { IAnimate } from './intreface/animate';
1
+ import type { IGraphicAnimateParams, IAnimate } from '@visactor/vrender-core';
3
2
  import { Animate } from './animate';
4
3
  import { DefaultTimeline } from './timeline';
5
4
  import { DefaultTicker } from './ticker/default-ticker';
5
+ import type { IAnimationConfig } from './executor/executor';
6
+ import { AnimateExecutor } from './executor/animate-executor';
6
7
  export declare class AnimateExtension {
7
- animatedAttribute: Record<string, any> | null;
8
+ finalAttribute: Record<string, any>;
9
+ _animateExecutor: AnimateExecutor | null;
8
10
  animates: Map<string | number, IAnimate>;
9
11
  getAttributes(final?: boolean): any;
10
12
  animate(params?: IGraphicAnimateParams): Animate;
11
- protected computeAnimatedAttribute(): void;
12
13
  createTimeline(): DefaultTimeline;
13
14
  createTicker(stage: any): DefaultTicker;
14
- protected getFinalAttribute(): {};
15
+ setFinalAttributes(finalAttribute: Record<string, any>): void;
16
+ initFinalAttributes(finalAttribute: Record<string, any>): void;
17
+ initAnimateExecutor(): void;
18
+ executeAnimation(config: IAnimationConfig): this;
19
+ executeAnimations(configs: IAnimationConfig[]): this;
20
+ protected getFinalAttribute(): Record<string, any>;
21
+ getGraphicAttribute(key: string, prev?: boolean): any;
15
22
  }
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.AnimateExtension = void 0;
6
6
 
7
- const animate_1 = require("./animate"), timeline_1 = require("./timeline"), default_ticker_1 = require("./ticker/default-ticker");
7
+ const animate_1 = require("./animate"), timeline_1 = require("./timeline"), default_ticker_1 = require("./ticker/default-ticker"), animate_executor_1 = require("./executor/animate-executor");
8
8
 
9
9
  class AnimateExtension {
10
- constructor() {
11
- this.animatedAttribute = null;
12
- }
13
10
  getAttributes(final = !1) {
14
- return final ? (this.computeAnimatedAttribute(), this.getFinalAttribute()) : this.attribute;
11
+ return final && this.finalAttribute ? this.finalAttribute : this.attribute;
15
12
  }
16
13
  animate(params) {
17
14
  var _a, _b, _c;
@@ -26,20 +23,34 @@ class AnimateExtension {
26
23
  animate.stop(), this.animates.delete(animate.id);
27
24
  })), null === (_c = this.stage) || void 0 === _c || _c.ticker.start(), animate;
28
25
  }
29
- computeAnimatedAttribute() {
30
- this.animatedAttribute || (this.animatedAttribute = {}, this.animates.forEach((animate => {
31
- animate.getLoop() !== 1 / 0 && Object.assign(this.animatedAttribute, animate.getEndProps());
32
- })));
33
- }
34
26
  createTimeline() {
35
27
  return new timeline_1.DefaultTimeline;
36
28
  }
37
29
  createTicker(stage) {
38
30
  return new default_ticker_1.DefaultTicker(stage);
39
31
  }
32
+ setFinalAttributes(finalAttribute) {
33
+ this.finalAttribute || (this.finalAttribute = {}), Object.assign(this.finalAttribute, finalAttribute);
34
+ }
35
+ initFinalAttributes(finalAttribute) {
36
+ this.finalAttribute = finalAttribute;
37
+ }
38
+ initAnimateExecutor() {
39
+ this._animateExecutor || (this._animateExecutor = new animate_executor_1.AnimateExecutor(this));
40
+ }
41
+ executeAnimation(config) {
42
+ return this.initAnimateExecutor(), this._animateExecutor.execute(config), this;
43
+ }
44
+ executeAnimations(configs) {
45
+ return this.initAnimateExecutor(), configs.forEach((config => {
46
+ this._animateExecutor.execute(config);
47
+ })), this;
48
+ }
40
49
  getFinalAttribute() {
41
- const finalAttribute = {};
42
- return Object.assign(finalAttribute, this.attribute, this.animatedAttribute), finalAttribute;
50
+ return this.finalAttribute;
51
+ }
52
+ getGraphicAttribute(key, prev = !1) {
53
+ return !prev && this.finalAttribute ? this.finalAttribute[key] : this.attribute[key];
43
54
  }
44
55
  }
45
56
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/animate-extension.ts"],"names":[],"mappings":";;;AASA,uCAAoC;AACpC,yCAA8D;AAC9D,4DAAwD;AAGxD,MAAa,gBAAgB;IAA7B;QACE,sBAAiB,GAA+B,IAAI,CAAC;IAkEvD,CAAC;IA9DC,aAAa,CAAC,QAAiB,KAAK;QAClC,IAAI,KAA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AC,KAAK,0CAAE,MAAM,CAAC,KAAK,EAAE,CAAC;QAEpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,wBAAwB;QAChC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC3B,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;YAE5B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;gBAC9B,IAAI,OAAO,CAAC,OAAO,EAAE,KAAK,QAAQ,EAAE;oBAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;iBAC9D;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,0BAAe,EAAE,CAAC;IAC/B,CAAC;IAED,YAAY,CAAC,KAAU;QACrB,OAAO,IAAI,8BAAa,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAES,iBAAiB;QACzB,MAAM,cAAc,GAAG,EAAE,CAAC;QAC1B,MAAM,CAAC,MAAM,CAAC,cAAc,EAAG,IAAY,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC/E,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAnED,4CAmEC","file":"animate-extension.js","sourcesContent":["// 1. 支持animate函数\n// 2. 支持animates map\n// 2. 支持animatedAttribute 为所有动画的最终结果(loop为INFINITY的动画不算)\n// 3. 支持finalAttribute 为所有动画的最终结果(animatedAttribute 合并了 graphic.attribute之后的最终结果)\n// 3. 重载Graphic的getAttributes方法,根据参数getAttributes(final = true)返回finalAttribute = {}; merge(finalAttribute, graphic.attribute, animatedAttribute),\n// animatedAttribute为所有动画的最终结果(loop为INFINITY的动画不算)\n\nimport type { IGraphicAnimateParams } from '@visactor/vrender-core';\nimport type { IAnimate } from './intreface/animate';\nimport { Animate } from './animate';\nimport { DefaultTimeline, defaultTimeline } from './timeline';\nimport { DefaultTicker } from './ticker/default-ticker';\n\n// 基于性能考虑,每次调用animate函数,都会设置animatedAttribute为null,每次getAttributes(true)会根据animatedAttribute属性判断是否需要重新计算animatedAttribute。\nexport class AnimateExtension {\n animatedAttribute: Record<string, any> | null = null;\n\n declare animates: Map<string | number, IAnimate>;\n\n getAttributes(final: boolean = false) {\n if (final) {\n this.computeAnimatedAttribute();\n return this.getFinalAttribute();\n }\n return (this as any).attribute;\n }\n\n animate(params?: IGraphicAnimateParams) {\n if (!this.animates) {\n this.animates = new Map();\n }\n const animate = new Animate(\n params?.id,\n params?.timeline ?? ((this as any).stage && (this as any).stage.getTimeline()) ?? defaultTimeline,\n params?.slience\n );\n\n animate.bind(this as any);\n if (params) {\n const { onStart, onEnd, onRemove } = params;\n onStart != null && animate.onStart(onStart);\n onEnd != null && animate.onEnd(onEnd);\n onRemove != null && animate.onRemove(onRemove);\n }\n this.animates.set(animate.id, animate);\n animate.onRemove(() => {\n animate.stop();\n this.animates.delete(animate.id);\n });\n\n // TODO 考虑性能问题\n (this as any).stage?.ticker.start();\n\n return animate;\n }\n\n protected computeAnimatedAttribute() {\n if (!this.animatedAttribute) {\n this.animatedAttribute = {};\n\n this.animates.forEach(animate => {\n if (animate.getLoop() !== Infinity) {\n Object.assign(this.animatedAttribute, animate.getEndProps());\n }\n });\n }\n }\n\n createTimeline() {\n return new DefaultTimeline();\n }\n\n createTicker(stage: any) {\n return new DefaultTicker(stage);\n }\n\n protected getFinalAttribute() {\n const finalAttribute = {};\n Object.assign(finalAttribute, (this as any).attribute, this.animatedAttribute);\n return finalAttribute;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/animate-extension.ts"],"names":[],"mappings":";;;AAQA,uCAAoC;AACpC,yCAA8D;AAC9D,4DAAwD;AAExD,kEAA8D;AAG9D,MAAa,gBAAgB;IAM3B,aAAa,CAAC,QAAiB,KAAK;QAClC,IAAI,KAAK,IAAI,IAAI,CAAC,cAAc,EAAE;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC;S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G,CAAC,CAAC;IACtC,CAAC;CACF;AAtGD,4CAsGC","file":"animate-extension.js","sourcesContent":["// 1. 支持animate函数\n// 2. 支持animates map\n// 2. 支持animatedAttribute 为所有动画的最终结果(loop为INFINITY的动画不算)\n// 3. 支持finalAttribute 为所有动画的最终结果(animatedAttribute 合并了 graphic.attribute之后的最终结果)\n// 3. 重载Graphic的getAttributes方法,根据参数getAttributes(final = true)返回finalAttribute = {}; merge(finalAttribute, graphic.attribute, animatedAttribute),\n// animatedAttribute为所有动画的最终结果(loop为INFINITY的动画不算)\n\nimport type { IGraphicAnimateParams, IAnimate } from '@visactor/vrender-core';\nimport { Animate } from './animate';\nimport { DefaultTimeline, defaultTimeline } from './timeline';\nimport { DefaultTicker } from './ticker/default-ticker';\nimport type { IAnimationConfig } from './executor/executor';\nimport { AnimateExecutor } from './executor/animate-executor';\n\n// 基于性能考虑,每次调用animate函数,都会设置animatedAttribute为null,每次getAttributes(true)会根据animatedAttribute属性判断是否需要重新计算animatedAttribute。\nexport class AnimateExtension {\n declare finalAttribute: Record<string, any>;\n _animateExecutor: AnimateExecutor | null;\n\n declare animates: Map<string | number, IAnimate>;\n\n getAttributes(final: boolean = false) {\n if (final && this.finalAttribute) {\n return this.finalAttribute;\n }\n return (this as any).attribute;\n }\n\n animate(params?: IGraphicAnimateParams) {\n if (!this.animates) {\n this.animates = new Map();\n }\n const animate = new Animate(\n params?.id,\n params?.timeline ?? ((this as any).stage && (this as any).stage.getTimeline()) ?? defaultTimeline,\n params?.slience\n );\n\n animate.bind(this as any);\n if (params) {\n const { onStart, onEnd, onRemove } = params;\n onStart != null && animate.onStart(onStart);\n onEnd != null && animate.onEnd(onEnd);\n onRemove != null && animate.onRemove(onRemove);\n }\n this.animates.set(animate.id, animate);\n animate.onRemove(() => {\n animate.stop();\n this.animates.delete(animate.id);\n });\n\n // TODO 考虑性能问题\n (this as any).stage?.ticker.start();\n\n return animate;\n }\n\n createTimeline() {\n return new DefaultTimeline();\n }\n\n createTicker(stage: any) {\n return new DefaultTicker(stage);\n }\n\n setFinalAttributes(finalAttribute: Record<string, any>) {\n if (!this.finalAttribute) {\n this.finalAttribute = {};\n }\n Object.assign(this.finalAttribute, finalAttribute);\n }\n\n initFinalAttributes(finalAttribute: Record<string, any>) {\n this.finalAttribute = finalAttribute;\n }\n\n initAnimateExecutor(): void {\n if (!this._animateExecutor) {\n this._animateExecutor = new AnimateExecutor(this as any);\n }\n }\n\n /**\n * Apply animation configuration to the component\n * @param config Animation configuration\n * @returns This component instance\n */\n executeAnimation(config: IAnimationConfig): this {\n this.initAnimateExecutor();\n this._animateExecutor.execute(config);\n return this;\n }\n\n /**\n * Apply animations to multiple components\n * @param configs Animation configurations\n * @returns This component instance\n */\n executeAnimations(configs: IAnimationConfig[]): this {\n this.initAnimateExecutor();\n configs.forEach(config => {\n this._animateExecutor.execute(config);\n });\n return this;\n }\n\n protected getFinalAttribute() {\n return this.finalAttribute;\n }\n\n // TODO prev是兼容原本VGrammar函数的一个参数,用于动画中获取上一次属性,目前的逻辑中应该不需要,直接去当前帧的属性即可\n getGraphicAttribute(key: string, prev: boolean = false) {\n if (!prev && this.finalAttribute) {\n return this.finalAttribute[key];\n }\n return (this as any).attribute[key];\n }\n}\n"]}
package/cjs/animate.d.ts CHANGED
@@ -1,8 +1,4 @@
1
- import type { IAnimate, IStep, ICustomAnimate } from './intreface/animate';
2
- import type { EasingType } from './intreface/easing';
3
- import { AnimateStatus } from './intreface/type';
4
- import type { ITimeline } from './intreface/timeline';
5
- import { type IGraphic } from '@visactor/vrender-core';
1
+ import { AnimateStatus, type IGraphic, type IAnimate, type IStep, type ICustomAnimate, type EasingType, type ITimeline } from '@visactor/vrender-core';
6
2
  export declare class Animate implements IAnimate {
7
3
  readonly id: string | number;
8
4
  status: AnimateStatus;
@@ -26,6 +22,7 @@ export declare class Animate implements IAnimate {
26
22
  priority: number;
27
23
  protected currentTime: number;
28
24
  slience?: boolean;
25
+ lastRunStep?: IStep;
29
26
  interpolateUpdateFunction: ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void) | null;
30
27
  constructor(id?: string | number, timeline?: ITimeline, slience?: boolean);
31
28
  getStartProps(): Record<string, any>;
package/cjs/animate.js CHANGED
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Animate = void 0;
6
6
 
7
- const type_1 = require("./intreface/type"), step_1 = require("./step"), vrender_core_1 = require("@visactor/vrender-core"), timeline_1 = require("./timeline");
7
+ const step_1 = require("./step"), vrender_core_1 = require("@visactor/vrender-core"), timeline_1 = require("./timeline");
8
8
 
9
9
  class Animate {
10
10
  constructor(id = vrender_core_1.Generator.GenAutoIncrementId(), timeline = timeline_1.defaultTimeline, slience) {
11
- this.id = id, this.status = type_1.AnimateStatus.INITIAL, this._timeline = timeline,
11
+ this.id = id, this.status = vrender_core_1.AnimateStatus.INITIAL, this._timeline = timeline,
12
12
  timeline.addAnimate(this), this.slience = slience, this._startTime = 0, this._duration = 0,
13
13
  this._totalDuration = 0, this._loopCount = 0, this._currentLoop = 0, this._bounce = !1,
14
14
  this._firstStep = null, this._lastStep = null, this._startProps = {}, this._endProps = {},
@@ -35,12 +35,12 @@ class Animate {
35
35
  this.target.animationAttribute || (this.target.animationAttribute = {}), this;
36
36
  }
37
37
  to(props, duration = 300, easing = "linear") {
38
- const step = new step_1.Step(type_1.AnimateStepType.to, props, duration, easing);
39
- return this.updateStepAfterAppend(step), step.bind(this.target, this), this;
38
+ const step = new step_1.Step(vrender_core_1.AnimateStepType.to, props, duration, easing);
39
+ return step.bind(this.target, this), this.updateStepAfterAppend(step), this;
40
40
  }
41
41
  wait(delay) {
42
- const step = new step_1.WaitStep(type_1.AnimateStepType.wait, {}, delay, "linear");
43
- return this.updateStepAfterAppend(step), step.bind(this.target, this), this;
42
+ const step = new step_1.WaitStep(vrender_core_1.AnimateStepType.wait, {}, delay, "linear");
43
+ return step.bind(this.target, this), this.updateStepAfterAppend(step), this;
44
44
  }
45
45
  updateStepAfterAppend(step) {
46
46
  this._firstStep ? (this._lastStep.append(step), this._lastStep = step) : (this._firstStep = step,
@@ -66,19 +66,19 @@ class Animate {
66
66
  })), currentStep = currentStep.next;
67
67
  }
68
68
  from(props, duration = 300, easing = "linear") {
69
- const step = new step_1.Step(type_1.AnimateStepType.from, props, duration, easing);
69
+ const step = new step_1.Step(vrender_core_1.AnimateStepType.from, props, duration, easing);
70
70
  return this._firstStep ? (this._lastStep.append(step), this._lastStep = step) : (this._firstStep = step,
71
71
  this._lastStep = step), this.updateDuration(), this;
72
72
  }
73
73
  play(customAnimate) {
74
- return this.updateStepAfterAppend(customAnimate), customAnimate.bind(this.target, this),
74
+ return customAnimate.bind(this.target, this), this.updateStepAfterAppend(customAnimate),
75
75
  this;
76
76
  }
77
77
  pause() {
78
- this.status === type_1.AnimateStatus.RUNNING && (this.status = type_1.AnimateStatus.PAUSED);
78
+ this.status === vrender_core_1.AnimateStatus.RUNNING && (this.status = vrender_core_1.AnimateStatus.PAUSED);
79
79
  }
80
80
  resume() {
81
- this.status === type_1.AnimateStatus.PAUSED && (this.status = type_1.AnimateStatus.RUNNING);
81
+ this.status === vrender_core_1.AnimateStatus.PAUSED && (this.status = vrender_core_1.AnimateStatus.RUNNING);
82
82
  }
83
83
  onStart(cb) {
84
84
  var _a;
@@ -126,10 +126,13 @@ class Animate {
126
126
  return this._endProps;
127
127
  }
128
128
  stop(type) {
129
- this.status = type_1.AnimateStatus.END, this.onEnd(), this.target && ("start" === type ? this.target.setAttributes(this._startProps) : "end" === type ? this.target.setAttributes(this._endProps) : type && this.target.setAttributes(type));
129
+ let step = this._firstStep;
130
+ for (;step; ) step.stop(), step = step.next;
131
+ this.status !== vrender_core_1.AnimateStatus.END && this.onEnd(), this.status = vrender_core_1.AnimateStatus.END,
132
+ this.target && ("start" === type ? this.target.setAttributes(this._startProps) : "end" === type ? this.target.setAttributes(this._endProps) : type && this.target.setAttributes(type));
130
133
  }
131
134
  release() {
132
- this.status = type_1.AnimateStatus.END, this._onRemove && this._onRemove.forEach((cb => cb())),
135
+ this.status = vrender_core_1.AnimateStatus.END, this._onRemove && this._onRemove.forEach((cb => cb())),
133
136
  this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [];
134
137
  }
135
138
  getDuration() {
@@ -162,13 +165,13 @@ class Animate {
162
165
  return this._bounce = b, this;
163
166
  }
164
167
  advance(delta) {
165
- var _a;
166
- if (this.status === type_1.AnimateStatus.END) return void console.warn("aaa 动画已经结束,不能推进");
168
+ var _a, _b, _c;
169
+ if (this.status === vrender_core_1.AnimateStatus.END) return void console.warn("aaa 动画已经结束,不能推进");
167
170
  const nextTime = this.currentTime + delta;
168
171
  if (nextTime < this._startTime) return void (this.currentTime = nextTime);
169
- if (nextTime >= this._startTime + this._totalDuration) return null === (_a = this._lastStep) || void 0 === _a || _a.onEnd(),
170
- this.onEnd(), void (this.status = type_1.AnimateStatus.END);
171
- this.status = type_1.AnimateStatus.RUNNING, this.currentTime <= this._startTime && this.onStart(),
172
+ if (nextTime >= this._startTime + this._totalDuration) return null === (_a = this._lastStep) || void 0 === _a || _a.onUpdate(!0, 1, {}),
173
+ null === (_b = this._lastStep) || void 0 === _b || _b.onEnd(), this.onEnd(), void (this.status = vrender_core_1.AnimateStatus.END);
174
+ this.status = vrender_core_1.AnimateStatus.RUNNING, this.currentTime <= this._startTime && this.onStart(),
172
175
  this.currentTime = nextTime;
173
176
  let cycleTime = nextTime - this._startTime, newLoop = !1, bounceTime = !1;
174
177
  if (this._loopCount > 0) {
@@ -191,8 +194,10 @@ class Animate {
191
194
  }
192
195
  }
193
196
  if (!targetStep) return;
197
+ targetStep !== this.lastRunStep && (null === (_c = this.lastRunStep) || void 0 === _c || _c.onEnd()),
198
+ this.lastRunStep = targetStep;
194
199
  const ratio = (cycleTime - targetStep.getStartTime()) / targetStep.getDuration(), isEnd = ratio >= 1;
195
- targetStep.update(isEnd, ratio, {}), isEnd && targetStep.onEnd();
200
+ targetStep.update(isEnd, ratio, {}), isEnd && (targetStep.onEnd(), this.lastRunStep = null);
196
201
  }
197
202
  updateDuration() {
198
203
  this._lastStep ? (this._duration = this._lastStep.getStartTime() + this._lastStep.getDuration(),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/animate.ts"],"names":[],"mappings":";;;AAEA,2CAAkE;AAClE,iCAAwC;AAExC,yDAAkE;AAClE,yCAA6C;AAE7C,MAAa,OAAO;IAyClB,YACE,KAAsB,wBAAS,CAAC,kBAAkB,EAAE,EACpD,WAAsB,0BAAe,EACrC,OAAiB;QAEjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,oBAAa,CAAC,OAAO,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QAExB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IACpB,CAAC;IAKD,aAAa;QACX,OAAO,IAAI,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AAC;QAIzD,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC;QACzB,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAGpC,IAAI,KAAK,EAAE;YACT,UAAU,CAAC,KAAK,EAAE,CAAC;SAEpB;IAMH,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YACnB,OAAO;SACR;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QAC9E,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AApqBD,0BAoqBC","file":"animate.js","sourcesContent":["import type { IAnimate, IStep, ICustomAnimate } from './intreface/animate';\nimport type { EasingType } from './intreface/easing';\nimport { AnimateStatus, AnimateStepType } from './intreface/type';\nimport { Step, WaitStep } from './step';\nimport type { ITimeline } from './intreface/timeline';\nimport { Generator, type IGraphic } from '@visactor/vrender-core';\nimport { defaultTimeline } from './timeline';\n\nexport class Animate implements IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n target: IGraphic;\n\n // 回调函数列表\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n // 时间控制\n private _timeline: ITimeline;\n private _startTime: number;\n private _duration: number;\n private _totalDuration: number;\n\n // 动画控制\n // private _reversed: boolean;\n private _loopCount: number;\n private _currentLoop: number;\n private _bounce: boolean;\n\n // 链表头节点和尾节点\n private _firstStep: IStep | null;\n private _lastStep: IStep | null;\n\n // 初始属性和屏蔽的属性\n private _startProps: Record<string, any>;\n private _endProps: Record<string, any>;\n private _preventAttrs: Set<string>;\n // 优先级,用于判定是否能被后续的动画preventAttr\n declare priority: number;\n\n protected currentTime: number;\n slience?: boolean;\n\n interpolateUpdateFunction:\n | ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void)\n | null;\n\n constructor(\n id: string | number = Generator.GenAutoIncrementId(),\n timeline: ITimeline = defaultTimeline,\n slience?: boolean\n ) {\n this.id = id;\n this.status = AnimateStatus.INITIAL;\n this._timeline = timeline;\n timeline.addAnimate(this);\n this.slience = slience;\n this._startTime = 0;\n this._duration = 0;\n this._totalDuration = 0;\n // this._reversed = false;\n this._loopCount = 0;\n this._currentLoop = 0;\n this._bounce = false;\n this._firstStep = null;\n this._lastStep = null;\n this._startProps = {};\n this._endProps = {};\n this._preventAttrs = new Set();\n this.currentTime = 0;\n this.interpolateUpdateFunction = null;\n this.priority = 0;\n }\n\n /**\n * 获取开始属性\n */\n getStartProps(): Record<string, any> {\n return this._startProps;\n }\n\n /**\n * 获取结束属性\n */\n getEndProps(): Record<string, any> {\n return this._endProps;\n }\n\n /**\n * 设置时间线\n */\n setTimeline(timeline: ITimeline): void {\n this._timeline = timeline;\n }\n\n /**\n * 获取时间线\n */\n getTimeline(): ITimeline {\n return this._timeline;\n }\n\n /**\n * 时间线属性访问器\n */\n get timeline(): ITimeline {\n return this._timeline;\n }\n\n /**\n * 绑定目标图形\n */\n bind(target: IGraphic): this {\n this.target = target;\n\n if (this.target.onAnimateBind && !this.slience) {\n this.target.onAnimateBind(this as any);\n }\n // 添加一个animationAttribute属性,用于存储动画过程中的属性\n if (!this.target.animationAttribute) {\n this.target.animationAttribute = {};\n }\n return this;\n }\n\n /**\n * 动画步骤:to\n * 添加一个to步骤,这会在当前状态到指定状态间进行插值\n */\n to(props: Record<string, any>, duration: number = 300, easing: EasingType = 'linear'): this {\n // 创建新的step\n const step = new Step(AnimateStepType.to, props, duration, easing);\n\n this.updateStepAfterAppend(step);\n\n step.bind(this.target, this);\n\n return this;\n }\n\n /**\n * 等待延迟\n */\n wait(delay: number): this {\n // 创建新的wait step\n const step = new WaitStep(AnimateStepType.wait, {}, delay, 'linear');\n\n // 如果是第一个step\n this.updateStepAfterAppend(step);\n\n step.bind(this.target, this);\n\n return this;\n }\n\n protected updateStepAfterAppend(step: IStep): void {\n // 如果是第一个step\n if (!this._firstStep) {\n this._firstStep = step;\n this._lastStep = step;\n } else {\n // 添加到链表末尾\n this._lastStep.append(step);\n this._lastStep = step;\n }\n\n this.parseStepProps(step);\n\n this.updateDuration();\n }\n\n /**\n * 解析step的props\n * 1. 预先获取step的propKeys并保存\n * 2. 将截止目前的最新props设置到step.props中,这样该props上的属性就是最终的属性了,跳帧时直接设置即可\n * 3. 同步到_endProps中,保存这个Animate实例的最终props\n * 4. 给step的props的原型链上绑定Animate的_startProps,这样在下一个step查找fromProps的时候,一定能拿得到值\n */\n parseStepProps(step: IStep) {\n if (!this._lastStep) {\n return;\n }\n\n /* 预设置step的属性,基于性能考虑,实现比较复杂 */\n // step.propKeys为真实的props属性的key\n step.propKeys = step.propKeys || Object.keys(step.props);\n // step.props为包含前序step的props的最终props,用于跳帧等场景,可以直接设置\n Object.keys(this._endProps).forEach(key => {\n step.props[key] = step.props[key] ?? this._endProps[key];\n });\n // 将最终的props设置到step.props中\n step.propKeys.forEach(key => {\n this._endProps[key] = step.props[key];\n });\n // 给step的props的原型链上绑定Animate的_startProps\n // 下一个step在查找上一个step.props(也就是找到它的fromProps)的时候,就能拿到初始的props了\n // 比如:\n // rect.animate().to({ x: 100 }, 1000, 'linear').to({ y: 100 }, 1000, 'linear');\n // 在第二个step查找fromProps的时候,就能拿到第一个step的endProps中的y值(在原型链上)\n // TODO 由于会有其他animate的干扰,所以不能直接设置原型链\n // Object.setPrototypeOf(step.props, this._startProps);\n }\n\n /**\n * 重新同步和计算props,用于内部某些step发生了变更后,重新计算自身\n * 性能较差,不要频繁调用\n * @returns\n */\n reSyncProps() {\n if (!this._lastStep) {\n return;\n }\n this._endProps = {};\n let currentStep: IStep = this._firstStep;\n // 从前向后寻找当前时间所在的step\n while (currentStep) {\n // step.props为包含前序step的props的最终props,用于跳帧等场景,可以直接设置\n // eslint-disable-next-line no-loop-func\n Object.keys(this._endProps).forEach(key => {\n currentStep.props[key] = currentStep.props[key] ?? this._endProps[key];\n });\n // 将最终的props设置到step.props中\n // eslint-disable-next-line no-loop-func\n currentStep.propKeys.forEach(key => {\n this._endProps[key] = currentStep.props[key];\n });\n // 给step的props的原型链上绑定Animate的_startProps\n // 下一个step在查找上一个step.props(也就是找到它的fromProps)的时候,就能拿到初始的props了\n // 比如:\n // rect.animate().to({ x: 100 }, 1000, 'linear').to({ y: 100 }, 1000, 'linear');\n // 在第二个step查找fromProps的时候,就能拿到第一个step的endProps中的y值(在原型链上)\n // TODO 由于会有其他animate的干扰,所以不能直接设置原型链\n // Object.setPrototypeOf(currentStep.props, this._startProps);\n currentStep = currentStep.next;\n }\n }\n\n /**\n * 动画步骤:from\n * 添加一个from步骤,这会将目标属性先设置为指定值,然后过渡到当前状态\n * 【注意】这可能会导致动画跳变,请谨慎使用\n */\n from(props: Record<string, any>, duration: number = 300, easing: EasingType = 'linear'): this {\n // 创建新的step\n const step = new Step(AnimateStepType.from, props, duration, easing);\n\n // 如果是第一个step\n if (!this._firstStep) {\n this._firstStep = step;\n this._lastStep = step;\n } else {\n // 添加到链表末尾\n this._lastStep.append(step);\n this._lastStep = step;\n }\n\n this.updateDuration();\n\n return this;\n }\n\n /**\n * 自定义动画\n */\n play(customAnimate: ICustomAnimate): this {\n this.updateStepAfterAppend(customAnimate);\n\n customAnimate.bind(this.target, this);\n\n return this;\n }\n\n /**\n * 暂停动画\n */\n pause(): void {\n if (this.status === AnimateStatus.RUNNING) {\n this.status = AnimateStatus.PAUSED;\n }\n }\n\n /**\n * 恢复动画\n */\n resume(): void {\n if (this.status === AnimateStatus.PAUSED) {\n this.status = AnimateStatus.RUNNING;\n }\n }\n\n /**\n * 注册开始回调\n */\n onStart(cb?: () => void): void {\n if (cb) {\n if (!this._onStart) {\n this._onStart = [];\n }\n this._onStart.push(cb);\n } else {\n this._onStart?.forEach(cb => cb());\n // 设置开始属性,Animate不会重复执行start所以不需要判断firstStart\n Object.keys(this._endProps).forEach(key => {\n this._startProps[key] = this.target.getComputedAttribute(key);\n });\n }\n }\n\n /**\n * 注册结束回调\n */\n onEnd(cb?: () => void): void {\n if (cb) {\n if (!this._onEnd) {\n this._onEnd = [];\n }\n this._onEnd.push(cb);\n } else {\n this._onEnd?.forEach(cb => cb());\n }\n }\n\n /**\n * 注册帧回调\n */\n onFrame(cb?: (step: IStep, ratio: number) => void): void {\n if (cb) {\n if (!this._onFrame) {\n this._onFrame = [];\n }\n this._onFrame.push(cb);\n }\n }\n\n /**\n * 注册移除回调\n */\n onRemove(cb?: () => void): void {\n if (cb) {\n if (!this._onRemove) {\n this._onRemove = [];\n }\n this._onRemove.push(cb);\n } else {\n this._onRemove?.forEach(cb => cb());\n }\n }\n\n /**\n * 屏蔽单个属性\n */\n preventAttr(key: string): void {\n this._preventAttrs.add(key);\n // 从所有step中移除该属性,并从自身的_startProps和_endProps中移除该属性\n delete this._startProps[key];\n delete this._endProps[key];\n let step = this._firstStep;\n while (step) {\n step.deleteSelfAttr(key);\n step = step.next;\n }\n }\n\n /**\n * 屏蔽多个属性\n */\n preventAttrs(keys: string[]): void {\n keys.forEach(key => this._preventAttrs.add(key));\n }\n\n /**\n * 检查属性是否合法(未被屏蔽)\n */\n validAttr(key: string): boolean {\n return !this._preventAttrs.has(key);\n }\n\n /**\n * 运行自定义回调\n */\n runCb(cb: (a: IAnimate, step: IStep) => void): IAnimate {\n this._lastStep?.onEnd(cb);\n return this;\n }\n\n /**\n * 设置动画开始时间\n */\n startAt(t: number): this {\n this._startTime = t;\n\n return this;\n }\n\n /**\n * 自定义插值函数,返回false表示没有匹配上\n */\n customInterpolate(\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IGraphic,\n ret: Record<string, any>\n ): boolean {\n // 默认无自定义插值,可由子类重写\n return false;\n }\n\n /**\n * 获取起始值,该起始值为animate的起始值,并不一定为step的起始值\n */\n getFromValue(): Record<string, any> {\n return this._startProps;\n }\n\n /**\n * 获取结束值\n */\n getToValue(): Record<string, any> {\n return this._endProps;\n }\n\n /**\n * 停止动画\n */\n stop(type?: 'start' | 'end' | Record<string, any>): void {\n // TODO 有些动画可能一添加就被删除\n // if (this.status === AnimateStatus.END) {\n // return;\n // }\n\n this.status = AnimateStatus.END;\n\n this.onEnd();\n\n if (!this.target) {\n return;\n }\n\n if (type === 'start') {\n // 设置为开始状态\n this.target.setAttributes(this._startProps);\n } else if (type === 'end') {\n // 设置为结束状态\n this.target.setAttributes(this._endProps);\n } else if (type) {\n // 设置为自定义状态\n this.target.setAttributes(type);\n }\n }\n\n /**\n * 释放动画资源\n */\n release(): void {\n this.status = AnimateStatus.END;\n\n // 触发移除回调\n if (this._onRemove) {\n this._onRemove.forEach(cb => cb());\n }\n\n // 清空回调\n this._onStart = [];\n this._onFrame = [];\n this._onEnd = [];\n this._onRemove = [];\n }\n\n /**\n * 获取动画持续时间\n */\n getDuration(): number {\n return this._duration;\n }\n\n /**\n * 获取动画开始时间\n */\n getStartTime(): number {\n return this._startTime;\n }\n\n /**\n * 在所有动画完成后执行\n */\n afterAll(list: IAnimate[]): this {\n if (!list || list.length === 0) {\n return this;\n }\n\n // 计算所有动画结束的最大时间点\n let maxEndTime = 0;\n list.forEach(animate => {\n const endTime = animate.getStartTime() + animate.getTotalDuration();\n maxEndTime = Math.max(maxEndTime, endTime);\n });\n\n // 设置当前动画的开始时间为最大结束时间\n return this.startAt(maxEndTime);\n }\n\n /**\n * 在指定动画完成后执行\n */\n after(animate: IAnimate): this {\n if (!animate) {\n return this;\n }\n\n // 计算指定动画结束的时间点\n const endTime = animate.getStartTime() + animate.getTotalDuration();\n\n // 设置当前动画的开始时间为结束时间\n return this.startAt(endTime);\n }\n\n /**\n * 并行执行动画\n */\n parallel(animate: IAnimate): this {\n if (!animate) {\n return this;\n }\n\n // 设置指定动画的开始时间为当前动画的开始时间\n this.startAt(animate.getStartTime());\n\n return this;\n }\n\n // /**\n // * 设置动画是否反转\n // */\n // reversed(r: boolean): this {\n // this._reversed = r;\n // return this;\n // }\n\n /**\n * 设置动画循环次数,如果传入true,则无限循环,如果传入false,则不循环\n */\n loop(n: number | boolean): this {\n if (n === true) {\n n = Infinity;\n } else if (n === false) {\n n = 0;\n }\n this._loopCount = n;\n this.updateDuration();\n return this;\n }\n\n /**\n * 设置动画是否反弹\n */\n bounce(b: boolean): this {\n this._bounce = b;\n return this;\n }\n\n /**\n * 推进动画\n */\n advance(delta: number): void {\n if (this.status === AnimateStatus.END) {\n console.warn('aaa 动画已经结束,不能推进');\n return;\n }\n const nextTime = this.currentTime + delta;\n // 如果还没开始,直接return\n if (nextTime < this._startTime) {\n this.currentTime = nextTime;\n return;\n }\n // 如果已经结束,设置状态后return\n if (nextTime >= this._startTime + this._totalDuration) {\n this._lastStep?.onEnd();\n this.onEnd();\n this.status = AnimateStatus.END;\n return;\n }\n\n this.status = AnimateStatus.RUNNING;\n\n // 如果是第一次运行,触发开始回调\n if (this.currentTime <= this._startTime) {\n this.onStart();\n }\n this.currentTime = nextTime;\n\n let cycleTime = nextTime - this._startTime;\n let newLoop = false;\n let bounceTime = false;\n if (this._loopCount > 0) {\n cycleTime = (nextTime - this._startTime) % this._duration;\n const currentLoop = Math.floor((nextTime - this._startTime) / this._duration);\n newLoop = currentLoop > this._currentLoop;\n this._currentLoop = currentLoop;\n\n bounceTime = this._bounce && currentLoop % 2 === 1;\n if (bounceTime) {\n cycleTime = this._duration - cycleTime;\n }\n }\n\n // 如果是新的循环,重置为初始状态\n if (newLoop && !bounceTime) {\n this.target.setAttributes(this._startProps);\n }\n\n // 选择起始步骤和遍历方向\n let targetStep: IStep | null = null;\n\n if (this._lastStep === this._firstStep) {\n targetStep = this._firstStep;\n } else {\n let currentStep: IStep = this._firstStep;\n // 从前向后寻找当前时间所在的step\n while (currentStep) {\n const stepStartTime = currentStep.getStartTime();\n const stepDuration = currentStep.getDuration();\n const stepEndTime = stepStartTime + stepDuration;\n\n // 找到当前周期时间所在的step\n if (cycleTime >= stepStartTime && cycleTime <= stepEndTime) {\n targetStep = currentStep;\n break;\n }\n\n currentStep = currentStep.next;\n }\n }\n\n // 如果没找到目标step(可能是所有step都执行完了,但整体动画还没结束,这正常是不存在的)\n if (!targetStep) {\n // this.currentTime = nextTime;\n // console.warn('动画出现问题');\n return;\n }\n\n // 计算当前step的进度比例(基于当前step内的相对时间)\n const stepStartTime = targetStep.getStartTime();\n const stepDuration = targetStep.getDuration();\n\n const ratio = (cycleTime - stepStartTime) / stepDuration;\n // // 限制ratio在0-1之间\n // ratio = Math.max(0, Math.min(1, ratio));\n\n const isEnd = ratio >= 1;\n targetStep.update(isEnd, ratio, {});\n\n // 如果step执行完毕\n if (isEnd) {\n targetStep.onEnd();\n // 不立即调用onFinish,让动画系统来决定何时结束\n }\n\n // 触发帧回调\n // if (this._onFrame) {\n // this._onFrame.forEach(cb => cb(targetStep, ratio));\n // }\n }\n\n updateDuration(): void {\n if (!this._lastStep) {\n this._duration = 0;\n return;\n }\n\n this._duration = this._lastStep.getStartTime() + this._lastStep.getDuration();\n this._totalDuration = this._duration * (this._loopCount + 1);\n }\n\n getTotalDuration(): number {\n return this._totalDuration;\n }\n\n getLoop(): number {\n return this._loopCount;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/animate.ts"],"names":[],"mappings":";;;AAAA,iCAAwC;AACxC,yDAUgC;AAChC,yCAA6C;AAE7C,MAAa,OAAO;IA4ClB,YACE,KAAsB,wBAAS,CAAC,kBAAkB,EAAE,EACpD,WAAsB,0BAAe,EACrC,OAAiB;QAEjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,4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,SAAS,GAAG,aAAa,CAAC,GAAG,YAAY,CAAC;QAIzD,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC;QACzB,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAGpC,IAAI,KAAK,EAAE;YACT,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;SAEzB;IAMH,CAAC;IAED,cAAc;QACZ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YACnB,OAAO;SACR;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QAC9E,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AAvrBD,0BAurBC","file":"animate.js","sourcesContent":["import { Step, WaitStep } from './step';\nimport {\n Generator,\n AnimateStatus,\n AnimateStepType,\n type IGraphic,\n type IAnimate,\n type IStep,\n type ICustomAnimate,\n type EasingType,\n type ITimeline\n} from '@visactor/vrender-core';\nimport { defaultTimeline } from './timeline';\n\nexport class Animate implements IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n target: IGraphic;\n\n // 回调函数列表\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n // 时间控制\n private _timeline: ITimeline;\n private _startTime: number;\n private _duration: number;\n private _totalDuration: number;\n\n // 动画控制\n // private _reversed: boolean;\n private _loopCount: number;\n private _currentLoop: number;\n private _bounce: boolean;\n\n // 链表头节点和尾节点\n private _firstStep: IStep | null;\n private _lastStep: IStep | null;\n\n // 初始属性和屏蔽的属性\n private _startProps: Record<string, any>;\n private _endProps: Record<string, any>;\n private _preventAttrs: Set<string>;\n // 优先级,用于判定是否能被后续的动画preventAttr\n declare priority: number;\n\n protected currentTime: number;\n slience?: boolean;\n\n // 临时变量\n lastRunStep?: IStep;\n\n interpolateUpdateFunction:\n | ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void)\n | null;\n\n constructor(\n id: string | number = Generator.GenAutoIncrementId(),\n timeline: ITimeline = defaultTimeline,\n slience?: boolean\n ) {\n this.id = id;\n this.status = AnimateStatus.INITIAL;\n this._timeline = timeline;\n timeline.addAnimate(this);\n this.slience = slience;\n this._startTime = 0;\n this._duration = 0;\n this._totalDuration = 0;\n // this._reversed = false;\n this._loopCount = 0;\n this._currentLoop = 0;\n this._bounce = false;\n this._firstStep = null;\n this._lastStep = null;\n this._startProps = {};\n this._endProps = {};\n this._preventAttrs = new Set();\n this.currentTime = 0;\n this.interpolateUpdateFunction = null;\n this.priority = 0;\n }\n\n /**\n * 获取开始属性\n */\n getStartProps(): Record<string, any> {\n return this._startProps;\n }\n\n /**\n * 获取结束属性\n */\n getEndProps(): Record<string, any> {\n return this._endProps;\n }\n\n /**\n * 设置时间线\n */\n setTimeline(timeline: ITimeline): void {\n this._timeline = timeline;\n }\n\n /**\n * 获取时间线\n */\n getTimeline(): ITimeline {\n return this._timeline;\n }\n\n /**\n * 时间线属性访问器\n */\n get timeline(): ITimeline {\n return this._timeline;\n }\n\n /**\n * 绑定目标图形\n */\n bind(target: IGraphic): this {\n this.target = target;\n\n if (this.target.onAnimateBind && !this.slience) {\n this.target.onAnimateBind(this as any);\n }\n // 添加一个animationAttribute属性,用于存储动画过程中的属性\n if (!this.target.animationAttribute) {\n this.target.animationAttribute = {};\n }\n return this;\n }\n\n /**\n * 动画步骤:to\n * 添加一个to步骤,这会在当前状态到指定状态间进行插值\n */\n to(props: Record<string, any>, duration: number = 300, easing: EasingType = 'linear'): this {\n // 创建新的step\n const step = new Step(AnimateStepType.to, props, duration, easing);\n\n step.bind(this.target, this);\n\n this.updateStepAfterAppend(step);\n\n return this;\n }\n\n /**\n * 等待延迟\n */\n wait(delay: number): this {\n // 创建新的wait step\n const step = new WaitStep(AnimateStepType.wait, {}, delay, 'linear');\n\n step.bind(this.target, this);\n\n this.updateStepAfterAppend(step);\n\n return this;\n }\n\n protected updateStepAfterAppend(step: IStep): void {\n // 如果是第一个step\n if (!this._firstStep) {\n this._firstStep = step;\n this._lastStep = step;\n } else {\n // 添加到链表末尾\n this._lastStep.append(step);\n this._lastStep = step;\n }\n\n this.parseStepProps(step);\n\n this.updateDuration();\n }\n\n /**\n * 解析step的props\n * 1. 预先获取step的propKeys并保存\n * 2. 将截止目前的最新props设置到step.props中,这样该props上的属性就是最终的属性了,跳帧时直接设置即可\n * 3. 同步到_endProps中,保存这个Animate实例的最终props\n * 4. 给step的props的原型链上绑定Animate的_startProps,这样在下一个step查找fromProps的时候,一定能拿得到值\n */\n parseStepProps(step: IStep) {\n if (!this._lastStep) {\n return;\n }\n\n /* 预设置step的属性,基于性能考虑,实现比较复杂 */\n // step.propKeys为真实的props属性的key\n step.propKeys = step.propKeys || Object.keys(step.props);\n // step.props为包含前序step的props的最终props,用于跳帧等场景,可以直接设置\n Object.keys(this._endProps).forEach(key => {\n step.props[key] = step.props[key] ?? this._endProps[key];\n });\n // 将最终的props设置到step.props中\n step.propKeys.forEach(key => {\n this._endProps[key] = step.props[key];\n });\n // 给step的props的原型链上绑定Animate的_startProps\n // 下一个step在查找上一个step.props(也就是找到它的fromProps)的时候,就能拿到初始的props了\n // 比如:\n // rect.animate().to({ x: 100 }, 1000, 'linear').to({ y: 100 }, 1000, 'linear');\n // 在第二个step查找fromProps的时候,就能拿到第一个step的endProps中的y值(在原型链上)\n // TODO 由于会有其他animate的干扰,所以不能直接设置原型链\n // Object.setPrototypeOf(step.props, this._startProps);\n }\n\n /**\n * 重新同步和计算props,用于内部某些step发生了变更后,重新计算自身\n * 性能较差,不要频繁调用\n * @returns\n */\n reSyncProps() {\n if (!this._lastStep) {\n return;\n }\n this._endProps = {};\n let currentStep: IStep = this._firstStep;\n // 从前向后寻找当前时间所在的step\n while (currentStep) {\n // step.props为包含前序step的props的最终props,用于跳帧等场景,可以直接设置\n // eslint-disable-next-line no-loop-func\n Object.keys(this._endProps).forEach(key => {\n currentStep.props[key] = currentStep.props[key] ?? this._endProps[key];\n });\n // 将最终的props设置到step.props中\n // eslint-disable-next-line no-loop-func\n currentStep.propKeys.forEach(key => {\n this._endProps[key] = currentStep.props[key];\n });\n // 给step的props的原型链上绑定Animate的_startProps\n // 下一个step在查找上一个step.props(也就是找到它的fromProps)的时候,就能拿到初始的props了\n // 比如:\n // rect.animate().to({ x: 100 }, 1000, 'linear').to({ y: 100 }, 1000, 'linear');\n // 在第二个step查找fromProps的时候,就能拿到第一个step的endProps中的y值(在原型链上)\n // TODO 由于会有其他animate的干扰,所以不能直接设置原型链\n // Object.setPrototypeOf(currentStep.props, this._startProps);\n currentStep = currentStep.next;\n }\n }\n\n /**\n * 动画步骤:from\n * 添加一个from步骤,这会将目标属性先设置为指定值,然后过渡到当前状态\n * 【注意】这可能会导致动画跳变,请谨慎使用\n */\n from(props: Record<string, any>, duration: number = 300, easing: EasingType = 'linear'): this {\n // 创建新的step\n const step = new Step(AnimateStepType.from, props, duration, easing);\n\n // 如果是第一个step\n if (!this._firstStep) {\n this._firstStep = step;\n this._lastStep = step;\n } else {\n // 添加到链表末尾\n this._lastStep.append(step);\n this._lastStep = step;\n }\n\n this.updateDuration();\n\n return this;\n }\n\n /**\n * 自定义动画\n */\n play(customAnimate: ICustomAnimate): this {\n customAnimate.bind(this.target, this);\n this.updateStepAfterAppend(customAnimate);\n\n return this;\n }\n\n /**\n * 暂停动画\n */\n pause(): void {\n if (this.status === AnimateStatus.RUNNING) {\n this.status = AnimateStatus.PAUSED;\n }\n }\n\n /**\n * 恢复动画\n */\n resume(): void {\n if (this.status === AnimateStatus.PAUSED) {\n this.status = AnimateStatus.RUNNING;\n }\n }\n\n /**\n * 注册开始回调\n */\n onStart(cb?: () => void): void {\n if (cb) {\n if (!this._onStart) {\n this._onStart = [];\n }\n this._onStart.push(cb);\n } else {\n this._onStart?.forEach(cb => cb());\n // 设置开始属性,Animate不会重复执行start所以不需要判断firstStart\n Object.keys(this._endProps).forEach(key => {\n this._startProps[key] = this.target.getComputedAttribute(key);\n });\n }\n }\n\n /**\n * 注册结束回调\n */\n onEnd(cb?: () => void): void {\n if (cb) {\n if (!this._onEnd) {\n this._onEnd = [];\n }\n this._onEnd.push(cb);\n } else {\n this._onEnd?.forEach(cb => cb());\n }\n }\n\n /**\n * 注册帧回调\n */\n onFrame(cb?: (step: IStep, ratio: number) => void): void {\n if (cb) {\n if (!this._onFrame) {\n this._onFrame = [];\n }\n this._onFrame.push(cb);\n }\n }\n\n /**\n * 注册移除回调\n */\n onRemove(cb?: () => void): void {\n if (cb) {\n if (!this._onRemove) {\n this._onRemove = [];\n }\n this._onRemove.push(cb);\n } else {\n this._onRemove?.forEach(cb => cb());\n }\n }\n\n /**\n * 屏蔽单个属性\n */\n preventAttr(key: string): void {\n this._preventAttrs.add(key);\n // 从所有step中移除该属性,并从自身的_startProps和_endProps中移除该属性\n delete this._startProps[key];\n delete this._endProps[key];\n let step = this._firstStep;\n while (step) {\n step.deleteSelfAttr(key);\n step = step.next;\n }\n }\n\n /**\n * 屏蔽多个属性\n */\n preventAttrs(keys: string[]): void {\n keys.forEach(key => this._preventAttrs.add(key));\n }\n\n /**\n * 检查属性是否合法(未被屏蔽)\n */\n validAttr(key: string): boolean {\n return !this._preventAttrs.has(key);\n }\n\n /**\n * 运行自定义回调\n */\n runCb(cb: (a: IAnimate, step: IStep) => void): IAnimate {\n this._lastStep?.onEnd(cb);\n return this;\n }\n\n /**\n * 设置动画开始时间\n */\n startAt(t: number): this {\n this._startTime = t;\n\n return this;\n }\n\n /**\n * 自定义插值函数,返回false表示没有匹配上\n */\n customInterpolate(\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IGraphic,\n ret: Record<string, any>\n ): boolean {\n // 默认无自定义插值,可由子类重写\n return false;\n }\n\n /**\n * 获取起始值,该起始值为animate的起始值,并不一定为step的起始值\n */\n getFromValue(): Record<string, any> {\n return this._startProps;\n }\n\n /**\n * 获取结束值\n */\n getToValue(): Record<string, any> {\n return this._endProps;\n }\n\n /**\n * 停止动画\n */\n stop(type?: 'start' | 'end' | Record<string, any>): void {\n // TODO 有些动画可能一添加就被删除\n // if (this.status === AnimateStatus.END) {\n // return;\n // }\n // 遍历step,调用其stop\n let step = this._firstStep;\n while (step) {\n step.stop();\n step = step.next;\n }\n\n if (this.status !== AnimateStatus.END) {\n this.onEnd();\n }\n\n this.status = AnimateStatus.END;\n\n if (!this.target) {\n return;\n }\n\n if (type === 'start') {\n // 设置为开始状态\n this.target.setAttributes(this._startProps);\n } else if (type === 'end') {\n // 设置为结束状态\n this.target.setAttributes(this._endProps);\n } else if (type) {\n // 设置为自定义状态\n this.target.setAttributes(type);\n }\n }\n\n /**\n * 释放动画资源\n */\n release(): void {\n this.status = AnimateStatus.END;\n\n // 触发移除回调\n if (this._onRemove) {\n this._onRemove.forEach(cb => cb());\n }\n\n // 清空回调\n this._onStart = [];\n this._onFrame = [];\n this._onEnd = [];\n this._onRemove = [];\n }\n\n /**\n * 获取动画持续时间\n */\n getDuration(): number {\n return this._duration;\n }\n\n /**\n * 获取动画开始时间\n */\n getStartTime(): number {\n return this._startTime;\n }\n\n /**\n * 在所有动画完成后执行\n */\n afterAll(list: IAnimate[]): this {\n if (!list || list.length === 0) {\n return this;\n }\n\n // 计算所有动画结束的最大时间点\n let maxEndTime = 0;\n list.forEach(animate => {\n const endTime = animate.getStartTime() + animate.getTotalDuration();\n maxEndTime = Math.max(maxEndTime, endTime);\n });\n\n // 设置当前动画的开始时间为最大结束时间\n return this.startAt(maxEndTime);\n }\n\n /**\n * 在指定动画完成后执行\n */\n after(animate: IAnimate): this {\n if (!animate) {\n return this;\n }\n\n // 计算指定动画结束的时间点\n const endTime = animate.getStartTime() + animate.getTotalDuration();\n\n // 设置当前动画的开始时间为结束时间\n return this.startAt(endTime);\n }\n\n /**\n * 并行执行动画\n */\n parallel(animate: IAnimate): this {\n if (!animate) {\n return this;\n }\n\n // 设置指定动画的开始时间为当前动画的开始时间\n this.startAt(animate.getStartTime());\n\n return this;\n }\n\n // /**\n // * 设置动画是否反转\n // */\n // reversed(r: boolean): this {\n // this._reversed = r;\n // return this;\n // }\n\n /**\n * 设置动画循环次数,如果传入true,则无限循环,如果传入false,则不循环\n */\n loop(n: number | boolean): this {\n if (n === true) {\n n = Infinity;\n } else if (n === false) {\n n = 0;\n }\n this._loopCount = n;\n this.updateDuration();\n return this;\n }\n\n /**\n * 设置动画是否反弹\n */\n bounce(b: boolean): this {\n this._bounce = b;\n return this;\n }\n\n /**\n * 推进动画\n */\n advance(delta: number): void {\n if (this.status === AnimateStatus.END) {\n console.warn('aaa 动画已经结束,不能推进');\n return;\n }\n const nextTime = this.currentTime + delta;\n // 如果还没开始,直接return\n if (nextTime < this._startTime) {\n this.currentTime = nextTime;\n return;\n }\n // 如果已经结束,设置状态后return\n if (nextTime >= this._startTime + this._totalDuration) {\n this._lastStep?.onUpdate(true, 1, {});\n this._lastStep?.onEnd();\n this.onEnd();\n this.status = AnimateStatus.END;\n return;\n }\n\n this.status = AnimateStatus.RUNNING;\n\n // 如果是第一次运行,触发开始回调\n if (this.currentTime <= this._startTime) {\n this.onStart();\n }\n this.currentTime = nextTime;\n\n let cycleTime = nextTime - this._startTime;\n let newLoop = false;\n let bounceTime = false;\n if (this._loopCount > 0) {\n cycleTime = (nextTime - this._startTime) % this._duration;\n const currentLoop = Math.floor((nextTime - this._startTime) / this._duration);\n newLoop = currentLoop > this._currentLoop;\n this._currentLoop = currentLoop;\n\n bounceTime = this._bounce && currentLoop % 2 === 1;\n if (bounceTime) {\n cycleTime = this._duration - cycleTime;\n }\n }\n\n // 如果是新的循环,重置为初始状态\n if (newLoop && !bounceTime) {\n this.target.setAttributes(this._startProps);\n }\n\n // 选择起始步骤和遍历方向\n let targetStep: IStep | null = null;\n\n if (this._lastStep === this._firstStep) {\n targetStep = this._firstStep;\n } else {\n let currentStep: IStep = this._firstStep;\n // 从前向后寻找当前时间所在的step\n while (currentStep) {\n const stepStartTime = currentStep.getStartTime();\n const stepDuration = currentStep.getDuration();\n const stepEndTime = stepStartTime + stepDuration;\n\n // 找到当前周期时间所在的step\n if (cycleTime >= stepStartTime && cycleTime <= stepEndTime) {\n targetStep = currentStep;\n break;\n }\n\n currentStep = currentStep.next;\n }\n }\n\n // 如果没找到目标step(可能是所有step都执行完了,但整体动画还没结束,这正常是不存在的)\n if (!targetStep) {\n // this.currentTime = nextTime;\n // console.warn('动画出现问题');\n return;\n }\n\n // 如果当前step和上一次执行的step不一样,则调用上一次step的onEnd,确保所有完成的step都调用了结束\n // 如果上一次的step已经调用了onEnd,在下面的onEnd那里会将lastRunStep设置为null\n if (targetStep !== this.lastRunStep) {\n this.lastRunStep?.onEnd();\n }\n\n this.lastRunStep = targetStep;\n\n // 计算当前step的进度比例(基于当前step内的相对时间)\n const stepStartTime = targetStep.getStartTime();\n const stepDuration = targetStep.getDuration();\n\n const ratio = (cycleTime - stepStartTime) / stepDuration;\n // // 限制ratio在0-1之间\n // ratio = Math.max(0, Math.min(1, ratio));\n\n const isEnd = ratio >= 1;\n targetStep.update(isEnd, ratio, {});\n\n // 如果step执行完毕\n if (isEnd) {\n targetStep.onEnd();\n this.lastRunStep = null;\n // 不立即调用onFinish,让动画系统来决定何时结束\n }\n\n // 触发帧回调\n // if (this._onFrame) {\n // this._onFrame.forEach(cb => cb(targetStep, ratio));\n // }\n }\n\n updateDuration(): void {\n if (!this._lastStep) {\n this._duration = 0;\n return;\n }\n\n this._duration = this._lastStep.getStartTime() + this._lastStep.getDuration();\n this._totalDuration = this._duration * (this._loopCount + 1);\n }\n\n getTotalDuration(): number {\n return this._totalDuration;\n }\n\n getLoop(): number {\n return this._loopCount;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=component-animate-extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/component/component-animate-extension.ts"],"names":[],"mappings":"","file":"component-animate-extension.js","sourcesContent":["// import type { IGraphic } from '@visactor/vrender-core';\n// import type { IAnimationConfig } from '../executor/executor';\n// import { ComponentAnimator } from './component-animator';\n\n// /**\n// * Component animation extension that can be mixed in to component classes\n// */\n// export class ComponentAnimateExtension {\n// private _componentAnimator: ComponentAnimator;\n\n// /**\n// * Get the component animator for this component\n// * @returns The ComponentAnimator instance\n// */\n// getComponentAnimator(): ComponentAnimator {\n// if (!this._componentAnimator) {\n// this._componentAnimator = new ComponentAnimator(this as unknown as IGraphic);\n// }\n// return this._componentAnimator;\n// }\n\n// /**\n// * Create a new animation sequence for this component\n// * @returns A new ComponentAnimator instance\n// */\n// createAnimationSequence(): ComponentAnimator {\n// return new ComponentAnimator(this as unknown as IGraphic);\n// }\n\n// /**\n// * Create an animation for the component with the given preset\n// * @param preset Animation preset name ('appear', 'disappear', etc.)\n// * @param options Animation options\n// * @returns The ComponentAnimator instance\n// */\n// animate(preset: string, options?: Record<string, any>): ComponentAnimator {\n// const animator = this.getComponentAnimator();\n\n// // Call the appropriate animation setup method based on preset\n// switch (preset) {\n// case 'appear':\n// this.setupAppearAnimation(animator, options);\n// break;\n// case 'disappear':\n// this.setupDisappearAnimation(animator, options);\n// break;\n// default:\n// throw new Error(`Unknown animation preset: ${preset}`);\n// }\n\n// // Start the animation immediately\n// animator.start();\n\n// return animator;\n// }\n\n// /**\n// * Create an appear animation\n// * @param options Animation options\n// * @returns The ComponentAnimator instance (not started)\n// */\n// createAppearAnimation(options?: Record<string, any>): ComponentAnimator {\n// const animator = this.createAnimationSequence();\n// this.setupAppearAnimation(animator, options);\n// return animator;\n// }\n\n// /**\n// * Create a disappear animation\n// * @param options Animation options\n// * @returns The ComponentAnimator instance (not started)\n// */\n// createDisappearAnimation(options?: Record<string, any>): ComponentAnimator {\n// const animator = this.createAnimationSequence();\n// this.setupDisappearAnimation(animator, options);\n// return animator;\n// }\n\n// /**\n// * Execute an animation with the given config directly on the component\n// * @param config Animation configuration\n// * @returns This component\n// */\n// executeAnimation(config: IAnimationConfig): this {\n// this.getComponentAnimator()\n// .animate(this as unknown as IGraphic, config)\n// .start();\n// return this;\n// }\n\n// /**\n// * Set up appear animation for this component\n// * This is a placeholder method that component classes should override\n// * @param animator The ComponentAnimator to set up\n// * @param options Animation options\n// */\n// protected setupAppearAnimation(animator: ComponentAnimator, options?: Record<string, any>): void {\n// // To be overridden by concrete component classes\n// console.warn('setupAppearAnimation not implemented for this component');\n// }\n\n// /**\n// * Set up disappear animation for this component\n// * This is a placeholder method that component classes should override\n// * @param animator The ComponentAnimator to set up\n// * @param options Animation options\n// */\n// protected setupDisappearAnimation(animator: ComponentAnimator, options?: Record<string, any>): void {\n// // To be overridden by concrete component classes\n// console.warn('setupDisappearAnimation not implemented for this component');\n// }\n// }\n\n// /**\n// * Type for components that can be animated\n// */\n// export interface IAnimatableComponent {\n// animate: (preset: string, options?: Record<string, any>) => ComponentAnimator;\n// createAppearAnimation: (options?: Record<string, any>) => ComponentAnimator;\n// createDisappearAnimation: (options?: Record<string, any>) => ComponentAnimator;\n// executeAnimation: (config: IAnimationConfig) => IAnimatableComponent;\n// }\n"]}
@@ -0,0 +1,22 @@
1
+ import type { IGraphic } from '@visactor/vrender-core';
2
+ import type { IAnimationConfig } from '../executor/executor';
3
+ export declare class ComponentAnimator {
4
+ private component;
5
+ private tasks;
6
+ private started;
7
+ private completed;
8
+ private totalDuration;
9
+ private onStartCallbacks;
10
+ private onEndCallbacks;
11
+ private onUpdateCallbacks;
12
+ constructor(component: IGraphic);
13
+ animate(graphic: IGraphic, config: IAnimationConfig): ComponentAnimator;
14
+ onStart(callback: () => void): ComponentAnimator;
15
+ onEnd(callback: () => void): ComponentAnimator;
16
+ onUpdate(callback: (progress: number) => void): ComponentAnimator;
17
+ start(): ComponentAnimator;
18
+ deleteSelfAttr(key: string): void;
19
+ stop(type?: 'start' | 'end'): ComponentAnimator;
20
+ getDuration(): number;
21
+ }
22
+ export declare function createComponentAnimator(component: IGraphic): ComponentAnimator;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.createComponentAnimator = exports.ComponentAnimator = void 0;
6
+
7
+ const animate_executor_1 = require("../executor/animate-executor");
8
+
9
+ class ComponentAnimator {
10
+ constructor(component) {
11
+ this.tasks = [], this.started = !1, this.completed = 0, this.totalDuration = 0,
12
+ this.onStartCallbacks = [], this.onEndCallbacks = [], this.onUpdateCallbacks = [],
13
+ this.component = component;
14
+ }
15
+ animate(graphic, config) {
16
+ return this.started ? (console.warn("Cannot add animations after animation has started"),
17
+ this) : (this.tasks.push({
18
+ graphic: graphic,
19
+ config: config
20
+ }), this);
21
+ }
22
+ onStart(callback) {
23
+ return this.onStartCallbacks.push(callback), this;
24
+ }
25
+ onEnd(callback) {
26
+ return this.onEndCallbacks.push(callback), this;
27
+ }
28
+ onUpdate(callback) {
29
+ return this.onUpdateCallbacks.push(callback), this;
30
+ }
31
+ start() {
32
+ return this.started ? (console.warn("Animation has already started"), this) : (this.started = !0,
33
+ this.completed = 0, this.onStartCallbacks.forEach((callback => callback())), 0 === this.tasks.length ? (setTimeout((() => {
34
+ this.onEndCallbacks.forEach((callback => callback()));
35
+ }), 0), this) : (this.tasks.forEach((task => {
36
+ const executor = new animate_executor_1.AnimateExecutor(task.graphic);
37
+ executor.onEnd((() => {
38
+ this.completed++, this.completed === this.tasks.length && this.onEndCallbacks.forEach((callback => callback()));
39
+ }));
40
+ const animate = executor.executeItem(task.config, task.graphic);
41
+ task.animate = animate, animate.forEach((animate => {
42
+ this.totalDuration = Math.max(this.totalDuration, animate.getStartTime() + animate.getDuration());
43
+ }));
44
+ })), this));
45
+ }
46
+ deleteSelfAttr(key) {
47
+ this.tasks.forEach((task => {
48
+ task.animate && task.animate.forEach((animate => animate.preventAttr(key)));
49
+ }));
50
+ }
51
+ stop(type) {
52
+ return this.tasks.forEach((task => {
53
+ task.animate && task.animate.forEach((animate => animate.stop(type)));
54
+ })), this.started && this.completed !== this.tasks.length && (this.onEndCallbacks.forEach((callback => callback())),
55
+ this.completed = this.tasks.length), this;
56
+ }
57
+ getDuration() {
58
+ return this.totalDuration;
59
+ }
60
+ }
61
+
62
+ function createComponentAnimator(component) {
63
+ return new ComponentAnimator(component);
64
+ }
65
+
66
+ exports.ComponentAnimator = ComponentAnimator, exports.createComponentAnimator = createComponentAnimator;
67
+ //# sourceMappingURL=component-animator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/component/component-animator.ts"],"names":[],"mappings":";;;AACA,mEAA+D;AAgB/D,MAAa,iBAAiB;IAc5B,YAAY,SAAmB;QAZvB,UAAK,GAAqB,EAAE,CAAC;QAC7B,YAAO,GAAY,KAAK,CAAC;QACzB,cAAS,GAAW,CAAC,CAAC;QACtB,kBAAa,GAAW,CAAC,CAAC;QAC1B,qBAAgB,GAAmB,EAAE,CAAC;QACtC,mBAAc,GAAmB,EAAE,CAAC;QACpC,sBAAiB,GAAmC,EAAE,CAAC;QAO7D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IASD,OAAO,CAAC,OAAiB,EAAE,MAAwB;QACjD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,OAAO,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;YAClE,OAAO,IAAI,CAAC;SACb;QAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACd,OAAO;YACP,MAAM;SACP,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAOD,OAAO,CAAC,QAAoB;QAC1B,IAAI,CAAC,gBAAgB,CAAC,IAAI,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,CAAC,KAAK,CAAC,MAAM,CAAC;SACpC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAMD,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF;AAvJD,8CAuJC;AAOD,SAAgB,uBAAuB,CAAC,SAAmB;IACzD,OAAO,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAC1C,CAAC;AAFD,0DAEC","file":"component-animator.js","sourcesContent":["import type { IGraphic, IAnimate } from '@visactor/vrender-core';\nimport { AnimateExecutor } from '../executor/animate-executor';\nimport type { IAnimationConfig } from '../executor/executor';\n\n/**\n * Animation task that contains information about a scheduled animation\n */\ninterface IAnimationTask {\n graphic: IGraphic;\n config: IAnimationConfig;\n animate?: IAnimate[];\n}\n\n/**\n * ComponentAnimator provides a way to orchestrate animations across child elements\n * with centralized lifecycle management\n */\nexport class ComponentAnimator {\n private component: IGraphic;\n private tasks: IAnimationTask[] = [];\n private started: boolean = false;\n private completed: number = 0;\n private totalDuration: number = 0;\n private onStartCallbacks: (() => void)[] = [];\n private onEndCallbacks: (() => void)[] = [];\n private onUpdateCallbacks: ((progress: number) => void)[] = [];\n\n /**\n * Creates a new ComponentAnimator\n * @param component The component or group containing elements to animate\n */\n constructor(component: IGraphic) {\n this.component = component;\n }\n\n /**\n * Add animation for a specific graphic element\n * @param graphic The graphic element to animate\n * @param config Animation configuration\n * @param delay Optional delay before starting this animation (in ms)\n * @returns This ComponentAnimator for chaining\n */\n animate(graphic: IGraphic, config: IAnimationConfig): ComponentAnimator {\n if (this.started) {\n console.warn('Cannot add animations after animation has started');\n return this;\n }\n\n this.tasks.push({\n graphic,\n config\n });\n\n return this;\n }\n\n /**\n * Add a callback to be called when animation starts\n * @param callback Function to call when animation starts\n * @returns This ComponentAnimator for chaining\n */\n onStart(callback: () => void): ComponentAnimator {\n this.onStartCallbacks.push(callback);\n return this;\n }\n\n /**\n * Add a callback to be called when animation ends\n * @param callback Function to call when animation ends\n * @returns This ComponentAnimator for chaining\n */\n onEnd(callback: () => void): ComponentAnimator {\n this.onEndCallbacks.push(callback);\n return this;\n }\n\n /**\n * Add a callback to be called when animation updates\n * @param callback Function to call when animation updates (receives progress from 0 to 1)\n * @returns This ComponentAnimator for chaining\n */\n onUpdate(callback: (progress: number) => void): ComponentAnimator {\n this.onUpdateCallbacks.push(callback);\n return this;\n }\n\n /**\n * Start all animations in this component animation\n * @returns This ComponentAnimator\n */\n start(): ComponentAnimator {\n if (this.started) {\n console.warn('Animation has already started');\n return this;\n }\n\n this.started = true;\n this.completed = 0;\n\n // Call onStart callbacks\n this.onStartCallbacks.forEach(callback => callback());\n\n // Empty animation case\n if (this.tasks.length === 0) {\n setTimeout(() => {\n this.onEndCallbacks.forEach(callback => callback());\n }, 0);\n return this;\n }\n\n // Start all animations with their specified delays\n this.tasks.forEach(task => {\n const executor = new AnimateExecutor(task.graphic);\n\n // Set up callbacks to track completion\n executor.onEnd(() => {\n this.completed++;\n if (this.completed === this.tasks.length) {\n this.onEndCallbacks.forEach(callback => callback());\n }\n });\n\n const animate = executor.executeItem(task.config, task.graphic);\n task.animate = animate;\n animate.forEach(animate => {\n this.totalDuration = Math.max(this.totalDuration, animate.getStartTime() + animate.getDuration());\n });\n });\n\n return this;\n }\n\n deleteSelfAttr(key: string): void {\n this.tasks.forEach(task => {\n if (task.animate) {\n task.animate.forEach(animate => animate.preventAttr(key));\n }\n });\n }\n\n /**\n * Stop all animations in this component animation\n * @param type Whether to jump to the end state or start state\n * @returns This ComponentAnimator\n */\n stop(type?: 'start' | 'end'): ComponentAnimator {\n this.tasks.forEach(task => {\n if (task.animate) {\n task.animate.forEach(animate => animate.stop(type));\n }\n });\n\n // If not already completed, call end callbacks\n if (this.started && this.completed !== this.tasks.length) {\n this.onEndCallbacks.forEach(callback => callback());\n this.completed = this.tasks.length;\n }\n\n return this;\n }\n\n /**\n * Get total duration of all animations including delays\n * @returns Total duration in milliseconds\n */\n getDuration(): number {\n return this.totalDuration;\n }\n}\n\n/**\n * Factory function to create a ComponentAnimator for a component\n * @param component The component or group to animate\n * @returns A new ComponentAnimator instance\n */\nexport function createComponentAnimator(component: IGraphic): ComponentAnimator {\n return new ComponentAnimator(component);\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from './component-animator';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
4
+ void 0 === k2 && (k2 = k);
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
7
+ enumerable: !0,
8
+ get: function() {
9
+ return m[k];
10
+ }
11
+ }), Object.defineProperty(o, k2, desc);
12
+ } : function(o, m, k, k2) {
13
+ void 0 === k2 && (k2 = k), o[k2] = m[k];
14
+ }), __exportStar = this && this.__exportStar || function(m, exports) {
15
+ for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
16
+ };
17
+
18
+ Object.defineProperty(exports, "__esModule", {
19
+ value: !0
20
+ }), __exportStar(require("./component-animator"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/component/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC","file":"index.js","sourcesContent":["export * from './component-animator';\n// export * from './component-animate-extension';\n"]}
@@ -0,0 +1,2 @@
1
+ import type { IAnimateConfig } from '@visactor/vrender-core';
2
+ export declare const DefaultMorphingAnimateConfig: IAnimateConfig;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.DefaultMorphingAnimateConfig = void 0, exports.DefaultMorphingAnimateConfig = {
6
+ duration: 1e3,
7
+ easing: "quadInOut"
8
+ };
9
+ //# sourceMappingURL=morphing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/morphing.ts"],"names":[],"mappings":";;;AAEa,QAAA,4BAA4B,GAAmB;IAC1D,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,WAAW;CACpB,CAAC","file":"morphing.js","sourcesContent":["import type { IAnimateConfig } from '@visactor/vrender-core';\n\nexport const DefaultMorphingAnimateConfig: IAnimateConfig = {\n duration: 1000,\n easing: 'quadInOut'\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { IGraphic, IGroup } from '@visactor/vrender-core';
2
+ import { type EasingType } from '@visactor/vrender-core';
2
3
  import { ACustomAnimate } from './custom-animate';
3
- import type { EasingType } from '../intreface/easing';
4
4
  export declare class ClipGraphicAnimate extends ACustomAnimate<any> {
5
5
  private _group?;
6
6
  private _clipGraphic?;
@@ -8,11 +8,11 @@ const vrender_core_1 = require("@visactor/vrender-core"), custom_animate_1 = req
8
8
 
9
9
  class ClipGraphicAnimate extends custom_animate_1.ACustomAnimate {
10
10
  constructor(from, to, duration, easing, params) {
11
- super(null, null, duration, easing, params), this.clipFromAttribute = from, this.clipToAttribute = to,
11
+ super(null, {}, duration, easing, params), this.clipFromAttribute = from, this.clipToAttribute = to,
12
12
  this._group = null == params ? void 0 : params.group, this._clipGraphic = null == params ? void 0 : params.clipGraphic;
13
13
  }
14
14
  onBind() {
15
- this._group && this._clipGraphic && (this._lastClip = this._group.attribute.clip,
15
+ super.onBind(), this._group && this._clipGraphic && (this._lastClip = this._group.attribute.clip,
16
16
  this._lastPath = this._group.attribute.path, this._group.setAttributes({
17
17
  clip: !0,
18
18
  path: [ this._clipGraphic ]