@visactor/vrender-animate 0.22.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/README.md +177 -0
  2. package/cjs/animate-extension.d.ts +15 -0
  3. package/cjs/animate-extension.js +46 -0
  4. package/cjs/animate-extension.js.map +1 -0
  5. package/cjs/animate.d.ts +71 -0
  6. package/cjs/animate.js +210 -0
  7. package/cjs/animate.js.map +1 -0
  8. package/cjs/custom/clip-graphic.d.ts +53 -0
  9. package/cjs/custom/clip-graphic.js +146 -0
  10. package/cjs/custom/clip-graphic.js.map +1 -0
  11. package/cjs/custom/clip.d.ts +13 -0
  12. package/cjs/custom/clip.js +24 -0
  13. package/cjs/custom/clip.js.map +1 -0
  14. package/cjs/custom/common.d.ts +22 -0
  15. package/cjs/custom/common.js +58 -0
  16. package/cjs/custom/common.js.map +1 -0
  17. package/cjs/custom/custom-animate.d.ts +15 -0
  18. package/cjs/custom/custom-animate.js +25 -0
  19. package/cjs/custom/custom-animate.js.map +1 -0
  20. package/cjs/custom/fade.d.ts +13 -0
  21. package/cjs/custom/fade.js +24 -0
  22. package/cjs/custom/fade.js.map +1 -0
  23. package/cjs/custom/group-fade.d.ts +16 -0
  24. package/cjs/custom/group-fade.js +66 -0
  25. package/cjs/custom/group-fade.js.map +1 -0
  26. package/cjs/custom/growAngle.d.ts +37 -0
  27. package/cjs/custom/growAngle.js +140 -0
  28. package/cjs/custom/growAngle.js.map +1 -0
  29. package/cjs/custom/growCenter.d.ts +17 -0
  30. package/cjs/custom/growCenter.js +161 -0
  31. package/cjs/custom/growCenter.js.map +1 -0
  32. package/cjs/custom/growHeight.d.ts +36 -0
  33. package/cjs/custom/growHeight.js +154 -0
  34. package/cjs/custom/growHeight.js.map +1 -0
  35. package/cjs/custom/growPoints.d.ts +52 -0
  36. package/cjs/custom/growPoints.js +227 -0
  37. package/cjs/custom/growPoints.js.map +1 -0
  38. package/cjs/custom/growRadius.d.ts +41 -0
  39. package/cjs/custom/growRadius.js +113 -0
  40. package/cjs/custom/growRadius.js.map +1 -0
  41. package/cjs/custom/growWidth.d.ts +36 -0
  42. package/cjs/custom/growWidth.js +154 -0
  43. package/cjs/custom/growWidth.js.map +1 -0
  44. package/cjs/custom/input-text.d.ts +29 -0
  45. package/cjs/custom/input-text.js +45 -0
  46. package/cjs/custom/input-text.js.map +1 -0
  47. package/cjs/custom/number.d.ts +25 -0
  48. package/cjs/custom/number.js +102 -0
  49. package/cjs/custom/number.js.map +1 -0
  50. package/cjs/custom/register.d.ts +1 -0
  51. package/cjs/custom/register.js +35 -0
  52. package/cjs/custom/register.js.map +1 -0
  53. package/cjs/custom/scale-in.d.ts +13 -0
  54. package/cjs/custom/scale-in.js +57 -0
  55. package/cjs/custom/scale-in.js.map +1 -0
  56. package/cjs/custom/scale.d.ts +20 -0
  57. package/cjs/custom/scale.js +106 -0
  58. package/cjs/custom/scale.js.map +1 -0
  59. package/cjs/custom/sphere.d.ts +20 -0
  60. package/cjs/custom/sphere.js +26 -0
  61. package/cjs/custom/sphere.js.map +1 -0
  62. package/cjs/custom/state.d.ts +13 -0
  63. package/cjs/custom/state.js +25 -0
  64. package/cjs/custom/state.js.map +1 -0
  65. package/cjs/custom/tag-points.d.ts +26 -0
  66. package/cjs/custom/tag-points.js +81 -0
  67. package/cjs/custom/tag-points.js.map +1 -0
  68. package/cjs/custom/update.d.ts +14 -0
  69. package/cjs/custom/update.js +26 -0
  70. package/cjs/custom/update.js.map +1 -0
  71. package/cjs/executor/animate-executor.d.ts +36 -0
  72. package/cjs/executor/animate-executor.js +177 -0
  73. package/cjs/executor/animate-executor.js.map +1 -0
  74. package/cjs/executor/executor.d.ts +69 -0
  75. package/cjs/executor/executor.js +6 -0
  76. package/cjs/executor/executor.js.map +1 -0
  77. package/cjs/index.d.ts +25 -0
  78. package/cjs/index.js +214 -0
  79. package/cjs/index.js.map +1 -0
  80. package/cjs/interpolate/executor.d.ts +66 -0
  81. package/cjs/interpolate/executor.js +6 -0
  82. package/cjs/interpolate/executor.js.map +1 -0
  83. package/cjs/interpolate/number.d.ts +1 -0
  84. package/cjs/interpolate/number.js +10 -0
  85. package/cjs/interpolate/number.js.map +1 -0
  86. package/cjs/interpolate/store.d.ts +32 -0
  87. package/cjs/interpolate/store.js +96 -0
  88. package/cjs/interpolate/store.js.map +1 -0
  89. package/cjs/intreface/animate.d.ts +91 -0
  90. package/cjs/intreface/animate.js +10 -0
  91. package/cjs/intreface/animate.js.map +1 -0
  92. package/cjs/intreface/easing.d.ts +3 -0
  93. package/cjs/intreface/easing.js +6 -0
  94. package/cjs/intreface/easing.js.map +1 -0
  95. package/cjs/intreface/state.d.ts +35 -0
  96. package/cjs/intreface/state.js +6 -0
  97. package/cjs/intreface/state.js.map +1 -0
  98. package/cjs/intreface/ticker.d.ts +37 -0
  99. package/cjs/intreface/ticker.js +10 -0
  100. package/cjs/intreface/ticker.js.map +1 -0
  101. package/cjs/intreface/timeline.d.ts +17 -0
  102. package/cjs/intreface/timeline.js +6 -0
  103. package/cjs/intreface/timeline.js.map +1 -0
  104. package/cjs/intreface/type.d.ts +13 -0
  105. package/cjs/intreface/type.js +15 -0
  106. package/cjs/intreface/type.js.map +1 -0
  107. package/cjs/register.d.ts +1 -0
  108. package/cjs/register.js +19 -0
  109. package/cjs/register.js.map +1 -0
  110. package/cjs/state/animation-state-machine.d.ts +22 -0
  111. package/cjs/state/animation-state-machine.js +53 -0
  112. package/cjs/state/animation-state-machine.js.map +1 -0
  113. package/cjs/state/animation-state-queue.d.ts +24 -0
  114. package/cjs/state/animation-state-queue.js +66 -0
  115. package/cjs/state/animation-state-queue.js.map +1 -0
  116. package/cjs/state/animation-state-registry.d.ts +14 -0
  117. package/cjs/state/animation-state-registry.js +53 -0
  118. package/cjs/state/animation-state-registry.js.map +1 -0
  119. package/cjs/state/animation-state.d.ts +25 -0
  120. package/cjs/state/animation-state.js +80 -0
  121. package/cjs/state/animation-state.js.map +1 -0
  122. package/cjs/state/animation-states-registry.d.ts +17 -0
  123. package/cjs/state/animation-states-registry.js +95 -0
  124. package/cjs/state/animation-states-registry.js.map +1 -0
  125. package/cjs/state/graphic-extension.d.ts +12 -0
  126. package/cjs/state/graphic-extension.js +37 -0
  127. package/cjs/state/graphic-extension.js.map +1 -0
  128. package/cjs/state/index.d.ts +3 -0
  129. package/cjs/state/index.js +22 -0
  130. package/cjs/state/index.js.map +1 -0
  131. package/cjs/state/types.d.ts +11 -0
  132. package/cjs/state/types.js +6 -0
  133. package/cjs/state/types.js.map +1 -0
  134. package/cjs/step.d.ts +49 -0
  135. package/cjs/step.js +124 -0
  136. package/cjs/step.js.map +1 -0
  137. package/cjs/ticker/default-ticker.d.ts +39 -0
  138. package/cjs/ticker/default-ticker.js +133 -0
  139. package/cjs/ticker/default-ticker.js.map +1 -0
  140. package/cjs/ticker/manual-ticker.d.ts +6 -0
  141. package/cjs/ticker/manual-ticker.js +37 -0
  142. package/cjs/ticker/manual-ticker.js.map +1 -0
  143. package/cjs/timeline.d.ts +34 -0
  144. package/cjs/timeline.js +84 -0
  145. package/cjs/timeline.js.map +1 -0
  146. package/cjs/utils/easing-func.d.ts +1 -0
  147. package/cjs/utils/easing-func.js +16 -0
  148. package/cjs/utils/easing-func.js.map +1 -0
  149. package/cjs/utils/easing.d.ts +49 -0
  150. package/cjs/utils/easing.js +141 -0
  151. package/cjs/utils/easing.js.map +1 -0
  152. package/dist/index.es.js +3824 -0
  153. package/es/animate-extension.d.ts +15 -0
  154. package/es/animate-extension.js +42 -0
  155. package/es/animate-extension.js.map +1 -0
  156. package/es/animate.d.ts +71 -0
  157. package/es/animate.js +207 -0
  158. package/es/animate.js.map +1 -0
  159. package/es/custom/clip-graphic.d.ts +53 -0
  160. package/es/custom/clip-graphic.js +134 -0
  161. package/es/custom/clip-graphic.js.map +1 -0
  162. package/es/custom/clip.d.ts +13 -0
  163. package/es/custom/clip.js +14 -0
  164. package/es/custom/clip.js.map +1 -0
  165. package/es/custom/common.d.ts +22 -0
  166. package/es/custom/common.js +48 -0
  167. package/es/custom/common.js.map +1 -0
  168. package/es/custom/custom-animate.d.ts +15 -0
  169. package/es/custom/custom-animate.js +17 -0
  170. package/es/custom/custom-animate.js.map +1 -0
  171. package/es/custom/fade.d.ts +13 -0
  172. package/es/custom/fade.js +14 -0
  173. package/es/custom/fade.js.map +1 -0
  174. package/es/custom/group-fade.d.ts +16 -0
  175. package/es/custom/group-fade.js +56 -0
  176. package/es/custom/group-fade.js.map +1 -0
  177. package/es/custom/growAngle.d.ts +37 -0
  178. package/es/custom/growAngle.js +132 -0
  179. package/es/custom/growAngle.js.map +1 -0
  180. package/es/custom/growCenter.d.ts +17 -0
  181. package/es/custom/growCenter.js +155 -0
  182. package/es/custom/growCenter.js.map +1 -0
  183. package/es/custom/growHeight.d.ts +36 -0
  184. package/es/custom/growHeight.js +144 -0
  185. package/es/custom/growHeight.js.map +1 -0
  186. package/es/custom/growPoints.d.ts +52 -0
  187. package/es/custom/growPoints.js +219 -0
  188. package/es/custom/growPoints.js.map +1 -0
  189. package/es/custom/growRadius.d.ts +41 -0
  190. package/es/custom/growRadius.js +105 -0
  191. package/es/custom/growRadius.js.map +1 -0
  192. package/es/custom/growWidth.d.ts +36 -0
  193. package/es/custom/growWidth.js +144 -0
  194. package/es/custom/growWidth.js.map +1 -0
  195. package/es/custom/input-text.d.ts +29 -0
  196. package/es/custom/input-text.js +37 -0
  197. package/es/custom/input-text.js.map +1 -0
  198. package/es/custom/number.d.ts +25 -0
  199. package/es/custom/number.js +94 -0
  200. package/es/custom/number.js.map +1 -0
  201. package/es/custom/register.d.ts +1 -0
  202. package/es/custom/register.js +39 -0
  203. package/es/custom/register.js.map +1 -0
  204. package/es/custom/scale-in.d.ts +13 -0
  205. package/es/custom/scale-in.js +49 -0
  206. package/es/custom/scale-in.js.map +1 -0
  207. package/es/custom/scale.d.ts +20 -0
  208. package/es/custom/scale.js +96 -0
  209. package/es/custom/scale.js.map +1 -0
  210. package/es/custom/sphere.d.ts +20 -0
  211. package/es/custom/sphere.js +20 -0
  212. package/es/custom/sphere.js.map +1 -0
  213. package/es/custom/state.d.ts +13 -0
  214. package/es/custom/state.js +17 -0
  215. package/es/custom/state.js.map +1 -0
  216. package/es/custom/tag-points.d.ts +26 -0
  217. package/es/custom/tag-points.js +77 -0
  218. package/es/custom/tag-points.js.map +1 -0
  219. package/es/custom/update.d.ts +14 -0
  220. package/es/custom/update.js +18 -0
  221. package/es/custom/update.js.map +1 -0
  222. package/es/executor/animate-executor.d.ts +36 -0
  223. package/es/executor/animate-executor.js +169 -0
  224. package/es/executor/animate-executor.js.map +1 -0
  225. package/es/executor/executor.d.ts +69 -0
  226. package/es/executor/executor.js +2 -0
  227. package/es/executor/executor.js.map +1 -0
  228. package/es/index.d.ts +25 -0
  229. package/es/index.js +50 -0
  230. package/es/index.js.map +1 -0
  231. package/es/interpolate/executor.d.ts +66 -0
  232. package/es/interpolate/executor.js +2 -0
  233. package/es/interpolate/executor.js.map +1 -0
  234. package/es/interpolate/number.d.ts +1 -0
  235. package/es/interpolate/number.js +4 -0
  236. package/es/interpolate/number.js.map +1 -0
  237. package/es/interpolate/store.d.ts +32 -0
  238. package/es/interpolate/store.js +88 -0
  239. package/es/interpolate/store.js.map +1 -0
  240. package/es/intreface/animate.d.ts +91 -0
  241. package/es/intreface/animate.js +6 -0
  242. package/es/intreface/animate.js.map +1 -0
  243. package/es/intreface/easing.d.ts +3 -0
  244. package/es/intreface/easing.js +2 -0
  245. package/es/intreface/easing.js.map +1 -0
  246. package/es/intreface/state.d.ts +35 -0
  247. package/es/intreface/state.js +2 -0
  248. package/es/intreface/state.js.map +1 -0
  249. package/es/intreface/ticker.d.ts +37 -0
  250. package/es/intreface/ticker.js +6 -0
  251. package/es/intreface/ticker.js.map +1 -0
  252. package/es/intreface/timeline.d.ts +17 -0
  253. package/es/intreface/timeline.js +2 -0
  254. package/es/intreface/timeline.js.map +1 -0
  255. package/es/intreface/type.d.ts +13 -0
  256. package/es/intreface/type.js +14 -0
  257. package/es/intreface/type.js.map +1 -0
  258. package/es/register.d.ts +1 -0
  259. package/es/register.js +20 -0
  260. package/es/register.js.map +1 -0
  261. package/es/state/animation-state-machine.d.ts +22 -0
  262. package/es/state/animation-state-machine.js +47 -0
  263. package/es/state/animation-state-machine.js.map +1 -0
  264. package/es/state/animation-state-queue.d.ts +24 -0
  265. package/es/state/animation-state-queue.js +58 -0
  266. package/es/state/animation-state-queue.js.map +1 -0
  267. package/es/state/animation-state-registry.d.ts +14 -0
  268. package/es/state/animation-state-registry.js +45 -0
  269. package/es/state/animation-state-registry.js.map +1 -0
  270. package/es/state/animation-state.d.ts +25 -0
  271. package/es/state/animation-state.js +72 -0
  272. package/es/state/animation-state.js.map +1 -0
  273. package/es/state/animation-states-registry.d.ts +17 -0
  274. package/es/state/animation-states-registry.js +87 -0
  275. package/es/state/animation-states-registry.js.map +1 -0
  276. package/es/state/graphic-extension.d.ts +12 -0
  277. package/es/state/graphic-extension.js +29 -0
  278. package/es/state/graphic-extension.js.map +1 -0
  279. package/es/state/index.d.ts +3 -0
  280. package/es/state/index.js +6 -0
  281. package/es/state/index.js.map +1 -0
  282. package/es/state/types.d.ts +11 -0
  283. package/es/state/types.js +2 -0
  284. package/es/state/types.js.map +1 -0
  285. package/es/step.d.ts +49 -0
  286. package/es/step.js +120 -0
  287. package/es/step.js.map +1 -0
  288. package/es/ticker/default-ticker.d.ts +39 -0
  289. package/es/ticker/default-ticker.js +129 -0
  290. package/es/ticker/default-ticker.js.map +1 -0
  291. package/es/ticker/manual-ticker.d.ts +6 -0
  292. package/es/ticker/manual-ticker.js +29 -0
  293. package/es/ticker/manual-ticker.js.map +1 -0
  294. package/es/timeline.d.ts +34 -0
  295. package/es/timeline.js +79 -0
  296. package/es/timeline.js.map +1 -0
  297. package/es/utils/easing-func.d.ts +1 -0
  298. package/es/utils/easing-func.js +8 -0
  299. package/es/utils/easing-func.js.map +1 -0
  300. package/es/utils/easing.d.ts +49 -0
  301. package/es/utils/easing.js +134 -0
  302. package/es/utils/easing.js.map +1 -0
  303. package/package.json +72 -0
@@ -0,0 +1,3824 @@
1
+ import { interpolateColor, interpolatePureColorArrayToStr, ColorStore, ColorType, Generator, AnimateStatus as AnimateStatus$1, PerformanceRAF, application, CustomPath2D, CurveContext, Graphic, AttributeUpdateType, pointInterpolation } from '@visactor/vrender-core';
2
+ import { pi2, isString, EventEmitter, cloneDeep, isArray, isFunction, mixin, isValidNumber, clamp, Point, pi, isNumber, isValid, isNil } from '@visactor/vutils';
3
+
4
+ var AnimateMode;
5
+ (function (AnimateMode) {
6
+ AnimateMode[AnimateMode["NORMAL"] = 0] = "NORMAL";
7
+ AnimateMode[AnimateMode["SET_ATTR_IMMEDIATELY"] = 1] = "SET_ATTR_IMMEDIATELY";
8
+ })(AnimateMode || (AnimateMode = {}));
9
+
10
+ var AnimateStepType;
11
+ (function (AnimateStepType) {
12
+ AnimateStepType["wait"] = "wait";
13
+ AnimateStepType["from"] = "from";
14
+ AnimateStepType["to"] = "to";
15
+ AnimateStepType["customAnimate"] = "customAnimate";
16
+ })(AnimateStepType || (AnimateStepType = {}));
17
+ var AnimateStatus;
18
+ (function (AnimateStatus) {
19
+ AnimateStatus[AnimateStatus["INITIAL"] = 0] = "INITIAL";
20
+ AnimateStatus[AnimateStatus["RUNNING"] = 1] = "RUNNING";
21
+ AnimateStatus[AnimateStatus["PAUSED"] = 2] = "PAUSED";
22
+ AnimateStatus[AnimateStatus["END"] = 3] = "END";
23
+ })(AnimateStatus || (AnimateStatus = {}));
24
+
25
+ class Easing {
26
+ constructor() {
27
+ }
28
+ static linear(t) {
29
+ return t;
30
+ }
31
+ static none() {
32
+ return this.linear;
33
+ }
34
+ static get(amount) {
35
+ if (amount < -1) {
36
+ amount = -1;
37
+ }
38
+ else if (amount > 1) {
39
+ amount = 1;
40
+ }
41
+ return function (t) {
42
+ if (amount === 0) {
43
+ return t;
44
+ }
45
+ if (amount < 0) {
46
+ return t * (t * -amount + 1 + amount);
47
+ }
48
+ return t * ((2 - t) * amount + (1 - amount));
49
+ };
50
+ }
51
+ static getPowIn(pow) {
52
+ return function (t) {
53
+ return Math.pow(t, pow);
54
+ };
55
+ }
56
+ static getPowOut(pow) {
57
+ return function (t) {
58
+ return 1 - Math.pow(1 - t, pow);
59
+ };
60
+ }
61
+ static getPowInOut(pow) {
62
+ return function (t) {
63
+ if ((t *= 2) < 1) {
64
+ return 0.5 * Math.pow(t, pow);
65
+ }
66
+ return 1 - 0.5 * Math.abs(Math.pow(2 - t, pow));
67
+ };
68
+ }
69
+ static getBackIn(amount) {
70
+ return function (t) {
71
+ return t * t * ((amount + 1) * t - amount);
72
+ };
73
+ }
74
+ static getBackOut(amount) {
75
+ return function (t) {
76
+ return --t * t * ((amount + 1) * t + amount) + 1;
77
+ };
78
+ }
79
+ static getBackInOut(amount) {
80
+ amount *= 1.525;
81
+ return function (t) {
82
+ if ((t *= 2) < 1) {
83
+ return 0.5 * (t * t * ((amount + 1) * t - amount));
84
+ }
85
+ return 0.5 * ((t -= 2) * t * ((amount + 1) * t + amount) + 2);
86
+ };
87
+ }
88
+ static sineIn(t) {
89
+ return 1 - Math.cos((t * Math.PI) / 2);
90
+ }
91
+ static sineOut(t) {
92
+ return Math.sin((t * Math.PI) / 2);
93
+ }
94
+ static sineInOut(t) {
95
+ return -(Math.cos(Math.PI * t) - 1) / 2;
96
+ }
97
+ static expoIn(t) {
98
+ return t === 0 ? 0 : Math.pow(2, 10 * t - 10);
99
+ }
100
+ static expoOut(t) {
101
+ return t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
102
+ }
103
+ static expoInOut(t) {
104
+ return t === 0 ? 0 : t === 1 ? 1 : t < 0.5 ? Math.pow(2, 20 * t - 10) / 2 : (2 - Math.pow(2, -20 * t + 10)) / 2;
105
+ }
106
+ static circIn(t) {
107
+ return -(Math.sqrt(1 - t * t) - 1);
108
+ }
109
+ static circOut(t) {
110
+ return Math.sqrt(1 - --t * t);
111
+ }
112
+ static circInOut(t) {
113
+ if ((t *= 2) < 1) {
114
+ return -0.5 * (Math.sqrt(1 - t * t) - 1);
115
+ }
116
+ return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
117
+ }
118
+ static bounceOut(t) {
119
+ if (t < 1 / 2.75) {
120
+ return 7.5625 * t * t;
121
+ }
122
+ else if (t < 2 / 2.75) {
123
+ return 7.5625 * (t -= 1.5 / 2.75) * t + 0.75;
124
+ }
125
+ else if (t < 2.5 / 2.75) {
126
+ return 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375;
127
+ }
128
+ return 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375;
129
+ }
130
+ static bounceIn(t) {
131
+ return 1 - Easing.bounceOut(1 - t);
132
+ }
133
+ static bounceInOut(t) {
134
+ if (t < 0.5) {
135
+ return Easing.bounceIn(t * 2) * 0.5;
136
+ }
137
+ return Easing.bounceOut(t * 2 - 1) * 0.5 + 0.5;
138
+ }
139
+ static getElasticIn(amplitude, period) {
140
+ return function (t) {
141
+ if (t === 0 || t === 1) {
142
+ return t;
143
+ }
144
+ const s = (period / pi2) * Math.asin(1 / amplitude);
145
+ return -(amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin(((t - s) * pi2) / period));
146
+ };
147
+ }
148
+ static getElasticOut(amplitude, period) {
149
+ return function (t) {
150
+ if (t === 0 || t === 1) {
151
+ return t;
152
+ }
153
+ const s = (period / pi2) * Math.asin(1 / amplitude);
154
+ return amplitude * Math.pow(2, -10 * t) * Math.sin(((t - s) * pi2) / period) + 1;
155
+ };
156
+ }
157
+ static getElasticInOut(amplitude, period) {
158
+ return function (t) {
159
+ const s = (period / pi2) * Math.asin(1 / amplitude);
160
+ if ((t *= 2) < 1) {
161
+ return -0.5 * (amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin(((t - s) * pi2) / period));
162
+ }
163
+ return amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin(((t - s) * pi2) / period) * 0.5 + 1;
164
+ };
165
+ }
166
+ static registerFunc(name, func) {
167
+ Easing[name] = func;
168
+ }
169
+ }
170
+ Easing.quadIn = Easing.getPowIn(2);
171
+ Easing.quadOut = Easing.getPowOut(2);
172
+ Easing.quadInOut = Easing.getPowInOut(2);
173
+ Easing.cubicIn = Easing.getPowIn(3);
174
+ Easing.cubicOut = Easing.getPowOut(3);
175
+ Easing.cubicInOut = Easing.getPowInOut(3);
176
+ Easing.quartIn = Easing.getPowIn(4);
177
+ Easing.quartOut = Easing.getPowOut(4);
178
+ Easing.quartInOut = Easing.getPowInOut(4);
179
+ Easing.quintIn = Easing.getPowIn(5);
180
+ Easing.quintOut = Easing.getPowOut(5);
181
+ Easing.quintInOut = Easing.getPowInOut(5);
182
+ Easing.backIn = Easing.getBackIn(1.7);
183
+ Easing.backOut = Easing.getBackOut(1.7);
184
+ Easing.backInOut = Easing.getBackInOut(1.7);
185
+ Easing.elasticIn = Easing.getElasticIn(1, 0.3);
186
+ Easing.elasticOut = Easing.getElasticOut(1, 0.3);
187
+ Easing.elasticInOut = Easing.getElasticInOut(1, 0.3 * 1.5);
188
+ Easing.easeInOutQuad = (t) => {
189
+ if ((t /= 0.5) < 1) {
190
+ return 0.5 * Math.pow(t, 2);
191
+ }
192
+ return -0.5 * ((t -= 2) * t - 2);
193
+ };
194
+ Easing.easeOutElastic = (x) => {
195
+ const c4 = (2 * Math.PI) / 3;
196
+ return x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1;
197
+ };
198
+ Easing.easeInOutElastic = (x) => {
199
+ const c5 = (2 * Math.PI) / 4.5;
200
+ return x === 0
201
+ ? 0
202
+ : x === 1
203
+ ? 1
204
+ : x < 0.5
205
+ ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2
206
+ : (Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5)) / 2 + 1;
207
+ };
208
+ function flicker(t, n) {
209
+ const step = 1 / n;
210
+ let flag = 1;
211
+ while (t > step) {
212
+ t -= step;
213
+ flag *= -1;
214
+ }
215
+ const v = (flag * t) / step;
216
+ return v > 0 ? v : 1 + v;
217
+ }
218
+ for (let i = 0; i < 10; i++) {
219
+ Easing[`flicker${i}`] = (t) => flicker(t, i);
220
+ }
221
+ for (let i = 2; i < 10; i++) {
222
+ Easing[`aIn${i}`] = (t) => i * t * t + (1 - i) * t;
223
+ }
224
+
225
+ function interpolateNumber(from, to, ratio) {
226
+ return from + (to - from) * ratio;
227
+ }
228
+
229
+ class InterpolateUpdateStore {
230
+ constructor() {
231
+ this.opacity = (key, from, to, ratio, step, target) => {
232
+ target.attribute.opacity = interpolateNumber(from, to, ratio);
233
+ };
234
+ this.fillOpacity = (key, from, to, ratio, step, target) => {
235
+ target.attribute.fillOpacity = interpolateNumber(from, to, ratio);
236
+ };
237
+ this.strokeOpacity = (key, from, to, ratio, step, target) => {
238
+ target.attribute.strokeOpacity = interpolateNumber(from, to, ratio);
239
+ };
240
+ this.zIndex = (key, from, to, ratio, step, target) => {
241
+ target.attribute.zIndex = interpolateNumber(from, to, ratio);
242
+ };
243
+ this.backgroundOpacity = (key, from, to, ratio, step, target) => {
244
+ target.attribute.backgroundOpacity = interpolateNumber(from, to, ratio);
245
+ };
246
+ this.shadowOffsetX = (key, from, to, ratio, step, target) => {
247
+ target.attribute.shadowOffsetX = interpolateNumber(from, to, ratio);
248
+ };
249
+ this.shadowOffsetY = (key, from, to, ratio, step, target) => {
250
+ target.attribute.shadowOffsetY = interpolateNumber(from, to, ratio);
251
+ };
252
+ this.shadowBlur = (key, from, to, ratio, step, target) => {
253
+ target.attribute.shadowBlur = interpolateNumber(from, to, ratio);
254
+ };
255
+ this.fill = (key, from, to, ratio, step, target) => {
256
+ target.attribute.fill = interpolateColor(from, to, ratio, false);
257
+ };
258
+ this.fillPure = (key, from, to, ratio, step, target) => {
259
+ target.attribute.fill = interpolatePureColorArrayToStr(step.fromParsedProps.fill, step.toParsedProps.fill, ratio);
260
+ };
261
+ this.stroke = (key, from, to, ratio, step, target) => {
262
+ target.attribute.stroke = interpolateColor(from, to, ratio, false);
263
+ };
264
+ this.strokePure = (key, from, to, ratio, step, target) => {
265
+ target.attribute.stroke = interpolatePureColorArrayToStr(step.fromParsedProps.stroke, step.toParsedProps.stroke, ratio);
266
+ };
267
+ this.width = (key, from, to, ratio, step, target) => {
268
+ target.attribute.width = interpolateNumber(from, to, ratio);
269
+ target.addUpdateBoundTag();
270
+ };
271
+ this.height = (key, from, to, ratio, step, target) => {
272
+ target.attribute.height = interpolateNumber(from, to, ratio);
273
+ target.addUpdateBoundTag();
274
+ };
275
+ this.x = (key, from, to, ratio, step, target) => {
276
+ target.attribute.x = interpolateNumber(from, to, ratio);
277
+ target.addUpdateBoundTag();
278
+ target.addUpdatePositionTag();
279
+ };
280
+ this.y = (key, from, to, ratio, step, target) => {
281
+ target.attribute.y = interpolateNumber(from, to, ratio);
282
+ target.addUpdateBoundTag();
283
+ target.addUpdatePositionTag();
284
+ };
285
+ this.angle = (key, from, to, ratio, step, target) => {
286
+ target.attribute.angle = interpolateNumber(from, to, ratio);
287
+ target.addUpdateBoundTag();
288
+ target.addUpdatePositionTag();
289
+ };
290
+ this.scaleX = (key, from, to, ratio, step, target) => {
291
+ target.attribute.scaleX = interpolateNumber(from, to, ratio);
292
+ target.addUpdateBoundTag();
293
+ target.addUpdatePositionTag();
294
+ };
295
+ this.scaleY = (key, from, to, ratio, step, target) => {
296
+ target.attribute.scaleY = interpolateNumber(from, to, ratio);
297
+ target.addUpdateBoundTag();
298
+ target.addUpdatePositionTag();
299
+ };
300
+ this.lineWidth = (key, from, to, ratio, step, target) => {
301
+ target.attribute.lineWidth = interpolateNumber(from, to, ratio);
302
+ target.addUpdateBoundTag();
303
+ };
304
+ this.startAngle = (key, from, to, ratio, step, target) => {
305
+ target.attribute.startAngle = interpolateNumber(from, to, ratio);
306
+ target.addUpdateBoundTag();
307
+ };
308
+ this.endAngle = (key, from, to, ratio, step, target) => {
309
+ target.attribute.endAngle = interpolateNumber(from, to, ratio);
310
+ target.addUpdateBoundTag();
311
+ };
312
+ this.radius = (key, from, to, ratio, step, target) => {
313
+ target.attribute.radius = interpolateNumber(from, to, ratio);
314
+ target.addUpdateBoundTag();
315
+ };
316
+ this.outerRadius = (key, from, to, ratio, step, target) => {
317
+ target.attribute.outerRadius = interpolateNumber(from, to, ratio);
318
+ target.addUpdateBoundTag();
319
+ };
320
+ this.innerRadius = (key, from, to, ratio, step, target) => {
321
+ target.attribute.innerRadius = interpolateNumber(from, to, ratio);
322
+ target.addUpdateBoundTag();
323
+ };
324
+ this.size = (key, from, to, ratio, step, target) => {
325
+ target.attribute.size = interpolateNumber(from, to, ratio);
326
+ target.addUpdateBoundTag();
327
+ };
328
+ }
329
+ }
330
+ const interpolateUpdateStore = new InterpolateUpdateStore();
331
+ function commonInterpolateUpdate(key, from, to, ratio, step, target) {
332
+ if (Number.isFinite(to) && Number.isFinite(from)) {
333
+ target.attribute[key] = from + (to - from) * ratio;
334
+ return true;
335
+ }
336
+ else if (Array.isArray(to) && Array.isArray(from) && to.length === from.length) {
337
+ const nextList = [];
338
+ let valid = true;
339
+ for (let i = 0; i < to.length; i++) {
340
+ const v = from[i];
341
+ const val = v + (to[i] - v) * ratio;
342
+ if (!Number.isFinite(val)) {
343
+ valid = false;
344
+ break;
345
+ }
346
+ nextList.push(val);
347
+ }
348
+ if (valid) {
349
+ target.attribute[key] = nextList;
350
+ }
351
+ return true;
352
+ }
353
+ return false;
354
+ }
355
+
356
+ function noop() {
357
+ }
358
+ class Step {
359
+ constructor(type, props, duration, easing) {
360
+ this._startTime = 0;
361
+ this._hasFirstRun = false;
362
+ this.type = type;
363
+ this.props = props;
364
+ this.duration = duration;
365
+ if (easing) {
366
+ this.easing = typeof easing === 'function' ? easing : Easing[easing];
367
+ }
368
+ else {
369
+ this.easing = Easing.linear;
370
+ }
371
+ if (type === 'wait') {
372
+ this.onUpdate = noop;
373
+ }
374
+ }
375
+ bind(target, animate) {
376
+ this.target = target;
377
+ this.animate = animate;
378
+ this.onBind();
379
+ }
380
+ append(step) {
381
+ this.next = step;
382
+ step.prev = this;
383
+ step.setStartTime(this.getStartTime() + this.duration, false);
384
+ }
385
+ updateDownstreamStartTimes() {
386
+ let currentStep = this.next;
387
+ let currentStartTime = this._startTime + this.duration;
388
+ while (currentStep) {
389
+ currentStep.setStartTime(currentStartTime, false);
390
+ currentStartTime += currentStep.duration;
391
+ currentStep = currentStep.next;
392
+ }
393
+ this.animate.updateDuration();
394
+ }
395
+ getLastProps() {
396
+ if (this.prev) {
397
+ return this.prev.props || {};
398
+ }
399
+ return this.animate.getStartProps();
400
+ }
401
+ setDuration(duration, updateDownstream = true) {
402
+ this.duration = duration;
403
+ if (updateDownstream) {
404
+ this.updateDownstreamStartTimes();
405
+ }
406
+ }
407
+ getDuration() {
408
+ return this.duration;
409
+ }
410
+ determineInterpolateUpdateFunction() {
411
+ if (!this.props) {
412
+ return;
413
+ }
414
+ const funcs = [];
415
+ this.propKeys.forEach(key => {
416
+ if (key === 'fill' || key === 'stroke') {
417
+ const from = this.getLastProps()[key];
418
+ const to = this.props[key];
419
+ if (isString(from) && isString(to)) {
420
+ const fromArray = ColorStore.Get(from, ColorType.Color255);
421
+ const toArray = ColorStore.Get(to, ColorType.Color255);
422
+ if (!this.fromParsedProps) {
423
+ this.fromParsedProps = {};
424
+ }
425
+ if (!this.toParsedProps) {
426
+ this.toParsedProps = {};
427
+ }
428
+ this.fromParsedProps[key] = fromArray;
429
+ this.toParsedProps[key] = toArray;
430
+ }
431
+ funcs.push(interpolateUpdateStore[key === 'fill' ? 'fillPure' : 'strokePure']);
432
+ }
433
+ else if (interpolateUpdateStore[key]) {
434
+ funcs.push(interpolateUpdateStore[key]);
435
+ }
436
+ else {
437
+ funcs.push(commonInterpolateUpdate);
438
+ }
439
+ });
440
+ this.interpolateUpdateFunctions = funcs;
441
+ }
442
+ setStartTime(time, updateDownstream = true) {
443
+ this._startTime = time;
444
+ if (updateDownstream) {
445
+ this.updateDownstreamStartTimes();
446
+ }
447
+ }
448
+ getStartTime() {
449
+ return this._startTime;
450
+ }
451
+ onBind() {
452
+ }
453
+ onFirstRun() {
454
+ }
455
+ onStart() {
456
+ if (!this._hasFirstRun) {
457
+ this._hasFirstRun = true;
458
+ this.fromProps = this.getLastProps();
459
+ this.determineInterpolateUpdateFunction();
460
+ this.tryPreventConflict();
461
+ this.trySyncStartProps();
462
+ this.onFirstRun();
463
+ }
464
+ }
465
+ tryPreventConflict() {
466
+ const animate = this.animate;
467
+ const target = this.target;
468
+ target.animates.forEach((a) => {
469
+ if (a === animate || a.priority > animate.priority) {
470
+ return;
471
+ }
472
+ const fromProps = a.getStartProps();
473
+ this.propKeys.forEach(key => {
474
+ if (fromProps[key] != null) {
475
+ a.preventAttr(key);
476
+ }
477
+ });
478
+ });
479
+ }
480
+ deleteSelfAttr(key) {
481
+ var _a;
482
+ delete this.props[key];
483
+ this.fromProps && delete this.fromProps[key];
484
+ const index = this.propKeys.indexOf(key);
485
+ if (index !== -1) {
486
+ this.propKeys.splice(index, 1);
487
+ (_a = this.interpolateUpdateFunctions) === null || _a === void 0 ? void 0 : _a.splice(index, 1);
488
+ }
489
+ }
490
+ trySyncStartProps() {
491
+ this.propKeys.forEach(key => {
492
+ this.fromProps[key] = this.animate.target.getComputedAttribute(key);
493
+ });
494
+ }
495
+ update(end, ratio, out) {
496
+ this.onStart();
497
+ if (!this.props || !this.propKeys) {
498
+ return;
499
+ }
500
+ const easedRatio = this.easing(ratio);
501
+ this.animate.interpolateUpdateFunction
502
+ ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target)
503
+ : this.interpolateUpdateFunctions.forEach((func, index) => {
504
+ if (!this.animate.validAttr(this.propKeys[index])) {
505
+ return;
506
+ }
507
+ const key = this.propKeys[index];
508
+ const fromValue = this.fromProps[key];
509
+ const toValue = this.props[key];
510
+ func(key, fromValue, toValue, easedRatio, this, this.target);
511
+ });
512
+ this.onUpdate(end, easedRatio, out);
513
+ }
514
+ onUpdate(end, ratio, out) {
515
+ }
516
+ onEnd(cb) {
517
+ if (cb) {
518
+ this._endCb = cb;
519
+ }
520
+ else if (this._endCb) {
521
+ this.target.setAttributes(this.props);
522
+ this._endCb(this.animate, this);
523
+ }
524
+ }
525
+ getEndProps() {
526
+ return this.props;
527
+ }
528
+ getFromProps() {
529
+ return this.fromProps;
530
+ }
531
+ getMergedEndProps() {
532
+ return this.getEndProps();
533
+ }
534
+ }
535
+ class WaitStep extends Step {
536
+ constructor(type, props, duration, easing) {
537
+ super(type, props, duration, easing);
538
+ }
539
+ update(end, ratio, out) {
540
+ this.onStart();
541
+ }
542
+ determineInterpolateUpdateFunction() {
543
+ return;
544
+ }
545
+ }
546
+
547
+ class DefaultTimeline {
548
+ get animateCount() {
549
+ return this.animates.length;
550
+ }
551
+ constructor() {
552
+ this.animates = [];
553
+ this._playSpeed = 1;
554
+ this._totalDuration = 0;
555
+ this._startTime = 0;
556
+ this._currentTime = 0;
557
+ this._endAnimatePtr = -1;
558
+ this.id = Generator.GenAutoIncrementId();
559
+ this.animates = [];
560
+ this.paused = false;
561
+ }
562
+ isRunning() {
563
+ return !this.paused && this._endAnimatePtr >= 0;
564
+ }
565
+ forEachAccessAnimate(cb) {
566
+ for (let i = 0; i <= this._endAnimatePtr; i++) {
567
+ cb(this.animates[i], i);
568
+ }
569
+ }
570
+ addAnimate(animate) {
571
+ this.animates.push(animate);
572
+ this._endAnimatePtr++;
573
+ this.animates[this.animates.length - 1] = this.animates[this._endAnimatePtr];
574
+ this.animates[this._endAnimatePtr] = animate;
575
+ this._totalDuration = Math.max(this._totalDuration, animate.getStartTime() + animate.getDuration());
576
+ }
577
+ pause() {
578
+ this.paused = true;
579
+ }
580
+ resume() {
581
+ this.paused = false;
582
+ }
583
+ tick(delta) {
584
+ if (this.paused) {
585
+ return;
586
+ }
587
+ const scaledDelta = delta * this._playSpeed;
588
+ this._currentTime += scaledDelta;
589
+ this.forEachAccessAnimate((animate, i) => {
590
+ if (animate.status === AnimateStatus$1.END) {
591
+ this.removeAnimate(animate, true, i);
592
+ }
593
+ else if (animate.status === AnimateStatus$1.RUNNING || animate.status === AnimateStatus$1.INITIAL) {
594
+ animate.advance(scaledDelta);
595
+ }
596
+ });
597
+ }
598
+ clear() {
599
+ this.forEachAccessAnimate(animate => {
600
+ animate.release();
601
+ });
602
+ this.animates = [];
603
+ this._totalDuration = 0;
604
+ }
605
+ removeAnimate(animate, release = true, index) {
606
+ if (this._endAnimatePtr < 0) {
607
+ return;
608
+ }
609
+ if (release) {
610
+ animate._onRemove && animate._onRemove.forEach(cb => cb());
611
+ animate.release();
612
+ }
613
+ index = index !== null && index !== void 0 ? index : this.animates.indexOf(animate);
614
+ this.animates[index] = this.animates[this._endAnimatePtr];
615
+ this._endAnimatePtr--;
616
+ return;
617
+ }
618
+ recalculateTotalDuration() {
619
+ this._totalDuration = 0;
620
+ this.animates.forEach(animate => {
621
+ this._totalDuration = Math.max(this._totalDuration, animate.getStartTime() + animate.getDuration());
622
+ });
623
+ }
624
+ getTotalDuration() {
625
+ return this._totalDuration;
626
+ }
627
+ getPlaySpeed() {
628
+ return this._playSpeed;
629
+ }
630
+ setPlaySpeed(speed) {
631
+ this._playSpeed = speed;
632
+ }
633
+ getPlayState() {
634
+ if (this.paused) {
635
+ return 'paused';
636
+ }
637
+ if (this.animateCount === 0) {
638
+ return 'stopped';
639
+ }
640
+ return 'playing';
641
+ }
642
+ setStartTime(time) {
643
+ this._startTime = time;
644
+ }
645
+ getStartTime() {
646
+ return this._startTime;
647
+ }
648
+ getCurrentTime() {
649
+ return this._currentTime;
650
+ }
651
+ setCurrentTime(time) {
652
+ this._currentTime = time;
653
+ }
654
+ }
655
+ const defaultTimeline = new DefaultTimeline();
656
+ defaultTimeline.isGlobal = true;
657
+
658
+ class Animate {
659
+ constructor(id = Generator.GenAutoIncrementId(), timeline = defaultTimeline, slience) {
660
+ this.id = id;
661
+ this.status = AnimateStatus.INITIAL;
662
+ this._timeline = timeline;
663
+ timeline.addAnimate(this);
664
+ this.slience = slience;
665
+ this._startTime = 0;
666
+ this._duration = 0;
667
+ this._totalDuration = 0;
668
+ this._loopCount = 0;
669
+ this._currentLoop = 0;
670
+ this._bounce = false;
671
+ this._firstStep = null;
672
+ this._lastStep = null;
673
+ this._startProps = {};
674
+ this._endProps = {};
675
+ this._preventAttrs = new Set();
676
+ this.currentTime = 0;
677
+ this.interpolateUpdateFunction = null;
678
+ this.priority = 0;
679
+ }
680
+ getStartProps() {
681
+ return this._startProps;
682
+ }
683
+ getEndProps() {
684
+ return this._endProps;
685
+ }
686
+ setTimeline(timeline) {
687
+ this._timeline = timeline;
688
+ }
689
+ getTimeline() {
690
+ return this._timeline;
691
+ }
692
+ get timeline() {
693
+ return this._timeline;
694
+ }
695
+ bind(target) {
696
+ this.target = target;
697
+ if (this.target.onAnimateBind && !this.slience) {
698
+ this.target.onAnimateBind(this);
699
+ }
700
+ if (!this.target.animationAttribute) {
701
+ this.target.animationAttribute = {};
702
+ }
703
+ return this;
704
+ }
705
+ to(props, duration = 300, easing = 'linear') {
706
+ const step = new Step(AnimateStepType.to, props, duration, easing);
707
+ this.updateStepAfterAppend(step);
708
+ step.bind(this.target, this);
709
+ return this;
710
+ }
711
+ wait(delay) {
712
+ const step = new WaitStep(AnimateStepType.wait, {}, delay, 'linear');
713
+ this.updateStepAfterAppend(step);
714
+ step.bind(this.target, this);
715
+ return this;
716
+ }
717
+ updateStepAfterAppend(step) {
718
+ if (!this._firstStep) {
719
+ this._firstStep = step;
720
+ this._lastStep = step;
721
+ }
722
+ else {
723
+ this._lastStep.append(step);
724
+ this._lastStep = step;
725
+ }
726
+ this.parseStepProps(step);
727
+ this.updateDuration();
728
+ }
729
+ parseStepProps(step) {
730
+ if (!this._lastStep) {
731
+ return;
732
+ }
733
+ step.propKeys = step.propKeys || Object.keys(step.props);
734
+ Object.keys(this._endProps).forEach(key => {
735
+ var _a;
736
+ step.props[key] = (_a = step.props[key]) !== null && _a !== void 0 ? _a : this._endProps[key];
737
+ });
738
+ step.propKeys.forEach(key => {
739
+ this._endProps[key] = step.props[key];
740
+ });
741
+ }
742
+ reSyncProps() {
743
+ if (!this._lastStep) {
744
+ return;
745
+ }
746
+ this._endProps = {};
747
+ let currentStep = this._firstStep;
748
+ while (currentStep) {
749
+ Object.keys(this._endProps).forEach(key => {
750
+ var _a;
751
+ currentStep.props[key] = (_a = currentStep.props[key]) !== null && _a !== void 0 ? _a : this._endProps[key];
752
+ });
753
+ currentStep.propKeys.forEach(key => {
754
+ this._endProps[key] = currentStep.props[key];
755
+ });
756
+ currentStep = currentStep.next;
757
+ }
758
+ }
759
+ from(props, duration = 300, easing = 'linear') {
760
+ const step = new Step(AnimateStepType.from, props, duration, easing);
761
+ if (!this._firstStep) {
762
+ this._firstStep = step;
763
+ this._lastStep = step;
764
+ }
765
+ else {
766
+ this._lastStep.append(step);
767
+ this._lastStep = step;
768
+ }
769
+ this.updateDuration();
770
+ return this;
771
+ }
772
+ play(customAnimate) {
773
+ this.updateStepAfterAppend(customAnimate);
774
+ customAnimate.bind(this.target, this);
775
+ return this;
776
+ }
777
+ pause() {
778
+ if (this.status === AnimateStatus.RUNNING) {
779
+ this.status = AnimateStatus.PAUSED;
780
+ }
781
+ }
782
+ resume() {
783
+ if (this.status === AnimateStatus.PAUSED) {
784
+ this.status = AnimateStatus.RUNNING;
785
+ }
786
+ }
787
+ onStart(cb) {
788
+ var _a;
789
+ if (cb) {
790
+ if (!this._onStart) {
791
+ this._onStart = [];
792
+ }
793
+ this._onStart.push(cb);
794
+ }
795
+ else {
796
+ (_a = this._onStart) === null || _a === void 0 ? void 0 : _a.forEach(cb => cb());
797
+ Object.keys(this._endProps).forEach(key => {
798
+ this._startProps[key] = this.target.getComputedAttribute(key);
799
+ });
800
+ }
801
+ }
802
+ onEnd(cb) {
803
+ var _a;
804
+ if (cb) {
805
+ if (!this._onEnd) {
806
+ this._onEnd = [];
807
+ }
808
+ this._onEnd.push(cb);
809
+ }
810
+ else {
811
+ (_a = this._onEnd) === null || _a === void 0 ? void 0 : _a.forEach(cb => cb());
812
+ }
813
+ }
814
+ onFrame(cb) {
815
+ if (cb) {
816
+ if (!this._onFrame) {
817
+ this._onFrame = [];
818
+ }
819
+ this._onFrame.push(cb);
820
+ }
821
+ }
822
+ onRemove(cb) {
823
+ var _a;
824
+ if (cb) {
825
+ if (!this._onRemove) {
826
+ this._onRemove = [];
827
+ }
828
+ this._onRemove.push(cb);
829
+ }
830
+ else {
831
+ (_a = this._onRemove) === null || _a === void 0 ? void 0 : _a.forEach(cb => cb());
832
+ }
833
+ }
834
+ preventAttr(key) {
835
+ this._preventAttrs.add(key);
836
+ delete this._startProps[key];
837
+ delete this._endProps[key];
838
+ let step = this._firstStep;
839
+ while (step) {
840
+ step.deleteSelfAttr(key);
841
+ step = step.next;
842
+ }
843
+ }
844
+ preventAttrs(keys) {
845
+ keys.forEach(key => this._preventAttrs.add(key));
846
+ }
847
+ validAttr(key) {
848
+ return !this._preventAttrs.has(key);
849
+ }
850
+ runCb(cb) {
851
+ var _a;
852
+ (_a = this._lastStep) === null || _a === void 0 ? void 0 : _a.onEnd(cb);
853
+ return this;
854
+ }
855
+ startAt(t) {
856
+ this._startTime = t;
857
+ return this;
858
+ }
859
+ customInterpolate(key, ratio, from, to, target, ret) {
860
+ return false;
861
+ }
862
+ getFromValue() {
863
+ return this._startProps;
864
+ }
865
+ getToValue() {
866
+ return this._endProps;
867
+ }
868
+ stop(type) {
869
+ this.status = AnimateStatus.END;
870
+ this.onEnd();
871
+ if (!this.target) {
872
+ return;
873
+ }
874
+ if (type === 'start') {
875
+ this.target.setAttributes(this._startProps);
876
+ }
877
+ else if (type === 'end') {
878
+ this.target.setAttributes(this._endProps);
879
+ }
880
+ else if (type) {
881
+ this.target.setAttributes(type);
882
+ }
883
+ }
884
+ release() {
885
+ this.status = AnimateStatus.END;
886
+ if (this._onRemove) {
887
+ this._onRemove.forEach(cb => cb());
888
+ }
889
+ this._onStart = [];
890
+ this._onFrame = [];
891
+ this._onEnd = [];
892
+ this._onRemove = [];
893
+ }
894
+ getDuration() {
895
+ return this._duration;
896
+ }
897
+ getStartTime() {
898
+ return this._startTime;
899
+ }
900
+ afterAll(list) {
901
+ if (!list || list.length === 0) {
902
+ return this;
903
+ }
904
+ let maxEndTime = 0;
905
+ list.forEach(animate => {
906
+ const endTime = animate.getStartTime() + animate.getTotalDuration();
907
+ maxEndTime = Math.max(maxEndTime, endTime);
908
+ });
909
+ return this.startAt(maxEndTime);
910
+ }
911
+ after(animate) {
912
+ if (!animate) {
913
+ return this;
914
+ }
915
+ const endTime = animate.getStartTime() + animate.getTotalDuration();
916
+ return this.startAt(endTime);
917
+ }
918
+ parallel(animate) {
919
+ if (!animate) {
920
+ return this;
921
+ }
922
+ this.startAt(animate.getStartTime());
923
+ return this;
924
+ }
925
+ loop(n) {
926
+ if (n === true) {
927
+ n = Infinity;
928
+ }
929
+ else if (n === false) {
930
+ n = 0;
931
+ }
932
+ this._loopCount = n;
933
+ this.updateDuration();
934
+ return this;
935
+ }
936
+ bounce(b) {
937
+ this._bounce = b;
938
+ return this;
939
+ }
940
+ advance(delta) {
941
+ var _a;
942
+ if (this.status === AnimateStatus.END) {
943
+ console.warn('aaa 动画已经结束,不能推进');
944
+ return;
945
+ }
946
+ const nextTime = this.currentTime + delta;
947
+ if (nextTime < this._startTime) {
948
+ this.currentTime = nextTime;
949
+ return;
950
+ }
951
+ if (nextTime >= this._startTime + this._totalDuration) {
952
+ (_a = this._lastStep) === null || _a === void 0 ? void 0 : _a.onEnd();
953
+ this.onEnd();
954
+ this.status = AnimateStatus.END;
955
+ return;
956
+ }
957
+ this.status = AnimateStatus.RUNNING;
958
+ if (this.currentTime <= this._startTime) {
959
+ this.onStart();
960
+ }
961
+ this.currentTime = nextTime;
962
+ let cycleTime = nextTime - this._startTime;
963
+ let newLoop = false;
964
+ let bounceTime = false;
965
+ if (this._loopCount > 0) {
966
+ cycleTime = (nextTime - this._startTime) % this._duration;
967
+ const currentLoop = Math.floor((nextTime - this._startTime) / this._duration);
968
+ newLoop = currentLoop > this._currentLoop;
969
+ this._currentLoop = currentLoop;
970
+ bounceTime = this._bounce && currentLoop % 2 === 1;
971
+ if (bounceTime) {
972
+ cycleTime = this._duration - cycleTime;
973
+ }
974
+ }
975
+ if (newLoop && !bounceTime) {
976
+ this.target.setAttributes(this._startProps);
977
+ }
978
+ let targetStep = null;
979
+ if (this._lastStep === this._firstStep) {
980
+ targetStep = this._firstStep;
981
+ }
982
+ else {
983
+ let currentStep = this._firstStep;
984
+ while (currentStep) {
985
+ const stepStartTime = currentStep.getStartTime();
986
+ const stepDuration = currentStep.getDuration();
987
+ const stepEndTime = stepStartTime + stepDuration;
988
+ if (cycleTime >= stepStartTime && cycleTime <= stepEndTime) {
989
+ targetStep = currentStep;
990
+ break;
991
+ }
992
+ currentStep = currentStep.next;
993
+ }
994
+ }
995
+ if (!targetStep) {
996
+ return;
997
+ }
998
+ const stepStartTime = targetStep.getStartTime();
999
+ const stepDuration = targetStep.getDuration();
1000
+ const ratio = (cycleTime - stepStartTime) / stepDuration;
1001
+ const isEnd = ratio >= 1;
1002
+ targetStep.update(isEnd, ratio, {});
1003
+ if (isEnd) {
1004
+ targetStep.onEnd();
1005
+ }
1006
+ }
1007
+ updateDuration() {
1008
+ if (!this._lastStep) {
1009
+ this._duration = 0;
1010
+ return;
1011
+ }
1012
+ this._duration = this._lastStep.getStartTime() + this._lastStep.getDuration();
1013
+ this._totalDuration = this._duration * (this._loopCount + 1);
1014
+ }
1015
+ getTotalDuration() {
1016
+ return this._totalDuration;
1017
+ }
1018
+ getLoop() {
1019
+ return this._loopCount;
1020
+ }
1021
+ }
1022
+
1023
+ var STATUS;
1024
+ (function (STATUS) {
1025
+ STATUS[STATUS["INITIAL"] = 0] = "INITIAL";
1026
+ STATUS[STATUS["RUNNING"] = 1] = "RUNNING";
1027
+ STATUS[STATUS["PAUSE"] = 2] = "PAUSE";
1028
+ })(STATUS || (STATUS = {}));
1029
+
1030
+ const performanceRAF = new PerformanceRAF();
1031
+ class RAFTickHandler {
1032
+ constructor() {
1033
+ this.released = false;
1034
+ }
1035
+ tick(interval, cb) {
1036
+ performanceRAF.addAnimationFrameCb(() => {
1037
+ if (this.released) {
1038
+ return;
1039
+ }
1040
+ cb(this);
1041
+ });
1042
+ }
1043
+ release() {
1044
+ this.released = true;
1045
+ }
1046
+ getTime() {
1047
+ return Date.now();
1048
+ }
1049
+ }
1050
+ class DefaultTicker extends EventEmitter {
1051
+ constructor(stage) {
1052
+ super();
1053
+ this.interval = 16;
1054
+ this.lastFrameTime = -1;
1055
+ this.lastExecutionTime = -1;
1056
+ this.tickCounts = 0;
1057
+ this.timelines = [];
1058
+ this.autoStop = true;
1059
+ this.handleTick = (handler, params) => {
1060
+ const { once = false } = params !== null && params !== void 0 ? params : {};
1061
+ if (this.ifCanStop()) {
1062
+ this.stop();
1063
+ return;
1064
+ }
1065
+ const currentTime = handler.getTime();
1066
+ const timeFromLastExecution = this.lastExecutionTime < 0 ? this.interval : currentTime - this.lastExecutionTime;
1067
+ if (timeFromLastExecution >= this.interval) {
1068
+ this._handlerTick();
1069
+ this.lastExecutionTime = currentTime;
1070
+ }
1071
+ if (!once) {
1072
+ handler.tick(this.interval, this.handleTick);
1073
+ }
1074
+ };
1075
+ this._handlerTick = () => {
1076
+ const tickerHandler = this.tickerHandler;
1077
+ const time = tickerHandler.getTime();
1078
+ let delta = 0;
1079
+ if (this.lastFrameTime >= 0) {
1080
+ delta = time - this.lastFrameTime;
1081
+ }
1082
+ this.lastFrameTime = time;
1083
+ if (this.status !== STATUS.RUNNING) {
1084
+ return;
1085
+ }
1086
+ this.tickCounts++;
1087
+ this.timelines.forEach(timeline => {
1088
+ timeline.tick(delta);
1089
+ });
1090
+ this.emit('tick', delta);
1091
+ };
1092
+ this.init();
1093
+ this.lastFrameTime = -1;
1094
+ this.lastExecutionTime = -1;
1095
+ this.tickCounts = 0;
1096
+ this.stage = stage;
1097
+ this.autoStop = true;
1098
+ }
1099
+ init() {
1100
+ this.interval = 16;
1101
+ this.status = STATUS.INITIAL;
1102
+ application.global.hooks.onSetEnv.tap('graph-ticker', () => {
1103
+ this.initHandler();
1104
+ });
1105
+ if (application.global.env) {
1106
+ this.initHandler();
1107
+ }
1108
+ }
1109
+ addTimeline(timeline) {
1110
+ this.timelines.push(timeline);
1111
+ }
1112
+ remTimeline(timeline) {
1113
+ this.timelines = this.timelines.filter(t => t !== timeline);
1114
+ }
1115
+ getTimelines() {
1116
+ return this.timelines;
1117
+ }
1118
+ initHandler() {
1119
+ this.setupTickHandler();
1120
+ }
1121
+ setupTickHandler() {
1122
+ const handler = new RAFTickHandler();
1123
+ if (this.tickerHandler) {
1124
+ this.tickerHandler.release();
1125
+ }
1126
+ this.tickerHandler = handler;
1127
+ return true;
1128
+ }
1129
+ setInterval(interval) {
1130
+ this.interval = interval;
1131
+ }
1132
+ getInterval() {
1133
+ return this.interval;
1134
+ }
1135
+ setFPS(fps) {
1136
+ this.setInterval(1000 / fps);
1137
+ }
1138
+ getFPS() {
1139
+ return 1000 / this.interval;
1140
+ }
1141
+ tick(interval) {
1142
+ this.tickerHandler.tick(interval, (handler) => {
1143
+ this.handleTick(handler, { once: true });
1144
+ });
1145
+ }
1146
+ tickTo(t) {
1147
+ if (!this.tickerHandler.tickTo) {
1148
+ return;
1149
+ }
1150
+ this.tickerHandler.tickTo(t, (handler) => {
1151
+ this.handleTick(handler, { once: true });
1152
+ });
1153
+ }
1154
+ pause() {
1155
+ if (this.status === STATUS.INITIAL) {
1156
+ return false;
1157
+ }
1158
+ this.status = STATUS.PAUSE;
1159
+ return true;
1160
+ }
1161
+ resume() {
1162
+ if (this.status === STATUS.INITIAL) {
1163
+ return false;
1164
+ }
1165
+ this.status = STATUS.RUNNING;
1166
+ return true;
1167
+ }
1168
+ ifCanStop() {
1169
+ if (this.autoStop) {
1170
+ if (!this.timelines.length) {
1171
+ return true;
1172
+ }
1173
+ if (this.timelines.every(timeline => !timeline.isRunning())) {
1174
+ return true;
1175
+ }
1176
+ }
1177
+ return false;
1178
+ }
1179
+ start(force = false) {
1180
+ if (this.status === STATUS.RUNNING) {
1181
+ return false;
1182
+ }
1183
+ if (!this.tickerHandler) {
1184
+ return false;
1185
+ }
1186
+ if (!force) {
1187
+ if (this.status === STATUS.PAUSE) {
1188
+ return false;
1189
+ }
1190
+ if (this.ifCanStop()) {
1191
+ return false;
1192
+ }
1193
+ }
1194
+ this.status = STATUS.RUNNING;
1195
+ this.tickerHandler.tick(0, this.handleTick);
1196
+ return true;
1197
+ }
1198
+ stop() {
1199
+ this.status = STATUS.INITIAL;
1200
+ this.setupTickHandler();
1201
+ this.lastFrameTime = -1;
1202
+ this.lastExecutionTime = -1;
1203
+ }
1204
+ trySyncTickStatus() {
1205
+ if (this.status === STATUS.INITIAL && this.timelines.some(timeline => timeline.isRunning())) {
1206
+ this.start();
1207
+ }
1208
+ else if (this.status === STATUS.RUNNING && this.timelines.every(timeline => !timeline.isRunning())) {
1209
+ this.stop();
1210
+ }
1211
+ }
1212
+ release() {
1213
+ var _a;
1214
+ this.stop();
1215
+ this.timelines = [];
1216
+ (_a = this.tickerHandler) === null || _a === void 0 ? void 0 : _a.release();
1217
+ this.tickerHandler = null;
1218
+ this.lastExecutionTime = -1;
1219
+ }
1220
+ }
1221
+
1222
+ class ManualTickHandler {
1223
+ constructor() {
1224
+ this.released = false;
1225
+ this.startTime = -1;
1226
+ this.currentTime = -1;
1227
+ }
1228
+ tick(interval, cb) {
1229
+ if (this.startTime < 0) {
1230
+ this.startTime = 0;
1231
+ }
1232
+ this.currentTime = this.startTime + interval;
1233
+ cb(this);
1234
+ }
1235
+ release() {
1236
+ this.released = true;
1237
+ }
1238
+ getTime() {
1239
+ return this.currentTime;
1240
+ }
1241
+ }
1242
+ class ManualTicker extends DefaultTicker {
1243
+ setupTickHandler() {
1244
+ const handler = new ManualTickHandler();
1245
+ if (this.tickerHandler) {
1246
+ this.tickerHandler.release();
1247
+ }
1248
+ this.tickerHandler = handler;
1249
+ return true;
1250
+ }
1251
+ getTime() {
1252
+ return this.tickerHandler.getTime();
1253
+ }
1254
+ }
1255
+
1256
+ function generatorPathEasingFunc(path) {
1257
+ const customPath = new CustomPath2D();
1258
+ customPath.setCtx(new CurveContext(customPath));
1259
+ customPath.fromString(path, 0, 0, 1, 1);
1260
+ return (x) => {
1261
+ return customPath.getYAt(x);
1262
+ };
1263
+ }
1264
+
1265
+ class AnimationTransitionRegistry {
1266
+ constructor() {
1267
+ this.transitions = new Map();
1268
+ this.registerDefaultTransitions();
1269
+ }
1270
+ static getInstance() {
1271
+ if (!AnimationTransitionRegistry.instance) {
1272
+ AnimationTransitionRegistry.instance = new AnimationTransitionRegistry();
1273
+ }
1274
+ return AnimationTransitionRegistry.instance;
1275
+ }
1276
+ registerDefaultTransitions() {
1277
+ this.registerTransition('appear', '*', () => ({
1278
+ allowTransition: true,
1279
+ stopOriginalTransition: false
1280
+ }));
1281
+ this.registerTransition('appear', 'appear', () => ({
1282
+ allowTransition: false,
1283
+ stopOriginalTransition: false
1284
+ }));
1285
+ this.registerTransition('appear', 'disappear', () => ({
1286
+ allowTransition: true,
1287
+ stopOriginalTransition: true
1288
+ }));
1289
+ this.registerTransition('appear', 'exit', () => ({
1290
+ allowTransition: true,
1291
+ stopOriginalTransition: true
1292
+ }));
1293
+ this.registerTransition('normal', '*', () => ({
1294
+ allowTransition: true,
1295
+ stopOriginalTransition: false
1296
+ }));
1297
+ this.registerTransition('normal', 'normal', () => ({
1298
+ allowTransition: false,
1299
+ stopOriginalTransition: false
1300
+ }));
1301
+ this.registerTransition('normal', 'disappear', () => ({
1302
+ allowTransition: true,
1303
+ stopOriginalTransition: true
1304
+ }));
1305
+ this.registerTransition('normal', 'exit', () => ({
1306
+ allowTransition: true,
1307
+ stopOriginalTransition: true
1308
+ }));
1309
+ this.registerTransition('exit', '*', () => ({
1310
+ allowTransition: false,
1311
+ stopOriginalTransition: false
1312
+ }));
1313
+ this.registerTransition('exit', 'disappear', () => ({
1314
+ allowTransition: true,
1315
+ stopOriginalTransition: true
1316
+ }));
1317
+ this.registerTransition('exit', 'enter', () => ({
1318
+ allowTransition: true,
1319
+ stopOriginalTransition: true
1320
+ }));
1321
+ this.registerTransition('exit', 'exit', () => ({
1322
+ allowTransition: false,
1323
+ stopOriginalTransition: false
1324
+ }));
1325
+ this.registerTransition('enter', '*', () => ({
1326
+ allowTransition: true,
1327
+ stopOriginalTransition: false
1328
+ }));
1329
+ this.registerTransition('enter', 'enter', () => ({
1330
+ allowTransition: false,
1331
+ stopOriginalTransition: false
1332
+ }));
1333
+ this.registerTransition('enter', 'disappear', () => ({
1334
+ allowTransition: true,
1335
+ stopOriginalTransition: true
1336
+ }));
1337
+ this.registerTransition('enter', 'exit', () => ({
1338
+ allowTransition: true,
1339
+ stopOriginalTransition: true
1340
+ }));
1341
+ this.registerTransition('disappear', '*', () => ({
1342
+ allowTransition: false,
1343
+ stopOriginalTransition: false
1344
+ }));
1345
+ this.registerTransition('disappear', 'appear', () => ({
1346
+ allowTransition: true,
1347
+ stopOriginalTransition: true
1348
+ }));
1349
+ }
1350
+ isTransitionAllowed(fromState, toState, graphic) {
1351
+ var _a, _b, _c, _d;
1352
+ let func = (_a = this.transitions.get(fromState)) === null || _a === void 0 ? void 0 : _a.get(toState);
1353
+ if (func) {
1354
+ return func(graphic, fromState);
1355
+ }
1356
+ func = (_b = this.transitions.get(fromState)) === null || _b === void 0 ? void 0 : _b.get('*');
1357
+ if (func) {
1358
+ return func(graphic, fromState);
1359
+ }
1360
+ func = (_c = this.transitions.get('*')) === null || _c === void 0 ? void 0 : _c.get(toState);
1361
+ if (func) {
1362
+ return func(graphic, fromState);
1363
+ }
1364
+ func = (_d = this.transitions.get('*')) === null || _d === void 0 ? void 0 : _d.get('*');
1365
+ if (func) {
1366
+ return func(graphic, fromState);
1367
+ }
1368
+ return {
1369
+ allowTransition: true,
1370
+ stopOriginalTransition: true
1371
+ };
1372
+ }
1373
+ registerTransition(fromState, toState, transition) {
1374
+ let fromStateMap = this.transitions.get(fromState);
1375
+ if (!fromStateMap) {
1376
+ fromStateMap = new Map();
1377
+ this.transitions.set(fromState, fromStateMap);
1378
+ }
1379
+ fromStateMap.set(toState, transition);
1380
+ }
1381
+ }
1382
+ const transitionRegistry = AnimationTransitionRegistry.getInstance();
1383
+
1384
+ class AnimateExecutor {
1385
+ static registerBuiltInAnimate(name, animate) {
1386
+ AnimateExecutor.builtInAnimateMap[name] = animate;
1387
+ }
1388
+ constructor(target) {
1389
+ this._animates = [];
1390
+ this._startCallbacks = [];
1391
+ this._endCallbacks = [];
1392
+ this._started = false;
1393
+ this._activeCount = 0;
1394
+ this._target = target;
1395
+ }
1396
+ onStart(cb) {
1397
+ if (cb) {
1398
+ this._startCallbacks.push(cb);
1399
+ if (this._started && this._activeCount > 0) {
1400
+ cb();
1401
+ }
1402
+ }
1403
+ else {
1404
+ this._startCallbacks.forEach(cb => {
1405
+ cb();
1406
+ });
1407
+ }
1408
+ }
1409
+ onEnd(cb) {
1410
+ if (cb) {
1411
+ this._endCallbacks.push(cb);
1412
+ }
1413
+ else {
1414
+ this._endCallbacks.forEach(cb => {
1415
+ cb();
1416
+ });
1417
+ }
1418
+ }
1419
+ _trackAnimation(animate) {
1420
+ this._animates.push(animate);
1421
+ this._activeCount++;
1422
+ if (this._activeCount === 1 && !this._started) {
1423
+ this._started = true;
1424
+ this.onStart();
1425
+ }
1426
+ animate.onEnd(() => {
1427
+ this._activeCount--;
1428
+ const index = this._animates.indexOf(animate);
1429
+ if (index >= 0) {
1430
+ this._animates.splice(index, 1);
1431
+ }
1432
+ if (this._activeCount === 0 && this._started) {
1433
+ this._started = false;
1434
+ this.onEnd();
1435
+ }
1436
+ });
1437
+ }
1438
+ parseParams(params) {
1439
+ const isTimeline = 'timeSlices' in params;
1440
+ const totalTime = this.resolveValue(params.totalTime, undefined, undefined);
1441
+ const startTime = this.resolveValue(params.startTime, undefined, 0);
1442
+ const parsedParams = cloneDeep(params);
1443
+ parsedParams.oneByOneDelay = 0;
1444
+ parsedParams.startTime = startTime;
1445
+ parsedParams.totalTime = totalTime;
1446
+ const oneByOne = this.resolveValue(params.oneByOne, undefined, false);
1447
+ if (isTimeline) {
1448
+ const timeSlices = parsedParams.timeSlices;
1449
+ if (!isArray(timeSlices)) {
1450
+ parsedParams.timeSlices = [timeSlices];
1451
+ }
1452
+ let sliceTime = 0;
1453
+ parsedParams.timeSlices.forEach(slice => {
1454
+ slice.delay = this.resolveValue(slice.delay, undefined, 0);
1455
+ slice.delayAfter = this.resolveValue(slice.delayAfter, undefined, 0);
1456
+ slice.duration = this.resolveValue(slice.duration, undefined, 300);
1457
+ sliceTime += slice.delay + slice.duration + slice.delayAfter;
1458
+ });
1459
+ let oneByOneDelay = 0;
1460
+ let oneByOneTime = 0;
1461
+ if (oneByOne) {
1462
+ oneByOneTime = Number(oneByOne);
1463
+ oneByOneDelay = oneByOneTime;
1464
+ }
1465
+ parsedParams.oneByOne = oneByOneTime;
1466
+ parsedParams.oneByOneDelay = oneByOneDelay;
1467
+ if (totalTime) {
1468
+ const _totalTime = sliceTime + oneByOneDelay * (this._target.count - 2);
1469
+ const scale = totalTime ? totalTime / _totalTime : 1;
1470
+ parsedParams.timeSlices.forEach(slice => {
1471
+ slice.delay = slice.delay * scale;
1472
+ slice.delayAfter = slice.delayAfter * scale;
1473
+ slice.duration = slice.duration * scale;
1474
+ });
1475
+ parsedParams.oneByOne = oneByOneTime * scale;
1476
+ parsedParams.oneByOneDelay = oneByOneDelay * scale;
1477
+ parsedParams.startTime = startTime * scale;
1478
+ }
1479
+ }
1480
+ else {
1481
+ const delay = this.resolveValue(params.delay, undefined, 0);
1482
+ const delayAfter = this.resolveValue(params.delayAfter, undefined, 0);
1483
+ const duration = this.resolveValue(params.duration, undefined, 300);
1484
+ let oneByOneDelay = 0;
1485
+ let oneByOneTime = 0;
1486
+ if (oneByOne) {
1487
+ oneByOneTime = Number(oneByOne);
1488
+ oneByOneDelay = duration + oneByOneTime;
1489
+ }
1490
+ parsedParams.oneByOne = oneByOneTime;
1491
+ parsedParams.oneByOneDelay = oneByOneDelay;
1492
+ if (totalTime) {
1493
+ const _totalTime = delay + delayAfter + duration + oneByOneDelay * (this._target.count - 2);
1494
+ const scale = totalTime ? totalTime / _totalTime : 1;
1495
+ parsedParams.delay = delay * scale;
1496
+ parsedParams.delayAfter = delayAfter * scale;
1497
+ parsedParams.duration = duration * scale;
1498
+ parsedParams.oneByOne = oneByOneTime * scale;
1499
+ parsedParams.oneByOneDelay = oneByOneDelay * scale;
1500
+ parsedParams.startTime = startTime;
1501
+ }
1502
+ }
1503
+ return parsedParams;
1504
+ }
1505
+ execute(params) {
1506
+ const isTimeline = 'timeSlices' in params;
1507
+ let filteredChildren;
1508
+ if (isTimeline && params.partitioner) {
1509
+ filteredChildren = (filteredChildren !== null && filteredChildren !== void 0 ? filteredChildren : this._target.getChildren()).filter(child => {
1510
+ var _a;
1511
+ return params.partitioner((_a = child.context) === null || _a === void 0 ? void 0 : _a.data, child, {});
1512
+ });
1513
+ }
1514
+ if (isTimeline && params.sort) {
1515
+ filteredChildren = filteredChildren !== null && filteredChildren !== void 0 ? filteredChildren : this._target.getChildren();
1516
+ filteredChildren.sort((a, b) => {
1517
+ var _a, _b;
1518
+ return params.sort((_a = a.context) === null || _a === void 0 ? void 0 : _a.data, (_b = b.context) === null || _b === void 0 ? void 0 : _b.data, a, b, {});
1519
+ });
1520
+ }
1521
+ const parsedParams = this.parseParams(params);
1522
+ const cb = isTimeline
1523
+ ? (child, index, count) => {
1524
+ const animate = this.executeTimelineItem(parsedParams, child, index, count);
1525
+ if (animate) {
1526
+ this._trackAnimation(animate);
1527
+ }
1528
+ }
1529
+ : (child, index, count) => {
1530
+ const animate = this.executeTypeConfigItem(parsedParams, child, index, count);
1531
+ if (animate) {
1532
+ this._trackAnimation(animate);
1533
+ }
1534
+ };
1535
+ if (filteredChildren) {
1536
+ filteredChildren.forEach((child, index) => cb(child, index, filteredChildren.length));
1537
+ }
1538
+ else if (this._target.count <= 1) {
1539
+ cb(this._target, 0, 1);
1540
+ }
1541
+ else {
1542
+ this._target.forEachChildren((child, index) => cb(child, index, this._target.count - 1));
1543
+ }
1544
+ return;
1545
+ }
1546
+ executeTypeConfigItem(params, graphic, index, count) {
1547
+ var _a, _b, _c, _d, _e, _f;
1548
+ const { type, channel, customParameters, easing = 'linear', delay = 0, delayAfter = 0, duration = 300, startTime = 0, oneByOneDelay = 0, loop, bounce, priority = 0, options, controlOptions } = params;
1549
+ const custom = (_a = params.custom) !== null && _a !== void 0 ? _a : AnimateExecutor.builtInAnimateMap[type];
1550
+ const animate = graphic.animate();
1551
+ animate.priority = priority;
1552
+ const delayValue = delay;
1553
+ const datum = (_c = (_b = graphic.context) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c[0];
1554
+ const indexKey = (_d = graphic.context) === null || _d === void 0 ? void 0 : _d.indexKey;
1555
+ if (datum && indexKey) {
1556
+ index = (_e = datum[indexKey]) !== null && _e !== void 0 ? _e : index;
1557
+ }
1558
+ animate.startAt(startTime);
1559
+ animate.wait(index * oneByOneDelay);
1560
+ if (delayValue > 0) {
1561
+ animate.wait(delayValue);
1562
+ }
1563
+ const props = (_f = params.to) !== null && _f !== void 0 ? _f : this.createPropsFromChannel(channel, graphic);
1564
+ this._handleRunAnimate(animate, custom, props, duration, easing, customParameters, options, type, graphic);
1565
+ if (oneByOneDelay) {
1566
+ animate.wait(oneByOneDelay * (count - index - 1));
1567
+ }
1568
+ if (delayAfter > 0) {
1569
+ animate.wait(delayAfter);
1570
+ }
1571
+ if (loop && loop > 0) {
1572
+ animate.loop(loop);
1573
+ }
1574
+ if (bounce) {
1575
+ animate.bounce(true);
1576
+ }
1577
+ return animate;
1578
+ }
1579
+ _handleRunAnimate(animate, custom, props, duration, easing, customParameters, options, type, graphic) {
1580
+ if (custom) {
1581
+ const customParams = this.resolveValue(customParameters, graphic, {});
1582
+ const objOptions = isFunction(options)
1583
+ ? options.call(null, customParameters.data && customParameters.data[0], graphic, customParameters)
1584
+ : options;
1585
+ customParams.options = objOptions;
1586
+ if (isFunction(custom)) {
1587
+ if (/^class\s/.test(Function.prototype.toString.call(custom))) {
1588
+ this.createCustomAnimation(animate, custom, props, duration, easing, customParams);
1589
+ }
1590
+ else {
1591
+ this.createCustomInterpolatorAnimation(animate, custom, props, duration, easing, customParams);
1592
+ }
1593
+ }
1594
+ }
1595
+ else if (type === 'to') {
1596
+ animate.to(props, duration, easing);
1597
+ }
1598
+ else if (type === 'from') {
1599
+ animate.from(props, duration, easing);
1600
+ }
1601
+ }
1602
+ executeTimelineItem(params, graphic, index, count) {
1603
+ var _a, _b, _c, _d;
1604
+ const { timeSlices, startTime = 0, loop, bounce, oneByOneDelay, priority, controlOptions } = params;
1605
+ const datum = (_b = (_a = graphic.context) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[0];
1606
+ const indexKey = (_c = graphic.context) === null || _c === void 0 ? void 0 : _c.indexKey;
1607
+ if (datum && indexKey) {
1608
+ index = (_d = datum[indexKey]) !== null && _d !== void 0 ? _d : index;
1609
+ }
1610
+ const animate = graphic.animate();
1611
+ animate.priority = priority;
1612
+ animate.startAt(startTime);
1613
+ animate.wait(index * oneByOneDelay);
1614
+ if (loop && loop > 0) {
1615
+ animate.loop(loop);
1616
+ }
1617
+ if (bounce) {
1618
+ animate.bounce(true);
1619
+ }
1620
+ const slices = Array.isArray(timeSlices) ? timeSlices : [timeSlices];
1621
+ slices.forEach(slice => {
1622
+ this.applyTimeSliceToAnimate(slice, animate, graphic);
1623
+ });
1624
+ if (oneByOneDelay) {
1625
+ animate.wait(oneByOneDelay * (count - index - 1));
1626
+ }
1627
+ return animate;
1628
+ }
1629
+ applyTimeSliceToAnimate(slice, animate, graphic) {
1630
+ const { effects, duration = 300, delay = 0, delayAfter = 0 } = slice;
1631
+ const delayValue = delay;
1632
+ const delayAfterValue = delayAfter;
1633
+ if (delayValue > 0) {
1634
+ animate.wait(delayValue);
1635
+ }
1636
+ const effectsArray = Array.isArray(effects) ? effects : [effects];
1637
+ effectsArray.forEach(effect => {
1638
+ var _a;
1639
+ const { type = 'to', channel, customParameters, easing = 'linear', options } = effect;
1640
+ const custom = (_a = effect.custom) !== null && _a !== void 0 ? _a : AnimateExecutor.builtInAnimateMap[type];
1641
+ const props = this.createPropsFromChannel(channel, graphic);
1642
+ this._handleRunAnimate(animate, custom, props, duration, easing, customParameters, options, type, graphic);
1643
+ });
1644
+ if (delayAfterValue > 0) {
1645
+ animate.wait(delayAfterValue);
1646
+ }
1647
+ }
1648
+ createCustomInterpolatorAnimation(animate, interpolator, props, duration, easing, customParams) {
1649
+ const to = props;
1650
+ Object.keys(to).forEach(key => {
1651
+ animate.target.getComputedAttribute(key);
1652
+ });
1653
+ animate.interpolateUpdateFunction = (from, to, ratio, step, target) => {
1654
+ interpolator(ratio, from, to, step, target, animate.target, customParams);
1655
+ };
1656
+ animate.to(props, duration, easing);
1657
+ }
1658
+ createCustomAnimation(animate, CustomAnimateConstructor, props, duration, easing, customParams) {
1659
+ const from = {};
1660
+ const to = props;
1661
+ Object.keys(to).forEach(key => {
1662
+ from[key] = animate.target.getComputedAttribute(key);
1663
+ });
1664
+ const customAnimate = new CustomAnimateConstructor(from, to, duration, easing, customParams);
1665
+ animate.play(customAnimate);
1666
+ }
1667
+ createPropsFromChannel(channel, graphic) {
1668
+ const props = {};
1669
+ if (!channel) {
1670
+ return props;
1671
+ }
1672
+ if (!Array.isArray(channel)) {
1673
+ Object.entries(channel).forEach(([key, config]) => {
1674
+ var _a;
1675
+ if (config.to !== undefined) {
1676
+ if (typeof config.to === 'function') {
1677
+ props[key] = config.to((_a = graphic.context) === null || _a === void 0 ? void 0 : _a.data, graphic, {});
1678
+ }
1679
+ else {
1680
+ props[key] = config.to;
1681
+ }
1682
+ }
1683
+ });
1684
+ }
1685
+ return props;
1686
+ }
1687
+ resolveValue(value, graphic, defaultValue) {
1688
+ var _a;
1689
+ if (value === undefined) {
1690
+ return defaultValue;
1691
+ }
1692
+ if (typeof value === 'function' && graphic) {
1693
+ return value((_a = graphic.context) === null || _a === void 0 ? void 0 : _a.data, graphic, {});
1694
+ }
1695
+ return value;
1696
+ }
1697
+ executeItem(params, graphic, index = 0, count = 1) {
1698
+ if (!graphic) {
1699
+ return null;
1700
+ }
1701
+ const isTimeline = 'timeSlices' in params;
1702
+ let animate = null;
1703
+ if (isTimeline) {
1704
+ animate = this.executeTimelineItem(params, graphic, index, count);
1705
+ }
1706
+ else {
1707
+ animate = this.executeTypeConfigItem(params, graphic, index, count);
1708
+ }
1709
+ if (animate) {
1710
+ this._trackAnimation(animate);
1711
+ }
1712
+ return animate;
1713
+ }
1714
+ stop(type) {
1715
+ while (this._animates.length > 0) {
1716
+ const animate = this._animates.pop();
1717
+ animate === null || animate === void 0 ? void 0 : animate.stop(type);
1718
+ }
1719
+ this._animates = [];
1720
+ this._activeCount = 0;
1721
+ if (this._started) {
1722
+ this._started = false;
1723
+ this.onEnd();
1724
+ }
1725
+ }
1726
+ }
1727
+ AnimateExecutor.builtInAnimateMap = {};
1728
+
1729
+ class AnimationStateStore {
1730
+ constructor(graphic) {
1731
+ this.graphic = graphic;
1732
+ }
1733
+ registerState(state) {
1734
+ if (!this.states) {
1735
+ this.states = new Map();
1736
+ }
1737
+ this.states.set(state.name, state);
1738
+ }
1739
+ clearStates() {
1740
+ var _a;
1741
+ (_a = this.states) === null || _a === void 0 ? void 0 : _a.clear();
1742
+ }
1743
+ }
1744
+ class AnimationStateManager {
1745
+ constructor(graphic) {
1746
+ this.stateList = null;
1747
+ this.graphic = graphic;
1748
+ }
1749
+ applyState(nextState, animationConfig, callback) {
1750
+ const registry = AnimationTransitionRegistry.getInstance();
1751
+ const shouldStopState = [];
1752
+ const shouldApplyState = [];
1753
+ if (!(this.stateList && this.stateList.length)) {
1754
+ nextState.forEach((state, index) => {
1755
+ shouldApplyState.push({
1756
+ state,
1757
+ animationConfig: animationConfig[index].animation,
1758
+ executor: new AnimateExecutor(this.graphic)
1759
+ });
1760
+ });
1761
+ }
1762
+ else {
1763
+ nextState.forEach((state, index) => {
1764
+ const result = {
1765
+ allowTransition: true,
1766
+ stopOriginalTransition: true
1767
+ };
1768
+ this.stateList.forEach(currState => {
1769
+ const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);
1770
+ result.allowTransition = result.allowTransition && _result.allowTransition;
1771
+ });
1772
+ if (result.allowTransition) {
1773
+ shouldApplyState.push({
1774
+ state,
1775
+ animationConfig: animationConfig[index].animation,
1776
+ executor: new AnimateExecutor(this.graphic)
1777
+ });
1778
+ this.stateList.forEach(currState => {
1779
+ const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);
1780
+ if (_result.stopOriginalTransition) {
1781
+ shouldStopState.push(currState);
1782
+ }
1783
+ });
1784
+ }
1785
+ });
1786
+ }
1787
+ shouldStopState.forEach(state => {
1788
+ state.executor.stop();
1789
+ });
1790
+ if (shouldApplyState.length) {
1791
+ shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);
1792
+ for (let i = 0; i < shouldApplyState.length; i++) {
1793
+ const nextState = shouldApplyState[i + 1];
1794
+ const currentState = shouldApplyState[i];
1795
+ currentState.executor.onEnd(() => {
1796
+ if (nextState) {
1797
+ nextState.executor.execute(nextState.animationConfig);
1798
+ }
1799
+ this.stateList = this.stateList.filter(state => state !== currentState);
1800
+ if (i === shouldApplyState.length - 1 && callback) {
1801
+ callback(false);
1802
+ }
1803
+ });
1804
+ }
1805
+ }
1806
+ else if (callback) {
1807
+ callback(true);
1808
+ }
1809
+ if (this.stateList) {
1810
+ this.stateList = this.stateList.filter(state => !shouldStopState.includes(state));
1811
+ }
1812
+ else {
1813
+ this.stateList = [];
1814
+ }
1815
+ this.stateList.push(...shouldApplyState);
1816
+ }
1817
+ stopState(state, type) {
1818
+ var _a;
1819
+ const stateInfo = (_a = this.stateList) === null || _a === void 0 ? void 0 : _a.find(stateInfo => stateInfo.state === state);
1820
+ if (stateInfo) {
1821
+ stateInfo.executor.stop(type);
1822
+ }
1823
+ }
1824
+ clearState() {
1825
+ var _a;
1826
+ (_a = this.stateList) === null || _a === void 0 ? void 0 : _a.forEach(state => {
1827
+ state.executor.stop();
1828
+ });
1829
+ this.stateList = null;
1830
+ }
1831
+ }
1832
+
1833
+ class GraphicStateExtension {
1834
+ _getAnimationStateManager(graphic) {
1835
+ if (!graphic._animationStateManager) {
1836
+ graphic._animationStateManager = new AnimationStateManager(graphic);
1837
+ }
1838
+ return graphic._animationStateManager;
1839
+ }
1840
+ _getAnimationStateStore(graphic) {
1841
+ if (!graphic._animationStateStore) {
1842
+ graphic._animationStateStore = new AnimationStateStore(graphic);
1843
+ }
1844
+ return graphic._animationStateStore;
1845
+ }
1846
+ registerAnimationState(state) {
1847
+ this._getAnimationStateStore(this).registerState(state);
1848
+ return this;
1849
+ }
1850
+ applyAnimationState(state, animationConfig, callback) {
1851
+ this._getAnimationStateManager(this).applyState(state, animationConfig, callback);
1852
+ return this;
1853
+ }
1854
+ stopAnimationState(state, type) {
1855
+ this._getAnimationStateManager(this).stopState(state, type);
1856
+ return this;
1857
+ }
1858
+ clearAnimationStates() {
1859
+ this._getAnimationStateManager(this).clearState();
1860
+ return this;
1861
+ }
1862
+ static extend(graphic) {
1863
+ const extension = new GraphicStateExtension();
1864
+ extension._getAnimationStateManager(graphic);
1865
+ return graphic;
1866
+ }
1867
+ }
1868
+
1869
+ class AnimateExtension {
1870
+ constructor() {
1871
+ this.animatedAttribute = null;
1872
+ }
1873
+ getAttributes(final = false) {
1874
+ if (final) {
1875
+ this.computeAnimatedAttribute();
1876
+ return this.getFinalAttribute();
1877
+ }
1878
+ return this.attribute;
1879
+ }
1880
+ animate(params) {
1881
+ var _a, _b, _c;
1882
+ if (!this.animates) {
1883
+ this.animates = new Map();
1884
+ }
1885
+ const animate = new Animate(params === null || params === void 0 ? void 0 : params.id, (_b = (_a = params === null || params === void 0 ? void 0 : params.timeline) !== null && _a !== void 0 ? _a : (this.stage && this.stage.getTimeline())) !== null && _b !== void 0 ? _b : defaultTimeline, params === null || params === void 0 ? void 0 : params.slience);
1886
+ animate.bind(this);
1887
+ if (params) {
1888
+ const { onStart, onEnd, onRemove } = params;
1889
+ onStart != null && animate.onStart(onStart);
1890
+ onEnd != null && animate.onEnd(onEnd);
1891
+ onRemove != null && animate.onRemove(onRemove);
1892
+ }
1893
+ this.animates.set(animate.id, animate);
1894
+ animate.onRemove(() => {
1895
+ animate.stop();
1896
+ this.animates.delete(animate.id);
1897
+ });
1898
+ (_c = this.stage) === null || _c === void 0 ? void 0 : _c.ticker.start();
1899
+ return animate;
1900
+ }
1901
+ computeAnimatedAttribute() {
1902
+ if (!this.animatedAttribute) {
1903
+ this.animatedAttribute = {};
1904
+ this.animates.forEach(animate => {
1905
+ if (animate.getLoop() !== Infinity) {
1906
+ Object.assign(this.animatedAttribute, animate.getEndProps());
1907
+ }
1908
+ });
1909
+ }
1910
+ }
1911
+ createTimeline() {
1912
+ return new DefaultTimeline();
1913
+ }
1914
+ createTicker(stage) {
1915
+ return new DefaultTicker(stage);
1916
+ }
1917
+ getFinalAttribute() {
1918
+ const finalAttribute = {};
1919
+ Object.assign(finalAttribute, this.attribute, this.animatedAttribute);
1920
+ return finalAttribute;
1921
+ }
1922
+ }
1923
+
1924
+ function registerAnimate() {
1925
+ if (!Graphic.Animate) {
1926
+ Graphic.Animate = Animate;
1927
+ }
1928
+ if (!Graphic.Timeline) {
1929
+ Graphic.Timeline = DefaultTimeline;
1930
+ }
1931
+ if (!Graphic.defaultTimeline) {
1932
+ Graphic.defaultTimeline = defaultTimeline;
1933
+ }
1934
+ if (!Graphic.Ticker) {
1935
+ Graphic.Ticker = DefaultTicker;
1936
+ }
1937
+ mixin(Graphic, GraphicStateExtension);
1938
+ mixin(Graphic, AnimateExtension);
1939
+ }
1940
+
1941
+ class ACustomAnimate extends Step {
1942
+ constructor(customFrom, customTo, duration, easing, params) {
1943
+ super('customAnimate', customTo, duration, easing);
1944
+ this.type = 'customAnimate';
1945
+ this.customFrom = customFrom;
1946
+ this.params = params;
1947
+ }
1948
+ update(end, ratio, out) {
1949
+ this.onStart();
1950
+ if (!this.props || !this.propKeys) {
1951
+ return;
1952
+ }
1953
+ const easedRatio = this.easing(ratio);
1954
+ this.onUpdate(end, easedRatio, out);
1955
+ }
1956
+ setProps(props) {
1957
+ this.props = props;
1958
+ this.propKeys = Object.keys(props);
1959
+ this.animate.reSyncProps();
1960
+ }
1961
+ }
1962
+
1963
+ class IncreaseCount extends ACustomAnimate {
1964
+ constructor(from, to, duration, easing, params) {
1965
+ super(from, to, duration, easing, params);
1966
+ this.formatTemplate = null;
1967
+ this.decimalLength = params === null || params === void 0 ? void 0 : params.decimalLength;
1968
+ if ((params === null || params === void 0 ? void 0 : params.formatTemplate) && params.formatTemplate.includes('{{var}}')) {
1969
+ this.formatTemplate = params.formatTemplate;
1970
+ }
1971
+ }
1972
+ onFirstRun() {
1973
+ var _a, _b, _c;
1974
+ const fromProps = this.getLastProps();
1975
+ const toProps = this.getEndProps();
1976
+ const fromText = (_a = fromProps.text) !== null && _a !== void 0 ? _a : 0;
1977
+ const toText = (_b = toProps.text) !== null && _b !== void 0 ? _b : 0;
1978
+ this.valid = true;
1979
+ let fromNum = 0;
1980
+ let toNum = 0;
1981
+ let fromFormat = '';
1982
+ let toFormat = '';
1983
+ let maxDecimalLength = 0;
1984
+ if (typeof fromText === 'number') {
1985
+ fromNum = fromText;
1986
+ const str = fromText.toString();
1987
+ const decimalPart = str.split('.')[1] || '';
1988
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
1989
+ }
1990
+ else if (typeof fromText === 'string') {
1991
+ if (fromText.endsWith('%')) {
1992
+ fromFormat = '%';
1993
+ const numStr = fromText.substring(0, fromText.length - 1);
1994
+ const cleanNumStr = numStr.replace(/,/g, '');
1995
+ fromNum = parseFloat(cleanNumStr) / 100;
1996
+ if (isNaN(fromNum)) {
1997
+ this.valid = false;
1998
+ return;
1999
+ }
2000
+ const decimalPart = cleanNumStr.split('.')[1] || '';
2001
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length + 2);
2002
+ }
2003
+ else {
2004
+ const cleanNumStr = fromText.replace(/,/g, '');
2005
+ fromNum = parseFloat(cleanNumStr);
2006
+ if (isNaN(fromNum)) {
2007
+ this.valid = false;
2008
+ return;
2009
+ }
2010
+ if (fromText.includes(',')) {
2011
+ fromFormat = ',';
2012
+ }
2013
+ const decimalPart = cleanNumStr.split('.')[1] || '';
2014
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
2015
+ }
2016
+ }
2017
+ else {
2018
+ this.valid = false;
2019
+ return;
2020
+ }
2021
+ if (typeof toText === 'number') {
2022
+ toNum = toText;
2023
+ const str = toText.toString();
2024
+ const decimalPart = str.split('.')[1] || '';
2025
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
2026
+ }
2027
+ else if (typeof toText === 'string') {
2028
+ if (toText.endsWith('%')) {
2029
+ toFormat = '%';
2030
+ const numStr = toText.substring(0, toText.length - 1);
2031
+ const cleanNumStr = numStr.replace(/,/g, '');
2032
+ toNum = parseFloat(cleanNumStr) / 100;
2033
+ if (isNaN(toNum)) {
2034
+ this.valid = false;
2035
+ return;
2036
+ }
2037
+ const decimalPart = cleanNumStr.split('.')[1] || '';
2038
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length + 2);
2039
+ }
2040
+ else {
2041
+ const cleanNumStr = toText.replace(/,/g, '');
2042
+ toNum = parseFloat(cleanNumStr);
2043
+ if (isNaN(toNum)) {
2044
+ this.valid = false;
2045
+ return;
2046
+ }
2047
+ if (toText.includes(',')) {
2048
+ toFormat = ',';
2049
+ }
2050
+ const decimalPart = cleanNumStr.split('.')[1] || '';
2051
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
2052
+ }
2053
+ }
2054
+ else {
2055
+ this.valid = false;
2056
+ return;
2057
+ }
2058
+ if ((_c = this.params) === null || _c === void 0 ? void 0 : _c.format) {
2059
+ switch (this.params.format) {
2060
+ case 'percent':
2061
+ this.format = '%';
2062
+ break;
2063
+ case 'thousandth':
2064
+ this.format = ',';
2065
+ break;
2066
+ case 'none':
2067
+ this.format = '';
2068
+ break;
2069
+ default:
2070
+ this.format = toFormat || fromFormat;
2071
+ }
2072
+ if (this.format === '%' && toFormat !== '%' && fromFormat !== '%') {
2073
+ if (this.decimalLength === undefined) {
2074
+ this.decimalLength = 2;
2075
+ }
2076
+ }
2077
+ if (this.format !== '%' && (toFormat === '%' || fromFormat === '%')) {
2078
+ fromNum = fromNum * 100;
2079
+ toNum = toNum * 100;
2080
+ }
2081
+ }
2082
+ else {
2083
+ this.format = toFormat || fromFormat;
2084
+ }
2085
+ this.fromNumber = fromNum;
2086
+ this.toNumber = toNum;
2087
+ if (this.decimalLength === undefined) {
2088
+ this.decimalLength = maxDecimalLength;
2089
+ }
2090
+ }
2091
+ onEnd(cb) {
2092
+ super.onEnd(cb);
2093
+ if (!cb) {
2094
+ this.props && this.target.setAttributes(this.props);
2095
+ }
2096
+ }
2097
+ onUpdate(end, ratio, out) {
2098
+ if (!this.valid) {
2099
+ return;
2100
+ }
2101
+ const currentNumber = this.fromNumber + (this.toNumber - this.fromNumber) * ratio;
2102
+ let formattedText = '';
2103
+ const format = this.format;
2104
+ const adjustedNumber = format === '%' ? currentNumber * 100 : currentNumber;
2105
+ const numberWithDecimals = adjustedNumber.toFixed(this.decimalLength);
2106
+ let formattedNumber = numberWithDecimals;
2107
+ if (parseFloat(numberWithDecimals) === Math.floor(parseFloat(numberWithDecimals))) {
2108
+ formattedNumber = Math.floor(parseFloat(numberWithDecimals));
2109
+ }
2110
+ let formattedWithBasicFormat;
2111
+ if (format === '%') {
2112
+ formattedWithBasicFormat = `${formattedNumber}%`;
2113
+ }
2114
+ else if (format === ',') {
2115
+ const parts = formattedNumber.toString().split('.');
2116
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
2117
+ formattedWithBasicFormat = parts.join('.');
2118
+ }
2119
+ else {
2120
+ formattedWithBasicFormat = formattedNumber;
2121
+ }
2122
+ if (this.formatTemplate) {
2123
+ formattedText = this.formatTemplate.replace('{{var}}', formattedWithBasicFormat.toString());
2124
+ }
2125
+ else {
2126
+ formattedText = formattedWithBasicFormat;
2127
+ }
2128
+ this.target.setAttribute('text', formattedText);
2129
+ }
2130
+ }
2131
+
2132
+ class InputText extends ACustomAnimate {
2133
+ constructor(from, to, duration, easing, params) {
2134
+ super(from, to, duration, easing, params);
2135
+ this.fromText = '';
2136
+ this.toText = '';
2137
+ this.showCursor = false;
2138
+ this.cursorChar = '|';
2139
+ this.blinkCursor = true;
2140
+ this.beforeText = '';
2141
+ this.afterText = '';
2142
+ if ((params === null || params === void 0 ? void 0 : params.showCursor) !== undefined) {
2143
+ this.showCursor = params.showCursor;
2144
+ }
2145
+ if ((params === null || params === void 0 ? void 0 : params.cursorChar) !== undefined) {
2146
+ this.cursorChar = params.cursorChar;
2147
+ }
2148
+ if ((params === null || params === void 0 ? void 0 : params.blinkCursor) !== undefined) {
2149
+ this.blinkCursor = params.blinkCursor;
2150
+ }
2151
+ if ((params === null || params === void 0 ? void 0 : params.beforeText) !== undefined) {
2152
+ this.beforeText = params.beforeText;
2153
+ }
2154
+ if ((params === null || params === void 0 ? void 0 : params.afterText) !== undefined) {
2155
+ this.afterText = params.afterText;
2156
+ }
2157
+ }
2158
+ onFirstRun() {
2159
+ var _a, _b;
2160
+ const fromProps = this.getLastProps();
2161
+ const toProps = this.getEndProps();
2162
+ const fromText = (_a = fromProps.text) !== null && _a !== void 0 ? _a : '';
2163
+ const toText = (_b = toProps.text) !== null && _b !== void 0 ? _b : '';
2164
+ this.valid = true;
2165
+ this.fromText = fromText.toString();
2166
+ this.toText = toText.toString();
2167
+ if (!this.toText && this.toText !== '') {
2168
+ this.valid = false;
2169
+ return;
2170
+ }
2171
+ }
2172
+ onEnd(cb) {
2173
+ super.onEnd(cb);
2174
+ if (!cb) {
2175
+ if (this.showCursor && !this.blinkCursor) {
2176
+ this.target.setAttribute('text', this.beforeText + this.toText + this.cursorChar + this.afterText);
2177
+ }
2178
+ else {
2179
+ this.target.setAttribute('text', this.beforeText + this.toText + this.afterText);
2180
+ }
2181
+ }
2182
+ }
2183
+ onUpdate(end, ratio, out) {
2184
+ if (!this.valid) {
2185
+ return;
2186
+ }
2187
+ const totalChars = this.toText.length;
2188
+ const fromChars = this.fromText.length;
2189
+ let currentLength;
2190
+ let currentText;
2191
+ if (fromChars > totalChars) {
2192
+ currentLength = Math.round(fromChars - (fromChars - totalChars) * ratio);
2193
+ currentText = this.fromText.substring(0, currentLength);
2194
+ }
2195
+ else {
2196
+ currentLength = Math.round(fromChars + (totalChars - fromChars) * ratio);
2197
+ if (this.toText.startsWith(this.fromText)) {
2198
+ currentText = this.toText.substring(0, currentLength);
2199
+ }
2200
+ else {
2201
+ if (currentLength <= fromChars) {
2202
+ currentText = this.fromText.substring(0, currentLength);
2203
+ }
2204
+ else {
2205
+ currentText = this.toText.substring(0, currentLength - fromChars + Math.min(fromChars, currentLength));
2206
+ }
2207
+ }
2208
+ }
2209
+ let displayText = this.beforeText + currentText + this.afterText;
2210
+ if (this.showCursor) {
2211
+ if (this.blinkCursor) {
2212
+ const blinkRate = 0.1;
2213
+ const showCursorNow = Math.floor(ratio / blinkRate) % 2 === 0;
2214
+ if (showCursorNow) {
2215
+ displayText = this.beforeText + currentText + this.cursorChar + this.afterText;
2216
+ }
2217
+ }
2218
+ else {
2219
+ displayText = this.beforeText + currentText + this.cursorChar + this.afterText;
2220
+ }
2221
+ }
2222
+ this.target.setAttribute('text', displayText);
2223
+ }
2224
+ }
2225
+
2226
+ class ClipGraphicAnimate extends ACustomAnimate {
2227
+ constructor(from, to, duration, easing, params) {
2228
+ super(null, null, duration, easing, params);
2229
+ this.clipFromAttribute = from;
2230
+ this.clipToAttribute = to;
2231
+ this._group = params === null || params === void 0 ? void 0 : params.group;
2232
+ this._clipGraphic = params === null || params === void 0 ? void 0 : params.clipGraphic;
2233
+ }
2234
+ onBind() {
2235
+ if (this._group && this._clipGraphic) {
2236
+ this._lastClip = this._group.attribute.clip;
2237
+ this._lastPath = this._group.attribute.path;
2238
+ this._group.setAttributes({
2239
+ clip: true,
2240
+ path: [this._clipGraphic]
2241
+ }, false, { type: AttributeUpdateType.ANIMATE_BIND });
2242
+ }
2243
+ }
2244
+ onEnd() {
2245
+ if (this._group) {
2246
+ this._group.setAttributes({
2247
+ clip: this._lastClip,
2248
+ path: this._lastPath
2249
+ }, false, { type: AttributeUpdateType.ANIMATE_END });
2250
+ }
2251
+ return;
2252
+ }
2253
+ onUpdate(end, ratio, out) {
2254
+ if (!this._clipGraphic) {
2255
+ return;
2256
+ }
2257
+ const res = {};
2258
+ Object.keys(this.clipFromAttribute).forEach(k => {
2259
+ res[k] = this.clipFromAttribute[k] + (this.clipToAttribute[k] - this.clipFromAttribute[k]) * ratio;
2260
+ });
2261
+ this._clipGraphic.setAttributes(res, false, {
2262
+ type: AttributeUpdateType.ANIMATE_UPDATE,
2263
+ animationState: { ratio, end }
2264
+ });
2265
+ }
2266
+ }
2267
+ class ClipAngleAnimate extends ClipGraphicAnimate {
2268
+ constructor(from, to, duration, easing, params) {
2269
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
2270
+ const groupAttribute = (_b = (_a = params === null || params === void 0 ? void 0 : params.group) === null || _a === void 0 ? void 0 : _a.attribute) !== null && _b !== void 0 ? _b : {};
2271
+ const width = (_c = groupAttribute.width) !== null && _c !== void 0 ? _c : 0;
2272
+ const height = (_d = groupAttribute.height) !== null && _d !== void 0 ? _d : 0;
2273
+ const animationType = (_e = params === null || params === void 0 ? void 0 : params.animationType) !== null && _e !== void 0 ? _e : 'in';
2274
+ const startAngle = (_f = params === null || params === void 0 ? void 0 : params.startAngle) !== null && _f !== void 0 ? _f : 0;
2275
+ const orient = (_g = params === null || params === void 0 ? void 0 : params.orient) !== null && _g !== void 0 ? _g : 'clockwise';
2276
+ let arcStartAngle = 0;
2277
+ let arcEndAngle = 0;
2278
+ if (orient === 'anticlockwise') {
2279
+ arcEndAngle = animationType === 'in' ? startAngle + Math.PI * 2 : startAngle;
2280
+ arcEndAngle = startAngle + Math.PI * 2;
2281
+ }
2282
+ else {
2283
+ arcStartAngle = startAngle;
2284
+ arcEndAngle = animationType === 'out' ? startAngle + Math.PI * 2 : startAngle;
2285
+ }
2286
+ const arc = application.graphicService.creator.arc({
2287
+ x: (_j = (_h = params === null || params === void 0 ? void 0 : params.center) === null || _h === void 0 ? void 0 : _h.x) !== null && _j !== void 0 ? _j : width / 2,
2288
+ y: (_l = (_k = params === null || params === void 0 ? void 0 : params.center) === null || _k === void 0 ? void 0 : _k.y) !== null && _l !== void 0 ? _l : height / 2,
2289
+ outerRadius: (_m = params === null || params === void 0 ? void 0 : params.radius) !== null && _m !== void 0 ? _m : (width + height) / 2,
2290
+ innerRadius: 0,
2291
+ startAngle: arcStartAngle,
2292
+ endAngle: arcEndAngle,
2293
+ fill: true
2294
+ });
2295
+ let fromAttributes;
2296
+ let toAttributes;
2297
+ if (orient === 'anticlockwise') {
2298
+ fromAttributes = { startAngle: startAngle + Math.PI * 2 };
2299
+ toAttributes = { startAngle: startAngle };
2300
+ }
2301
+ else {
2302
+ fromAttributes = { endAngle: startAngle };
2303
+ toAttributes = { endAngle: startAngle + Math.PI * 2 };
2304
+ }
2305
+ super(animationType === 'in' ? fromAttributes : toAttributes, animationType === 'in' ? toAttributes : fromAttributes, duration, easing, { group: params === null || params === void 0 ? void 0 : params.group, clipGraphic: arc });
2306
+ }
2307
+ }
2308
+ class ClipRadiusAnimate extends ClipGraphicAnimate {
2309
+ constructor(from, to, duration, easing, params) {
2310
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2311
+ const groupAttribute = (_b = (_a = params === null || params === void 0 ? void 0 : params.group) === null || _a === void 0 ? void 0 : _a.attribute) !== null && _b !== void 0 ? _b : {};
2312
+ const width = (_c = groupAttribute.width) !== null && _c !== void 0 ? _c : 0;
2313
+ const height = (_d = groupAttribute.height) !== null && _d !== void 0 ? _d : 0;
2314
+ const animationType = (_e = params === null || params === void 0 ? void 0 : params.animationType) !== null && _e !== void 0 ? _e : 'in';
2315
+ const startRadius = (_f = params === null || params === void 0 ? void 0 : params.startRadius) !== null && _f !== void 0 ? _f : 0;
2316
+ const endRadius = (_g = params === null || params === void 0 ? void 0 : params.endRadius) !== null && _g !== void 0 ? _g : Math.sqrt((width / 2) ** 2 + (height / 2) ** 2);
2317
+ const arc = application.graphicService.creator.arc({
2318
+ x: (_j = (_h = params === null || params === void 0 ? void 0 : params.center) === null || _h === void 0 ? void 0 : _h.x) !== null && _j !== void 0 ? _j : width / 2,
2319
+ y: (_l = (_k = params === null || params === void 0 ? void 0 : params.center) === null || _k === void 0 ? void 0 : _k.y) !== null && _l !== void 0 ? _l : height / 2,
2320
+ outerRadius: animationType === 'out' ? endRadius : startRadius,
2321
+ innerRadius: 0,
2322
+ startAngle: 0,
2323
+ endAngle: Math.PI * 2,
2324
+ fill: true
2325
+ });
2326
+ const fromAttributes = { outerRadius: startRadius };
2327
+ const toAttributes = { outerRadius: endRadius };
2328
+ super(animationType === 'in' ? fromAttributes : toAttributes, animationType === 'in' ? toAttributes : fromAttributes, duration, easing, { group: params === null || params === void 0 ? void 0 : params.group, clipGraphic: arc });
2329
+ }
2330
+ }
2331
+ class ClipDirectionAnimate extends ClipGraphicAnimate {
2332
+ constructor(from, to, duration, easing, params) {
2333
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2334
+ const groupAttribute = (_b = (_a = params === null || params === void 0 ? void 0 : params.group) === null || _a === void 0 ? void 0 : _a.attribute) !== null && _b !== void 0 ? _b : {};
2335
+ const width = (_d = (_c = params === null || params === void 0 ? void 0 : params.width) !== null && _c !== void 0 ? _c : groupAttribute.width) !== null && _d !== void 0 ? _d : 0;
2336
+ const height = (_f = (_e = params === null || params === void 0 ? void 0 : params.height) !== null && _e !== void 0 ? _e : groupAttribute.height) !== null && _f !== void 0 ? _f : 0;
2337
+ const animationType = (_g = params === null || params === void 0 ? void 0 : params.animationType) !== null && _g !== void 0 ? _g : 'in';
2338
+ const direction = (_h = params === null || params === void 0 ? void 0 : params.direction) !== null && _h !== void 0 ? _h : 'x';
2339
+ const orient = (_j = params === null || params === void 0 ? void 0 : params.orient) !== null && _j !== void 0 ? _j : 'positive';
2340
+ const rect = application.graphicService.creator.rect({
2341
+ x: 0,
2342
+ y: 0,
2343
+ width: animationType === 'in' && direction === 'x' ? 0 : width,
2344
+ height: animationType === 'in' && direction === 'y' ? 0 : height,
2345
+ fill: true
2346
+ });
2347
+ let fromAttributes = {};
2348
+ let toAttributes = {};
2349
+ if (direction === 'y') {
2350
+ if (orient === 'negative') {
2351
+ fromAttributes = { y: height, height: 0 };
2352
+ toAttributes = { y: 0, height: height };
2353
+ }
2354
+ else {
2355
+ fromAttributes = { height: 0 };
2356
+ toAttributes = { height: height };
2357
+ }
2358
+ }
2359
+ else {
2360
+ if (orient === 'negative') {
2361
+ fromAttributes = { x: width, width: 0 };
2362
+ toAttributes = { x: 0, width: width };
2363
+ }
2364
+ else {
2365
+ fromAttributes = { width: 0 };
2366
+ toAttributes = { width: width };
2367
+ }
2368
+ }
2369
+ super(animationType === 'in' ? fromAttributes : toAttributes, animationType === 'in' ? toAttributes : fromAttributes, duration, easing, { group: params === null || params === void 0 ? void 0 : params.group, clipGraphic: rect });
2370
+ }
2371
+ }
2372
+
2373
+ class TagPointsUpdate extends ACustomAnimate {
2374
+ constructor(from, to, duration, easing, params) {
2375
+ var _a, _b;
2376
+ super(from, to, duration, easing, params);
2377
+ this.newPointAnimateType = (_a = params === null || params === void 0 ? void 0 : params.newPointAnimateType) !== null && _a !== void 0 ? _a : 'grow';
2378
+ this.clipRangeByDimension = (_b = params === null || params === void 0 ? void 0 : params.clipRangeByDimension) !== null && _b !== void 0 ? _b : 'x';
2379
+ }
2380
+ getPoints(attribute, cache = false) {
2381
+ if (attribute.points) {
2382
+ return attribute.points;
2383
+ }
2384
+ if (attribute.segments) {
2385
+ const points = [];
2386
+ if (!this.segmentsCache) {
2387
+ this.segmentsCache = [];
2388
+ }
2389
+ attribute.segments.map((segment) => {
2390
+ var _a, _b;
2391
+ if (segment.points) {
2392
+ points.push(...segment.points);
2393
+ }
2394
+ if (cache) {
2395
+ this.segmentsCache.push((_b = (_a = segment.points) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0);
2396
+ }
2397
+ });
2398
+ return points;
2399
+ }
2400
+ return [];
2401
+ }
2402
+ onBind() {
2403
+ const originFromPoints = this.getPoints(this.from);
2404
+ const originToPoints = this.getPoints(this.to, true);
2405
+ this.fromPoints = !originFromPoints ? [] : !Array.isArray(originFromPoints) ? [originFromPoints] : originFromPoints;
2406
+ this.toPoints = !originToPoints ? [] : !Array.isArray(originToPoints) ? [originToPoints] : originToPoints;
2407
+ const tagMap = new Map();
2408
+ this.fromPoints.forEach(point => {
2409
+ if (point.context) {
2410
+ tagMap.set(point.context, point);
2411
+ }
2412
+ });
2413
+ let firstMatchedIndex = Infinity;
2414
+ let lastMatchedIndex = -Infinity;
2415
+ let firstMatchedPoint;
2416
+ let lastMatchedPoint;
2417
+ for (let i = 0; i < this.toPoints.length; i += 1) {
2418
+ if (tagMap.has(this.toPoints[i].context)) {
2419
+ firstMatchedIndex = i;
2420
+ firstMatchedPoint = tagMap.get(this.toPoints[i].context);
2421
+ break;
2422
+ }
2423
+ }
2424
+ for (let i = this.toPoints.length - 1; i >= 0; i -= 1) {
2425
+ if (tagMap.has(this.toPoints[i].context)) {
2426
+ lastMatchedIndex = i;
2427
+ lastMatchedPoint = tagMap.get(this.toPoints[i].context);
2428
+ break;
2429
+ }
2430
+ }
2431
+ if (this.newPointAnimateType === 'clip') {
2432
+ if (this.toPoints.length !== 0) {
2433
+ if (Number.isFinite(lastMatchedIndex)) {
2434
+ this.clipRange =
2435
+ this.toPoints[lastMatchedIndex][this.clipRangeByDimension] /
2436
+ this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension];
2437
+ if (this.clipRange === 1) {
2438
+ this.shrinkClipRange =
2439
+ this.toPoints[lastMatchedIndex][this.clipRangeByDimension] /
2440
+ this.fromPoints[this.fromPoints.length - 1][this.clipRangeByDimension];
2441
+ }
2442
+ if (!isValidNumber(this.clipRange)) {
2443
+ this.clipRange = 0;
2444
+ }
2445
+ else {
2446
+ this.clipRange = clamp(this.clipRange, 0, 1);
2447
+ }
2448
+ }
2449
+ else {
2450
+ this.clipRange = 0;
2451
+ }
2452
+ }
2453
+ }
2454
+ let prevMatchedPoint = this.toPoints[0];
2455
+ this.interpolatePoints = this.toPoints.map((point, index) => {
2456
+ const matchedPoint = tagMap.get(point.context);
2457
+ if (matchedPoint) {
2458
+ prevMatchedPoint = matchedPoint;
2459
+ return [matchedPoint, point];
2460
+ }
2461
+ if (this.newPointAnimateType === 'appear' || this.newPointAnimateType === 'clip') {
2462
+ return [point, point];
2463
+ }
2464
+ if (index < firstMatchedIndex && firstMatchedPoint) {
2465
+ return [firstMatchedPoint, point];
2466
+ }
2467
+ else if (index > lastMatchedIndex && lastMatchedPoint) {
2468
+ return [lastMatchedPoint, point];
2469
+ }
2470
+ return [prevMatchedPoint, point];
2471
+ });
2472
+ this.points = this.interpolatePoints.map(interpolate => {
2473
+ const fromPoint = interpolate[0];
2474
+ const toPoint = interpolate[1];
2475
+ const newPoint = new Point(fromPoint.x, fromPoint.y, fromPoint.x1, fromPoint.y1);
2476
+ newPoint.defined = toPoint.defined;
2477
+ newPoint.context = toPoint.context;
2478
+ return newPoint;
2479
+ });
2480
+ }
2481
+ onFirstRun() {
2482
+ const lastClipRange = this.target.attribute.clipRange;
2483
+ if (isValidNumber(lastClipRange * this.clipRange)) {
2484
+ this.clipRange *= lastClipRange;
2485
+ }
2486
+ }
2487
+ onUpdate(end, ratio, out) {
2488
+ this.points = this.points.map((point, index) => {
2489
+ const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
2490
+ newPoint.context = point.context;
2491
+ return newPoint;
2492
+ });
2493
+ if (this.clipRange) {
2494
+ if (this.shrinkClipRange) {
2495
+ if (!end) {
2496
+ out.points = this.fromPoints;
2497
+ out.clipRange = this.clipRange - (this.clipRange - this.shrinkClipRange) * ratio;
2498
+ }
2499
+ else {
2500
+ out.points = this.toPoints;
2501
+ out.clipRange = 1;
2502
+ }
2503
+ return;
2504
+ }
2505
+ out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
2506
+ }
2507
+ if (this.segmentsCache && this.to.segments) {
2508
+ let start = 0;
2509
+ out.segments = this.to.segments.map((segment, index) => {
2510
+ const end = start + this.segmentsCache[index];
2511
+ const points = this.points.slice(start, end);
2512
+ start = end;
2513
+ return Object.assign(Object.assign({}, segment), { points });
2514
+ });
2515
+ }
2516
+ else {
2517
+ out.points = this.points;
2518
+ }
2519
+ }
2520
+ }
2521
+
2522
+ class GroupFadeIn extends ACustomAnimate {
2523
+ getEndProps() {
2524
+ return {};
2525
+ }
2526
+ onBind() {
2527
+ this.target.setTheme({
2528
+ common: {
2529
+ opacity: 0
2530
+ }
2531
+ });
2532
+ return;
2533
+ }
2534
+ onEnd() {
2535
+ this.target.setTheme({
2536
+ common: {
2537
+ opacity: 1
2538
+ }
2539
+ });
2540
+ return;
2541
+ }
2542
+ onUpdate(end, ratio, out) {
2543
+ this.target.setTheme({
2544
+ common: {
2545
+ opacity: ratio
2546
+ }
2547
+ });
2548
+ }
2549
+ }
2550
+ class GroupFadeOut extends ACustomAnimate {
2551
+ getEndProps() {
2552
+ return {};
2553
+ }
2554
+ onBind() {
2555
+ this.target.setTheme({
2556
+ common: {
2557
+ opacity: 1
2558
+ }
2559
+ });
2560
+ return;
2561
+ }
2562
+ onEnd() {
2563
+ this.target.setTheme({
2564
+ common: {
2565
+ opacity: 0
2566
+ }
2567
+ });
2568
+ return;
2569
+ }
2570
+ onUpdate(end, ratio, out) {
2571
+ this.target.setTheme({
2572
+ common: {
2573
+ opacity: 1 - ratio
2574
+ }
2575
+ });
2576
+ }
2577
+ }
2578
+
2579
+ class RotateBySphereAnimate extends ACustomAnimate {
2580
+ onStart() {
2581
+ const { center, r } = typeof this.params === 'function' ? this.params() : this.params;
2582
+ const startX = this.target.getComputedAttribute('x');
2583
+ const startY = this.target.getComputedAttribute('y');
2584
+ const startZ = this.target.getComputedAttribute('z');
2585
+ const phi = Math.acos((startY - center.y) / r);
2586
+ let theta = Math.acos((startX - center.x) / r / Math.sin(phi));
2587
+ if (startZ - center.z < 0) {
2588
+ theta = pi2 - theta;
2589
+ }
2590
+ this.theta = theta;
2591
+ this.phi = phi;
2592
+ }
2593
+ onBind() {
2594
+ return;
2595
+ }
2596
+ onEnd() {
2597
+ return;
2598
+ }
2599
+ onUpdate(end, ratio, out) {
2600
+ if (this.phi == null || this.theta == null) {
2601
+ return;
2602
+ }
2603
+ const { center, r, cb } = typeof this.params === 'function' ? this.params() : this.params;
2604
+ const deltaAngle = Math.PI * 2 * ratio;
2605
+ const theta = this.theta + deltaAngle;
2606
+ const phi = this.phi;
2607
+ const x = r * Math.sin(phi) * Math.cos(theta) + center.x;
2608
+ const y = r * Math.cos(phi) + center.y;
2609
+ const z = r * Math.sin(phi) * Math.sin(theta) + center.z;
2610
+ out.x = x;
2611
+ out.y = y;
2612
+ out.z = z;
2613
+ out.alpha = theta + pi / 2;
2614
+ while (out.alpha > pi2) {
2615
+ out.alpha -= pi2;
2616
+ }
2617
+ out.alpha = pi2 - out.alpha;
2618
+ out.zIndex = out.z * -10000;
2619
+ cb && cb(out);
2620
+ }
2621
+ }
2622
+
2623
+ class CommonIn extends ACustomAnimate {
2624
+ constructor(from, to, duration, easing, params) {
2625
+ super(from, to, duration, easing, params);
2626
+ }
2627
+ onBind() {
2628
+ var _a;
2629
+ const attrs = this.target.getFinalAttribute();
2630
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : {};
2631
+ const to = {};
2632
+ const from = {};
2633
+ this.keys.forEach(key => {
2634
+ var _a, _b;
2635
+ to[key] = (_a = attrs === null || attrs === void 0 ? void 0 : attrs[key]) !== null && _a !== void 0 ? _a : 1;
2636
+ from[key] = (_b = fromAttrs === null || fromAttrs === void 0 ? void 0 : fromAttrs[key]) !== null && _b !== void 0 ? _b : 0;
2637
+ });
2638
+ this.props = to;
2639
+ this.propKeys = this.keys;
2640
+ this.animate.reSyncProps();
2641
+ this.from = from;
2642
+ this.to = to;
2643
+ this.target.setAttributes(from);
2644
+ }
2645
+ onEnd(cb) {
2646
+ super.onEnd(cb);
2647
+ }
2648
+ onUpdate(end, ratio, out) {
2649
+ this.propKeys.forEach(key => {
2650
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
2651
+ });
2652
+ this.target.setAttributes(out);
2653
+ }
2654
+ }
2655
+ class CommonOut extends ACustomAnimate {
2656
+ constructor(from, to, duration, easing, params) {
2657
+ super(from, to, duration, easing, params);
2658
+ }
2659
+ onBind() {
2660
+ const attrs = this.target.getFinalAttribute();
2661
+ const to = {};
2662
+ const from = {};
2663
+ this.keys.forEach(key => {
2664
+ var _a;
2665
+ to[key] = 0;
2666
+ from[key] = (_a = attrs === null || attrs === void 0 ? void 0 : attrs[key]) !== null && _a !== void 0 ? _a : 1;
2667
+ });
2668
+ this.props = to;
2669
+ this.propKeys = this.keys;
2670
+ this.animate.reSyncProps();
2671
+ this.from = from;
2672
+ this.to = to;
2673
+ this.target.setAttributes(from);
2674
+ }
2675
+ onEnd(cb) {
2676
+ super.onEnd(cb);
2677
+ }
2678
+ onUpdate(end, ratio, out) {
2679
+ this.propKeys.forEach(key => {
2680
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
2681
+ });
2682
+ this.target.setAttributes(out);
2683
+ }
2684
+ }
2685
+
2686
+ class ClipIn extends CommonIn {
2687
+ constructor(from, to, duration, easing, params) {
2688
+ super(from, to, duration, easing, params);
2689
+ this.keys = ['clipRange'];
2690
+ }
2691
+ }
2692
+ class ClipOut extends CommonOut {
2693
+ constructor(from, to, duration, easing, params) {
2694
+ super(from, to, duration, easing, params);
2695
+ this.keys = ['clipRange'];
2696
+ }
2697
+ }
2698
+
2699
+ class FadeIn extends CommonIn {
2700
+ constructor(from, to, duration, easing, params) {
2701
+ super(from, to, duration, easing, params);
2702
+ this.keys = ['opacity'];
2703
+ }
2704
+ }
2705
+ class FadeOut extends CommonOut {
2706
+ constructor(from, to, duration, easing, params) {
2707
+ super(from, to, duration, easing, params);
2708
+ this.keys = ['opacity'];
2709
+ }
2710
+ }
2711
+
2712
+ const growAngleInIndividual = (graphic, options, animationParameters) => {
2713
+ const attrs = graphic.getFinalAttribute();
2714
+ if (options && options.orient === 'anticlockwise') {
2715
+ return {
2716
+ from: { startAngle: attrs === null || attrs === void 0 ? void 0 : attrs.endAngle },
2717
+ to: { startAngle: attrs === null || attrs === void 0 ? void 0 : attrs.startAngle }
2718
+ };
2719
+ }
2720
+ return {
2721
+ from: { endAngle: attrs === null || attrs === void 0 ? void 0 : attrs.startAngle },
2722
+ to: { endAngle: attrs === null || attrs === void 0 ? void 0 : attrs.endAngle }
2723
+ };
2724
+ };
2725
+ const growAngleInOverall = (graphic, options, animationParameters) => {
2726
+ const attrs = graphic.getFinalAttribute();
2727
+ if (options && options.orient === 'anticlockwise') {
2728
+ const overallValue = isNumber(options.overall) ? options.overall : Math.PI * 2;
2729
+ return {
2730
+ from: {
2731
+ startAngle: overallValue,
2732
+ endAngle: overallValue
2733
+ },
2734
+ to: {
2735
+ startAngle: attrs === null || attrs === void 0 ? void 0 : attrs.startAngle,
2736
+ endAngle: attrs === null || attrs === void 0 ? void 0 : attrs.endAngle
2737
+ }
2738
+ };
2739
+ }
2740
+ const overallValue = isNumber(options === null || options === void 0 ? void 0 : options.overall) ? options.overall : 0;
2741
+ return {
2742
+ from: {
2743
+ startAngle: overallValue,
2744
+ endAngle: overallValue
2745
+ },
2746
+ to: {
2747
+ startAngle: attrs === null || attrs === void 0 ? void 0 : attrs.startAngle,
2748
+ endAngle: attrs === null || attrs === void 0 ? void 0 : attrs.endAngle
2749
+ }
2750
+ };
2751
+ };
2752
+ const growAngleIn = (graphic, options, animationParameters) => {
2753
+ var _a;
2754
+ return ((_a = options === null || options === void 0 ? void 0 : options.overall) !== null && _a !== void 0 ? _a : false) !== false
2755
+ ? growAngleInOverall(graphic, options)
2756
+ : growAngleInIndividual(graphic, options);
2757
+ };
2758
+ const growAngleOutIndividual = (graphic, options, animationParameters) => {
2759
+ const attrs = graphic.getFinalAttribute();
2760
+ if (options && options.orient === 'anticlockwise') {
2761
+ return {
2762
+ from: { startAngle: attrs.startAngle },
2763
+ to: { startAngle: attrs === null || attrs === void 0 ? void 0 : attrs.endAngle }
2764
+ };
2765
+ }
2766
+ return {
2767
+ from: { endAngle: attrs.endAngle },
2768
+ to: { endAngle: attrs === null || attrs === void 0 ? void 0 : attrs.startAngle }
2769
+ };
2770
+ };
2771
+ const growAngleOutOverall = (graphic, options, animationParameters) => {
2772
+ const attrs = graphic.getFinalAttribute();
2773
+ if (options && options.orient === 'anticlockwise') {
2774
+ const overallValue = isNumber(options.overall) ? options.overall : Math.PI * 2;
2775
+ return {
2776
+ from: {
2777
+ startAngle: attrs.startAngle,
2778
+ endAngle: attrs.endAngle
2779
+ },
2780
+ to: {
2781
+ startAngle: overallValue,
2782
+ endAngle: overallValue
2783
+ }
2784
+ };
2785
+ }
2786
+ const overallValue = isNumber(options === null || options === void 0 ? void 0 : options.overall) ? options.overall : 0;
2787
+ return {
2788
+ from: {
2789
+ startAngle: attrs.startAngle,
2790
+ endAngle: attrs.endAngle
2791
+ },
2792
+ to: {
2793
+ startAngle: overallValue,
2794
+ endAngle: overallValue
2795
+ }
2796
+ };
2797
+ };
2798
+ const growAngleOut = (graphic, options, animationParameters) => {
2799
+ var _a;
2800
+ return ((_a = options === null || options === void 0 ? void 0 : options.overall) !== null && _a !== void 0 ? _a : false) !== false
2801
+ ? growAngleOutOverall(graphic, options)
2802
+ : growAngleOutIndividual(graphic, options);
2803
+ };
2804
+ let GworPointsBase$2 = class GworPointsBase extends ACustomAnimate {
2805
+ constructor(from, to, duration, easing, params) {
2806
+ super(from, to, duration, easing, params);
2807
+ }
2808
+ onUpdate(end, ratio, out) {
2809
+ this.propKeys.forEach(key => {
2810
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
2811
+ });
2812
+ this.target.setAttributes(out);
2813
+ }
2814
+ };
2815
+ class GrowAngleIn extends GworPointsBase$2 {
2816
+ onBind() {
2817
+ var _a;
2818
+ const { from, to } = growAngleIn(this.target, this.params.options, this.params);
2819
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : from;
2820
+ this.props = to;
2821
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
2822
+ this.animate.reSyncProps();
2823
+ this.from = fromAttrs;
2824
+ this.to = to;
2825
+ this.target.setAttributes(fromAttrs);
2826
+ }
2827
+ }
2828
+ class GrowAngleOut extends GworPointsBase$2 {
2829
+ onBind() {
2830
+ var _a;
2831
+ const { from, to } = growAngleOut(this.target, this.params.options, this.params);
2832
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : from;
2833
+ this.props = to;
2834
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
2835
+ this.animate.reSyncProps();
2836
+ this.from = fromAttrs;
2837
+ this.to = to;
2838
+ this.target.setAttributes(fromAttrs);
2839
+ }
2840
+ }
2841
+
2842
+ const growCenterIn = (graphic, options, animationParameters) => {
2843
+ const attrs = graphic.getFinalAttribute();
2844
+ switch (options === null || options === void 0 ? void 0 : options.direction) {
2845
+ case 'x': {
2846
+ const x = attrs.x;
2847
+ const x1 = attrs.x1;
2848
+ const width = attrs.width;
2849
+ return {
2850
+ from: isValid(width)
2851
+ ? {
2852
+ x: x + width / 2,
2853
+ x1: undefined,
2854
+ width: 0
2855
+ }
2856
+ : {
2857
+ x: (x + x1) / 2,
2858
+ x1: (x + x1) / 2,
2859
+ width: undefined
2860
+ },
2861
+ to: { x, x1, width }
2862
+ };
2863
+ }
2864
+ case 'y': {
2865
+ const y = attrs.y;
2866
+ const y1 = attrs.y1;
2867
+ const height = attrs.height;
2868
+ return {
2869
+ from: isValid(height)
2870
+ ? {
2871
+ y: y + height / 2,
2872
+ y1: undefined,
2873
+ height: 0
2874
+ }
2875
+ : {
2876
+ y: (y + y1) / 2,
2877
+ y1: (y + y1) / 2,
2878
+ height: undefined
2879
+ },
2880
+ to: { y, y1, height }
2881
+ };
2882
+ }
2883
+ case 'xy':
2884
+ default: {
2885
+ const x = attrs.x;
2886
+ const x1 = attrs.x1;
2887
+ const width = attrs.width;
2888
+ const y = attrs.y;
2889
+ const y1 = attrs.y1;
2890
+ const height = attrs.height;
2891
+ const from = {};
2892
+ if (isValid(width)) {
2893
+ from.x = x + width / 2;
2894
+ from.width = 0;
2895
+ from.x1 = undefined;
2896
+ }
2897
+ else {
2898
+ from.x = (x + x1) / 2;
2899
+ from.x1 = (x + x1) / 2;
2900
+ from.width = undefined;
2901
+ }
2902
+ if (isValid(height)) {
2903
+ from.y = y + height / 2;
2904
+ from.height = 0;
2905
+ from.y1 = undefined;
2906
+ }
2907
+ else {
2908
+ from.y = (y + y1) / 2;
2909
+ from.y1 = (y + y1) / 2;
2910
+ from.height = undefined;
2911
+ }
2912
+ return {
2913
+ from,
2914
+ to: { x, y, x1, y1, width, height }
2915
+ };
2916
+ }
2917
+ }
2918
+ };
2919
+ const growCenterOut = (graphic, options, animationParameters) => {
2920
+ const attrs = graphic.getFinalAttribute();
2921
+ switch (options === null || options === void 0 ? void 0 : options.direction) {
2922
+ case 'x': {
2923
+ const x = attrs.x;
2924
+ const x1 = attrs.x1;
2925
+ const width = attrs.width;
2926
+ return {
2927
+ to: isValid(width)
2928
+ ? {
2929
+ x: x + width / 2,
2930
+ x1: undefined,
2931
+ width: 0
2932
+ }
2933
+ : {
2934
+ x: (x + x1) / 2,
2935
+ x1: (x + x1) / 2,
2936
+ width: undefined
2937
+ }
2938
+ };
2939
+ }
2940
+ case 'y': {
2941
+ const y = attrs.y;
2942
+ const y1 = attrs.y1;
2943
+ const height = attrs.height;
2944
+ return {
2945
+ to: isValid(height)
2946
+ ? {
2947
+ y: y + height / 2,
2948
+ y1: undefined,
2949
+ height: 0
2950
+ }
2951
+ : {
2952
+ y: (y + y1) / 2,
2953
+ y1: (y + y1) / 2,
2954
+ height: undefined
2955
+ }
2956
+ };
2957
+ }
2958
+ case 'xy':
2959
+ default: {
2960
+ const x = attrs.x;
2961
+ const y = attrs.y;
2962
+ const x1 = attrs.x1;
2963
+ const y1 = attrs.y1;
2964
+ const width = attrs.width;
2965
+ const height = attrs.height;
2966
+ const to = {};
2967
+ if (isValid(width)) {
2968
+ to.x = x + width / 2;
2969
+ to.width = 0;
2970
+ to.x1 = undefined;
2971
+ }
2972
+ else {
2973
+ to.x = (x + x1) / 2;
2974
+ to.x1 = (x + x1) / 2;
2975
+ to.width = undefined;
2976
+ }
2977
+ if (isValid(height)) {
2978
+ to.y = y + height / 2;
2979
+ to.height = 0;
2980
+ to.y1 = undefined;
2981
+ }
2982
+ else {
2983
+ to.y = (y + y1) / 2;
2984
+ to.y1 = (y + y1) / 2;
2985
+ to.height = undefined;
2986
+ }
2987
+ return {
2988
+ to
2989
+ };
2990
+ }
2991
+ }
2992
+ };
2993
+ class GrowCenterIn extends ACustomAnimate {
2994
+ constructor(from, to, duration, easing, params) {
2995
+ super(from, to, duration, easing, params);
2996
+ }
2997
+ onBind() {
2998
+ var _a;
2999
+ const { from, to } = growCenterIn(this.target, this.params.options, this.params);
3000
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : from;
3001
+ this.props = to;
3002
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3003
+ this.animate.reSyncProps();
3004
+ this.from = fromAttrs;
3005
+ this.to = to;
3006
+ this.target.setAttributes(fromAttrs);
3007
+ }
3008
+ onEnd(cb) {
3009
+ super.onEnd(cb);
3010
+ }
3011
+ onUpdate(end, ratio, out) {
3012
+ this.propKeys.forEach(key => {
3013
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
3014
+ });
3015
+ this.target.setAttributes(out);
3016
+ }
3017
+ }
3018
+ class GrowCenterOut extends ACustomAnimate {
3019
+ constructor(from, to, duration, easing, params) {
3020
+ super(from, to, duration, easing, params);
3021
+ }
3022
+ onBind() {
3023
+ const attrs = this.target.getFinalAttribute();
3024
+ const { from, to } = growCenterOut(this.target, this.params.options, this.params);
3025
+ this.props = to;
3026
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3027
+ this.animate.reSyncProps();
3028
+ this.from = from || attrs;
3029
+ this.to = to;
3030
+ }
3031
+ onEnd(cb) {
3032
+ super.onEnd(cb);
3033
+ }
3034
+ onUpdate(end, ratio, out) {
3035
+ this.propKeys.forEach(key => {
3036
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
3037
+ });
3038
+ this.target.setAttributes(out);
3039
+ }
3040
+ }
3041
+
3042
+ function growHeightInIndividual(graphic, options, animationParameters) {
3043
+ const attrs = graphic.getFinalAttribute();
3044
+ const y = attrs.y;
3045
+ const y1 = attrs.y1;
3046
+ const height = attrs.height;
3047
+ if (options && options.orient === 'negative') {
3048
+ const computedY1 = isValid(height) ? Math.max(y, y + height) : Math.max(y, y1);
3049
+ return {
3050
+ from: { y: computedY1, y1: isNil(y1) ? undefined : computedY1, height: isNil(height) ? undefined : 0 },
3051
+ to: { y: y, y1: y1, height: height }
3052
+ };
3053
+ }
3054
+ const computedY = isValid(height) ? Math.min(y, y + height) : Math.min(y, y1);
3055
+ return {
3056
+ from: { y: computedY, y1: isNil(y1) ? undefined : computedY, height: isNil(height) ? undefined : 0 },
3057
+ to: { y: y, y1: y1, height: height }
3058
+ };
3059
+ }
3060
+ function growHeightInOverall(graphic, options, animationParameters) {
3061
+ var _a;
3062
+ const attrs = graphic.getFinalAttribute();
3063
+ const y = attrs.y;
3064
+ const y1 = attrs.y1;
3065
+ const height = attrs.height;
3066
+ let overallValue;
3067
+ if (options && options.orient === 'negative') {
3068
+ if (isNumber(options.overall)) {
3069
+ overallValue = options.overall;
3070
+ }
3071
+ else if (animationParameters.group) {
3072
+ overallValue = (_a = animationParameters.groupHeight) !== null && _a !== void 0 ? _a : animationParameters.group.getBounds().height();
3073
+ animationParameters.groupHeight = overallValue;
3074
+ }
3075
+ else {
3076
+ overallValue = animationParameters.height;
3077
+ }
3078
+ }
3079
+ else {
3080
+ overallValue = isNumber(options === null || options === void 0 ? void 0 : options.overall) ? options.overall : 0;
3081
+ }
3082
+ return {
3083
+ from: { y: overallValue, y1: isNil(y1) ? undefined : overallValue, height: isNil(height) ? undefined : 0 },
3084
+ to: { y: y, y1: y1, height: height }
3085
+ };
3086
+ }
3087
+ const growHeightIn = (graphic, options, animationParameters) => {
3088
+ var _a;
3089
+ return ((_a = options === null || options === void 0 ? void 0 : options.overall) !== null && _a !== void 0 ? _a : false) !== false
3090
+ ? growHeightInOverall(graphic, options, animationParameters)
3091
+ : growHeightInIndividual(graphic, options);
3092
+ };
3093
+ class GrowHeightIn extends ACustomAnimate {
3094
+ constructor(from, to, duration, easing, params) {
3095
+ super(from, to, duration, easing, params);
3096
+ }
3097
+ onBind() {
3098
+ var _a;
3099
+ const { from, to } = growHeightIn(this.target, this.params.options, this.params);
3100
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : from;
3101
+ this.props = to;
3102
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3103
+ this.animate.reSyncProps();
3104
+ this.from = fromAttrs;
3105
+ this.to = to;
3106
+ this.target.setAttributes(fromAttrs);
3107
+ }
3108
+ onEnd(cb) {
3109
+ super.onEnd(cb);
3110
+ }
3111
+ onUpdate(end, ratio, out) {
3112
+ this.propKeys.forEach(key => {
3113
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
3114
+ });
3115
+ this.target.setAttributes(out);
3116
+ }
3117
+ }
3118
+ function growHeightOutIndividual(graphic, options, animationParameters) {
3119
+ const attrs = graphic.getFinalAttribute();
3120
+ const y = attrs.y;
3121
+ const y1 = attrs.y1;
3122
+ const height = attrs.height;
3123
+ if (options && options.orient === 'negative') {
3124
+ const computedY1 = isValid(height) ? Math.max(y, y + height) : Math.max(y, y1);
3125
+ return {
3126
+ to: { y: computedY1, y1: isNil(y1) ? undefined : computedY1, height: isNil(height) ? undefined : 0 }
3127
+ };
3128
+ }
3129
+ const computedY = isValid(height) ? Math.min(y, y + height) : Math.min(y, y1);
3130
+ return {
3131
+ to: { y: computedY, y1: isNil(y1) ? undefined : computedY, height: isNil(height) ? undefined : 0 }
3132
+ };
3133
+ }
3134
+ function growHeightOutOverall(graphic, options, animationParameters) {
3135
+ var _a;
3136
+ const attrs = graphic.getFinalAttribute();
3137
+ const y1 = attrs.y1;
3138
+ const height = attrs.height;
3139
+ let overallValue;
3140
+ if (options && options.orient === 'negative') {
3141
+ if (isNumber(options.overall)) {
3142
+ overallValue = options.overall;
3143
+ }
3144
+ else if (animationParameters.group) {
3145
+ overallValue = (_a = animationParameters.groupHeight) !== null && _a !== void 0 ? _a : animationParameters.group.getBounds().height();
3146
+ animationParameters.groupHeight = overallValue;
3147
+ }
3148
+ else {
3149
+ overallValue = animationParameters.height;
3150
+ }
3151
+ }
3152
+ else {
3153
+ overallValue = isNumber(options === null || options === void 0 ? void 0 : options.overall) ? options.overall : 0;
3154
+ }
3155
+ return {
3156
+ to: { y: overallValue, y1: isNil(y1) ? undefined : overallValue, height: isNil(height) ? undefined : 0 }
3157
+ };
3158
+ }
3159
+ const growHeightOut = (graphic, options, animationParameters) => {
3160
+ var _a;
3161
+ return ((_a = options === null || options === void 0 ? void 0 : options.overall) !== null && _a !== void 0 ? _a : false) !== false
3162
+ ? growHeightOutOverall(graphic, options, animationParameters)
3163
+ : growHeightOutIndividual(graphic, options);
3164
+ };
3165
+ class GrowHeightOut extends ACustomAnimate {
3166
+ constructor(from, to, duration, easing, params) {
3167
+ super(from, to, duration, easing, params);
3168
+ }
3169
+ onBind() {
3170
+ const attrs = this.target.getFinalAttribute();
3171
+ const { from, to } = growHeightOut(this.target, this.params.options, this.params);
3172
+ this.props = to;
3173
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3174
+ this.animate.reSyncProps();
3175
+ this.from = from || attrs;
3176
+ this.to = to;
3177
+ }
3178
+ onEnd(cb) {
3179
+ super.onEnd(cb);
3180
+ }
3181
+ onUpdate(end, ratio, out) {
3182
+ this.propKeys.forEach(key => {
3183
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
3184
+ });
3185
+ this.target.setAttributes(out);
3186
+ }
3187
+ }
3188
+
3189
+ const getCenterPoints = (graphic, options, animationParameters) => {
3190
+ const attrs = graphic.getFinalAttribute();
3191
+ const points = attrs.points;
3192
+ const center = { x: 0, y: 0 };
3193
+ points.forEach(point => {
3194
+ center.x += point.x;
3195
+ center.y += point.y;
3196
+ });
3197
+ center.x /= points.length;
3198
+ center.y /= points.length;
3199
+ if (options && options.center) {
3200
+ if (isValidNumber(options.center.x)) {
3201
+ center.x = options.center.x;
3202
+ }
3203
+ if (isValidNumber(options.center.y)) {
3204
+ center.y = options.center.y;
3205
+ }
3206
+ }
3207
+ if (graphic.type === 'area') {
3208
+ center.x1 = center.x;
3209
+ center.y1 = center.y;
3210
+ }
3211
+ return points.map(point => Object.assign({}, point, center));
3212
+ };
3213
+ const growPointsIn = (graphic, options, animationParameters) => {
3214
+ const attrs = graphic.getFinalAttribute();
3215
+ return {
3216
+ from: { points: getCenterPoints(graphic, options) },
3217
+ to: { points: attrs.points }
3218
+ };
3219
+ };
3220
+ const growPointsOut = (graphic, options, animationParameters) => {
3221
+ const attrs = graphic.getFinalAttribute();
3222
+ return {
3223
+ from: { points: attrs.points },
3224
+ to: { points: getCenterPoints(graphic, options) }
3225
+ };
3226
+ };
3227
+ let GworPointsBase$1 = class GworPointsBase extends ACustomAnimate {
3228
+ constructor(from, to, duration, easing, params) {
3229
+ super(from, to, duration, easing, params);
3230
+ }
3231
+ onUpdate(end, ratio, out) {
3232
+ var _a, _b;
3233
+ const fromPoints = (_a = this.from) === null || _a === void 0 ? void 0 : _a.points;
3234
+ const toPoints = (_b = this.to) === null || _b === void 0 ? void 0 : _b.points;
3235
+ if (!fromPoints || !toPoints) {
3236
+ return;
3237
+ }
3238
+ out.points = fromPoints.map((point, index) => {
3239
+ const newPoint = pointInterpolation(fromPoints[index], toPoints[index], ratio);
3240
+ return newPoint;
3241
+ });
3242
+ this.target.setAttributes(out);
3243
+ }
3244
+ };
3245
+ class GrowPointsIn extends GworPointsBase$1 {
3246
+ onBind() {
3247
+ var _a;
3248
+ if (['area', 'line'].includes(this.target.type)) {
3249
+ const { from, to } = growPointsIn(this.target, this.params.options, this.params);
3250
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : from;
3251
+ this.props = to;
3252
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3253
+ this.animate.reSyncProps();
3254
+ this.from = fromAttrs;
3255
+ this.to = to;
3256
+ this.target.setAttributes(fromAttrs);
3257
+ }
3258
+ else {
3259
+ this.valid = false;
3260
+ }
3261
+ }
3262
+ }
3263
+ class GrowPointsOut extends GworPointsBase$1 {
3264
+ onBind() {
3265
+ if (['area', 'line'].includes(this.target.type)) {
3266
+ const attrs = this.target.getFinalAttribute();
3267
+ const { from, to } = growPointsOut(this.target, this.params.options, this.params);
3268
+ this.props = to;
3269
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3270
+ this.animate.reSyncProps();
3271
+ this.from = from || attrs;
3272
+ this.to = to;
3273
+ }
3274
+ else {
3275
+ this.valid = false;
3276
+ }
3277
+ }
3278
+ }
3279
+ const changePointsX = (graphic, options, animationParameters) => {
3280
+ const attrs = graphic.getFinalAttribute();
3281
+ const points = attrs.points;
3282
+ return points.map((point) => {
3283
+ var _a;
3284
+ if (options && options.orient === 'negative') {
3285
+ let groupRight = animationParameters.width;
3286
+ if (animationParameters.group) {
3287
+ groupRight = (_a = animationParameters.groupWidth) !== null && _a !== void 0 ? _a : animationParameters.group.getBounds().width();
3288
+ animationParameters.groupWidth = groupRight;
3289
+ }
3290
+ return Object.assign(Object.assign({}, point), { x: groupRight, y: point.y, x1: groupRight, y1: point.y1, defined: point.defined !== false });
3291
+ }
3292
+ return Object.assign(Object.assign({}, point), { x: 0, y: point.y, x1: 0, y1: point.y1, defined: point.defined !== false });
3293
+ });
3294
+ };
3295
+ const growPointsXIn = (graphic, options, animationParameters) => {
3296
+ const attrs = graphic.getFinalAttribute();
3297
+ return {
3298
+ from: { points: changePointsX(graphic, options, animationParameters) },
3299
+ to: { points: attrs.points }
3300
+ };
3301
+ };
3302
+ const growPointsXOut = (graphic, options, animationParameters) => {
3303
+ const attrs = graphic.getFinalAttribute();
3304
+ return {
3305
+ from: { points: attrs.points },
3306
+ to: { points: changePointsX(graphic, options, animationParameters) }
3307
+ };
3308
+ };
3309
+ class GrowPointsXIn extends GworPointsBase$1 {
3310
+ onBind() {
3311
+ var _a;
3312
+ if (['area', 'line'].includes(this.target.type)) {
3313
+ const { from, to } = growPointsXIn(this.target, this.params.options, this.params);
3314
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : from;
3315
+ this.props = to;
3316
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3317
+ this.animate.reSyncProps();
3318
+ this.from = fromAttrs;
3319
+ this.to = to;
3320
+ this.target.setAttributes(fromAttrs);
3321
+ }
3322
+ else {
3323
+ this.valid = false;
3324
+ }
3325
+ }
3326
+ }
3327
+ class GrowPointsXOut extends GworPointsBase$1 {
3328
+ onBind() {
3329
+ if (['area', 'line'].includes(this.target.type)) {
3330
+ const attrs = this.target.getFinalAttribute();
3331
+ const { from, to } = growPointsXOut(this.target, this.params.options, this.params);
3332
+ this.props = to;
3333
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3334
+ this.animate.reSyncProps();
3335
+ this.from = from || attrs;
3336
+ this.to = to;
3337
+ }
3338
+ else {
3339
+ this.valid = false;
3340
+ }
3341
+ }
3342
+ }
3343
+ const changePointsY = (graphic, options, animationParameters) => {
3344
+ const attrs = graphic.getFinalAttribute();
3345
+ const points = attrs.points;
3346
+ return points.map((point) => {
3347
+ var _a;
3348
+ if (options && options.orient === 'negative') {
3349
+ let groupBottom = animationParameters.height;
3350
+ if (animationParameters.group) {
3351
+ groupBottom = (_a = animationParameters.groupHeight) !== null && _a !== void 0 ? _a : animationParameters.group.getBounds().height();
3352
+ animationParameters.groupHeight = groupBottom;
3353
+ }
3354
+ return Object.assign(Object.assign({}, point), { x: point.x, y: groupBottom, x1: point.x1, y1: groupBottom, defined: point.defined !== false });
3355
+ }
3356
+ return Object.assign(Object.assign({}, point), { x: point.x, y: 0, x1: point.x1, y1: 0, defined: point.defined !== false });
3357
+ });
3358
+ };
3359
+ const growPointsYIn = (graphic, options, animationParameters) => {
3360
+ const attrs = graphic.getFinalAttribute();
3361
+ return {
3362
+ from: { points: changePointsY(graphic, options, animationParameters) },
3363
+ to: { points: attrs.points }
3364
+ };
3365
+ };
3366
+ const growPointsYOut = (graphic, options, animationParameters) => {
3367
+ const attrs = graphic.getFinalAttribute();
3368
+ return {
3369
+ from: { points: attrs.points },
3370
+ to: { points: changePointsY(graphic, options, animationParameters) }
3371
+ };
3372
+ };
3373
+ class GrowPointsYIn extends GworPointsBase$1 {
3374
+ onBind() {
3375
+ var _a;
3376
+ if (['area', 'line'].includes(this.target.type)) {
3377
+ const { from, to } = growPointsYIn(this.target, this.params.options, this.params);
3378
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : from;
3379
+ this.props = to;
3380
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3381
+ this.animate.reSyncProps();
3382
+ this.from = fromAttrs;
3383
+ this.to = to;
3384
+ this.target.setAttributes(fromAttrs);
3385
+ }
3386
+ else {
3387
+ this.valid = false;
3388
+ }
3389
+ }
3390
+ }
3391
+ class GrowPointsYOut extends GworPointsBase$1 {
3392
+ onBind() {
3393
+ if (['area', 'line'].includes(this.target.type)) {
3394
+ const attrs = this.target.getFinalAttribute();
3395
+ const { from, to } = growPointsYOut(this.target, this.params.options, this.params);
3396
+ this.props = to;
3397
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3398
+ this.animate.reSyncProps();
3399
+ this.from = from || attrs;
3400
+ this.to = to;
3401
+ }
3402
+ else {
3403
+ this.valid = false;
3404
+ }
3405
+ }
3406
+ }
3407
+
3408
+ const growRadiusInIndividual = (graphic, options, animationParameters) => {
3409
+ const attrs = graphic.getFinalAttribute();
3410
+ if (options && options.orient === 'inside') {
3411
+ return {
3412
+ from: { innerRadius: attrs === null || attrs === void 0 ? void 0 : attrs.outerRadius },
3413
+ to: { innerRadius: attrs === null || attrs === void 0 ? void 0 : attrs.innerRadius }
3414
+ };
3415
+ }
3416
+ return {
3417
+ from: { outerRadius: attrs === null || attrs === void 0 ? void 0 : attrs.innerRadius },
3418
+ to: { outerRadius: attrs === null || attrs === void 0 ? void 0 : attrs.outerRadius }
3419
+ };
3420
+ };
3421
+ const growRadiusInOverall = (graphic, options, animationParameters) => {
3422
+ const attrs = graphic.getFinalAttribute();
3423
+ const overallValue = isNumber(options === null || options === void 0 ? void 0 : options.overall) ? options.overall : 0;
3424
+ return {
3425
+ from: {
3426
+ innerRadius: overallValue,
3427
+ outerRadius: overallValue
3428
+ },
3429
+ to: {
3430
+ innerRadius: attrs === null || attrs === void 0 ? void 0 : attrs.innerRadius,
3431
+ outerRadius: attrs === null || attrs === void 0 ? void 0 : attrs.outerRadius
3432
+ }
3433
+ };
3434
+ };
3435
+ const growRadiusIn = (graphic, options, animationParameters) => {
3436
+ var _a;
3437
+ return ((_a = options === null || options === void 0 ? void 0 : options.overall) !== null && _a !== void 0 ? _a : false) !== false
3438
+ ? growRadiusInOverall(graphic, options)
3439
+ : growRadiusInIndividual(graphic, options);
3440
+ };
3441
+ const growRadiusOutIndividual = (graphic, options, animationParameters) => {
3442
+ const attrs = graphic.getFinalAttribute();
3443
+ if (options && options.orient === 'inside') {
3444
+ return {
3445
+ from: { innerRadius: graphic.getGraphicAttribute('innerRadius', true) },
3446
+ to: { innerRadius: attrs === null || attrs === void 0 ? void 0 : attrs.outerRadius }
3447
+ };
3448
+ }
3449
+ return {
3450
+ from: { outerRadius: graphic.getGraphicAttribute('outerRadius', true) },
3451
+ to: { outerRadius: attrs === null || attrs === void 0 ? void 0 : attrs.innerRadius }
3452
+ };
3453
+ };
3454
+ const growRadiusOutOverall = (graphic, options, animationParameters) => {
3455
+ const overallValue = isNumber(options === null || options === void 0 ? void 0 : options.overall) ? options.overall : 0;
3456
+ return {
3457
+ from: {
3458
+ innerRadius: graphic.getGraphicAttribute('innerRadius', true),
3459
+ outerRadius: graphic.getGraphicAttribute('outerRadius', true)
3460
+ },
3461
+ to: {
3462
+ innerRadius: overallValue,
3463
+ outerRadius: overallValue
3464
+ }
3465
+ };
3466
+ };
3467
+ const growRadiusOut = (graphic, options, animationParameters) => {
3468
+ var _a;
3469
+ return ((_a = options === null || options === void 0 ? void 0 : options.overall) !== null && _a !== void 0 ? _a : false) !== false
3470
+ ? growRadiusOutOverall(graphic, options)
3471
+ : growRadiusOutIndividual(graphic, options);
3472
+ };
3473
+ class GworPointsBase extends ACustomAnimate {
3474
+ constructor(from, to, duration, easing, params) {
3475
+ super(from, to, duration, easing, params);
3476
+ }
3477
+ onUpdate(end, ratio, out) {
3478
+ this.propKeys.forEach(key => {
3479
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
3480
+ });
3481
+ this.target.setAttributes(out);
3482
+ }
3483
+ }
3484
+ class GrowRadiusIn extends GworPointsBase {
3485
+ onBind() {
3486
+ var _a;
3487
+ const { from, to } = growRadiusIn(this.target, this.params.options, this.params);
3488
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : from;
3489
+ this.props = to;
3490
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3491
+ this.animate.reSyncProps();
3492
+ this.from = fromAttrs;
3493
+ this.to = to;
3494
+ this.target.setAttributes(fromAttrs);
3495
+ }
3496
+ }
3497
+ class GrowRadiusOut extends GworPointsBase {
3498
+ onBind() {
3499
+ var _a;
3500
+ const { from, to } = growRadiusOut(this.target, this.params.options, this.params);
3501
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : from;
3502
+ this.props = to;
3503
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3504
+ this.animate.reSyncProps();
3505
+ this.from = fromAttrs;
3506
+ this.to = to;
3507
+ this.target.setAttributes(fromAttrs);
3508
+ }
3509
+ }
3510
+
3511
+ function growWidthInIndividual(graphic, options, animationParameters) {
3512
+ const attrs = graphic.getFinalAttribute();
3513
+ const x = attrs.x;
3514
+ const x1 = attrs.x1;
3515
+ const width = attrs.width;
3516
+ if (options && options.orient === 'negative') {
3517
+ const computedX1 = isValid(width) ? Math.max(x, x + width) : Math.max(x, x1);
3518
+ return {
3519
+ from: { x: computedX1, x1: isNil(x1) ? undefined : computedX1, width: isNil(width) ? undefined : 0 },
3520
+ to: { x: x, x1: x1, width: width }
3521
+ };
3522
+ }
3523
+ const computedX = isValid(width) ? Math.min(x, x + width) : Math.min(x, x1);
3524
+ return {
3525
+ from: { x: computedX, x1: isNil(x1) ? undefined : computedX, width: isNil(width) ? undefined : 0 },
3526
+ to: { x: x, x1: x1, width: width }
3527
+ };
3528
+ }
3529
+ function growWidthInOverall(graphic, options, animationParameters) {
3530
+ var _a;
3531
+ const attrs = graphic.getFinalAttribute();
3532
+ const x = attrs.x;
3533
+ const x1 = attrs.x1;
3534
+ const width = attrs.width;
3535
+ let overallValue;
3536
+ if (options && options.orient === 'negative') {
3537
+ if (isNumber(options.overall)) {
3538
+ overallValue = options.overall;
3539
+ }
3540
+ else if (animationParameters.group) {
3541
+ overallValue = (_a = animationParameters.groupWidth) !== null && _a !== void 0 ? _a : animationParameters.group.getBounds().width();
3542
+ animationParameters.groupWidth = overallValue;
3543
+ }
3544
+ else {
3545
+ overallValue = animationParameters.width;
3546
+ }
3547
+ }
3548
+ else {
3549
+ overallValue = isNumber(options === null || options === void 0 ? void 0 : options.overall) ? options === null || options === void 0 ? void 0 : options.overall : 0;
3550
+ }
3551
+ return {
3552
+ from: { x: overallValue, x1: isNil(x1) ? undefined : overallValue, width: isNil(width) ? undefined : 0 },
3553
+ to: { x: x, x1: x1, width: width }
3554
+ };
3555
+ }
3556
+ const growWidthIn = (graphic, options, animationParameters) => {
3557
+ var _a;
3558
+ return ((_a = options === null || options === void 0 ? void 0 : options.overall) !== null && _a !== void 0 ? _a : false) !== false
3559
+ ? growWidthInOverall(graphic, options, animationParameters)
3560
+ : growWidthInIndividual(graphic, options);
3561
+ };
3562
+ function growWidthOutIndividual(graphic, options, animationParameters) {
3563
+ const attrs = graphic.getFinalAttribute();
3564
+ const x = attrs.x;
3565
+ const x1 = attrs.x1;
3566
+ const width = attrs.width;
3567
+ if (options && options.orient === 'negative') {
3568
+ const computedX1 = isValid(width) ? Math.max(x, x + width) : Math.max(x, x1);
3569
+ return {
3570
+ to: { x: computedX1, x1: isNil(x1) ? undefined : computedX1, width: isNil(width) ? undefined : 0 }
3571
+ };
3572
+ }
3573
+ const computedX = isValid(width) ? Math.min(x, x + width) : Math.min(x, x1);
3574
+ return {
3575
+ to: { x: computedX, x1: isNil(x1) ? undefined : computedX, width: isNil(width) ? undefined : 0 }
3576
+ };
3577
+ }
3578
+ function growWidthOutOverall(graphic, options, animationParameters) {
3579
+ var _a;
3580
+ const attrs = graphic.getFinalAttribute();
3581
+ const x1 = attrs.x1;
3582
+ const width = attrs.width;
3583
+ let overallValue;
3584
+ if (options && options.orient === 'negative') {
3585
+ if (isNumber(options.overall)) {
3586
+ overallValue = options.overall;
3587
+ }
3588
+ else if (animationParameters.group) {
3589
+ overallValue = (_a = animationParameters.groupWidth) !== null && _a !== void 0 ? _a : animationParameters.group.getBounds().width();
3590
+ animationParameters.groupWidth = overallValue;
3591
+ }
3592
+ else {
3593
+ overallValue = animationParameters.width;
3594
+ }
3595
+ }
3596
+ else {
3597
+ overallValue = isNumber(options === null || options === void 0 ? void 0 : options.overall) ? options.overall : 0;
3598
+ }
3599
+ return {
3600
+ to: { x: overallValue, x1: isNil(x1) ? undefined : overallValue, width: isNil(width) ? undefined : 0 }
3601
+ };
3602
+ }
3603
+ const growWidthOut = (graphic, options, animationParameters) => {
3604
+ var _a;
3605
+ return ((_a = options === null || options === void 0 ? void 0 : options.overall) !== null && _a !== void 0 ? _a : false) !== false
3606
+ ? growWidthOutOverall(graphic, options, animationParameters)
3607
+ : growWidthOutIndividual(graphic, options);
3608
+ };
3609
+ class GrowWidthIn extends ACustomAnimate {
3610
+ constructor(from, to, duration, easing, params) {
3611
+ super(from, to, duration, easing, params);
3612
+ }
3613
+ onBind() {
3614
+ var _a;
3615
+ const { from, to } = growWidthIn(this.target, this.params.options, this.params);
3616
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : from;
3617
+ this.props = to;
3618
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3619
+ this.animate.reSyncProps();
3620
+ this.from = fromAttrs;
3621
+ this.to = to;
3622
+ this.target.setAttributes(fromAttrs);
3623
+ }
3624
+ onEnd(cb) {
3625
+ super.onEnd(cb);
3626
+ }
3627
+ onUpdate(end, ratio, out) {
3628
+ this.propKeys.forEach(key => {
3629
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
3630
+ });
3631
+ this.target.setAttributes(out);
3632
+ }
3633
+ }
3634
+ class GrowWidthOut extends ACustomAnimate {
3635
+ constructor(from, to, duration, easing, params) {
3636
+ super(from, to, duration, easing, params);
3637
+ }
3638
+ onBind() {
3639
+ const attrs = this.target.getFinalAttribute();
3640
+ const { from, to } = growWidthOut(this.target, this.params.options, this.params);
3641
+ this.props = to;
3642
+ this.propKeys = Object.keys(to).filter(key => to[key] != null);
3643
+ this.animate.reSyncProps();
3644
+ this.from = from || attrs;
3645
+ this.to = to;
3646
+ }
3647
+ onEnd(cb) {
3648
+ super.onEnd(cb);
3649
+ }
3650
+ onUpdate(end, ratio, out) {
3651
+ this.propKeys.forEach(key => {
3652
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
3653
+ });
3654
+ this.target.setAttributes(out);
3655
+ }
3656
+ }
3657
+
3658
+ class ScaleIn extends ACustomAnimate {
3659
+ constructor(from, to, duration, easing, params) {
3660
+ super(from, to, duration, easing, params);
3661
+ }
3662
+ onBind() {
3663
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
3664
+ let from;
3665
+ let to;
3666
+ const attrs = this.target.getFinalAttribute();
3667
+ const fromAttrs = (_a = this.target.context.lastAttrs) !== null && _a !== void 0 ? _a : {};
3668
+ switch ((_b = this.params) === null || _b === void 0 ? void 0 : _b.direction) {
3669
+ case 'x':
3670
+ from = { scaleX: (_c = fromAttrs.scaleX) !== null && _c !== void 0 ? _c : 0 };
3671
+ to = { scaleX: (_d = attrs === null || attrs === void 0 ? void 0 : attrs.scaleX) !== null && _d !== void 0 ? _d : 1 };
3672
+ break;
3673
+ case 'y':
3674
+ from = { scaleY: (_e = fromAttrs.scaleY) !== null && _e !== void 0 ? _e : 0 };
3675
+ to = { scaleY: (_f = attrs === null || attrs === void 0 ? void 0 : attrs.scaleY) !== null && _f !== void 0 ? _f : 1 };
3676
+ break;
3677
+ case 'xy':
3678
+ default:
3679
+ from = { scaleX: (_g = fromAttrs.scaleX) !== null && _g !== void 0 ? _g : 0, scaleY: (_h = fromAttrs.scaleY) !== null && _h !== void 0 ? _h : 0 };
3680
+ to = {
3681
+ scaleX: (_j = attrs === null || attrs === void 0 ? void 0 : attrs.scaleX) !== null && _j !== void 0 ? _j : 1,
3682
+ scaleY: (_k = attrs === null || attrs === void 0 ? void 0 : attrs.scaleY) !== null && _k !== void 0 ? _k : 1
3683
+ };
3684
+ }
3685
+ this.props = to;
3686
+ this.propKeys = Object.keys(to);
3687
+ this.animate.reSyncProps();
3688
+ this.from = from;
3689
+ this.to = to;
3690
+ this.target.setAttributes(from);
3691
+ }
3692
+ onEnd(cb) {
3693
+ super.onEnd(cb);
3694
+ }
3695
+ onUpdate(end, ratio, out) {
3696
+ this.propKeys.forEach(key => {
3697
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
3698
+ });
3699
+ this.target.setAttributes(out);
3700
+ }
3701
+ }
3702
+ class ScaleOut extends ACustomAnimate {
3703
+ constructor(from, to, duration, easing, params) {
3704
+ super(from, to, duration, easing, params);
3705
+ }
3706
+ onBind() {
3707
+ var _a, _b, _c, _d, _e;
3708
+ let from;
3709
+ let to;
3710
+ const attrs = this.target.getFinalAttribute();
3711
+ switch ((_a = this.params) === null || _a === void 0 ? void 0 : _a.direction) {
3712
+ case 'x':
3713
+ from = { scaleX: (_b = attrs === null || attrs === void 0 ? void 0 : attrs.scaleX) !== null && _b !== void 0 ? _b : 1 };
3714
+ to = { scaleX: 0 };
3715
+ break;
3716
+ case 'y':
3717
+ from = { scaleY: (_c = attrs === null || attrs === void 0 ? void 0 : attrs.scaleY) !== null && _c !== void 0 ? _c : 1 };
3718
+ to = { scaleY: 0 };
3719
+ break;
3720
+ case 'xy':
3721
+ default:
3722
+ from = { scaleX: (_d = attrs === null || attrs === void 0 ? void 0 : attrs.scaleX) !== null && _d !== void 0 ? _d : 1, scaleY: (_e = attrs === null || attrs === void 0 ? void 0 : attrs.scaleY) !== null && _e !== void 0 ? _e : 1 };
3723
+ to = {
3724
+ scaleX: 0,
3725
+ scaleY: 0
3726
+ };
3727
+ }
3728
+ this.props = to;
3729
+ this.propKeys = Object.keys(to);
3730
+ this.animate.reSyncProps();
3731
+ this.from = from;
3732
+ this.to = to;
3733
+ }
3734
+ onEnd(cb) {
3735
+ super.onEnd(cb);
3736
+ }
3737
+ onUpdate(end, ratio, out) {
3738
+ this.propKeys.forEach(key => {
3739
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
3740
+ });
3741
+ this.target.setAttributes(out);
3742
+ }
3743
+ }
3744
+
3745
+ class State extends ACustomAnimate {
3746
+ constructor(from, to, duration, easing, params) {
3747
+ super(from, to, duration, easing, params);
3748
+ }
3749
+ update(end, ratio, out) {
3750
+ this.onStart();
3751
+ if (!this.props || !this.propKeys) {
3752
+ return;
3753
+ }
3754
+ const easedRatio = this.easing(ratio);
3755
+ this.animate.interpolateUpdateFunction
3756
+ ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target)
3757
+ : this.interpolateUpdateFunctions.forEach((func, index) => {
3758
+ if (!this.animate.validAttr(this.propKeys[index])) {
3759
+ return;
3760
+ }
3761
+ const key = this.propKeys[index];
3762
+ const fromValue = this.fromProps[key];
3763
+ const toValue = this.props[key];
3764
+ func(key, fromValue, toValue, easedRatio, this, this.target);
3765
+ });
3766
+ this.onUpdate(end, easedRatio, out);
3767
+ }
3768
+ }
3769
+
3770
+ class Update extends ACustomAnimate {
3771
+ constructor(from, to, duration, easing, params) {
3772
+ const { diffAttrs = {} } = params;
3773
+ super(from, diffAttrs, duration, easing, params);
3774
+ this.params = params;
3775
+ }
3776
+ update(end, ratio, out) {
3777
+ this.onStart();
3778
+ if (!this.props || !this.propKeys) {
3779
+ return;
3780
+ }
3781
+ const easedRatio = this.easing(ratio);
3782
+ this.animate.interpolateUpdateFunction
3783
+ ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target)
3784
+ : this.interpolateUpdateFunctions.forEach((func, index) => {
3785
+ if (!this.animate.validAttr(this.propKeys[index])) {
3786
+ return;
3787
+ }
3788
+ const key = this.propKeys[index];
3789
+ const fromValue = this.fromProps[key];
3790
+ const toValue = this.props[key];
3791
+ func(key, fromValue, toValue, easedRatio, this, this.target);
3792
+ });
3793
+ this.onUpdate(end, easedRatio, out);
3794
+ }
3795
+ }
3796
+
3797
+ const registerCustomAnimate = () => {
3798
+ AnimateExecutor.registerBuiltInAnimate('scaleIn', ScaleIn);
3799
+ AnimateExecutor.registerBuiltInAnimate('scaleOut', ScaleOut);
3800
+ AnimateExecutor.registerBuiltInAnimate('growHeightIn', GrowHeightIn);
3801
+ AnimateExecutor.registerBuiltInAnimate('growHeightOut', GrowHeightOut);
3802
+ AnimateExecutor.registerBuiltInAnimate('growWidthIn', GrowWidthIn);
3803
+ AnimateExecutor.registerBuiltInAnimate('growWidthOut', GrowWidthOut);
3804
+ AnimateExecutor.registerBuiltInAnimate('growCenterIn', GrowCenterIn);
3805
+ AnimateExecutor.registerBuiltInAnimate('growCenterOut', GrowCenterOut);
3806
+ AnimateExecutor.registerBuiltInAnimate('clipIn', ClipIn);
3807
+ AnimateExecutor.registerBuiltInAnimate('clipOut', ClipOut);
3808
+ AnimateExecutor.registerBuiltInAnimate('fadeIn', FadeIn);
3809
+ AnimateExecutor.registerBuiltInAnimate('fadeOut', FadeOut);
3810
+ AnimateExecutor.registerBuiltInAnimate('growPointsIn', GrowPointsIn);
3811
+ AnimateExecutor.registerBuiltInAnimate('growPointsOut', GrowPointsOut);
3812
+ AnimateExecutor.registerBuiltInAnimate('growPointsXIn', GrowPointsXIn);
3813
+ AnimateExecutor.registerBuiltInAnimate('growPointsXOut', GrowPointsXOut);
3814
+ AnimateExecutor.registerBuiltInAnimate('growPointsYIn', GrowPointsYIn);
3815
+ AnimateExecutor.registerBuiltInAnimate('growPointsYOut', GrowPointsYOut);
3816
+ AnimateExecutor.registerBuiltInAnimate('growAngleIn', GrowAngleIn);
3817
+ AnimateExecutor.registerBuiltInAnimate('growAngleOut', GrowAngleOut);
3818
+ AnimateExecutor.registerBuiltInAnimate('growRadiusIn', GrowRadiusIn);
3819
+ AnimateExecutor.registerBuiltInAnimate('growRadiusOut', GrowRadiusOut);
3820
+ AnimateExecutor.registerBuiltInAnimate('update', Update);
3821
+ AnimateExecutor.registerBuiltInAnimate('state', State);
3822
+ };
3823
+
3824
+ export { ACustomAnimate, Animate, AnimateExecutor, AnimateMode, AnimateStatus, AnimateStepType, AnimationStateManager, AnimationStateStore, AnimationTransitionRegistry, ClipAngleAnimate, ClipDirectionAnimate, ClipGraphicAnimate, ClipRadiusAnimate, DefaultTicker, DefaultTimeline, GraphicStateExtension, GroupFadeIn, GroupFadeOut, IncreaseCount, InputText, ManualTicker, RotateBySphereAnimate, Step, TagPointsUpdate, generatorPathEasingFunc, registerAnimate, registerCustomAnimate, transitionRegistry };