@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,88 @@
1
+ import { interpolateColor, interpolatePureColorArrayToStr } from "@visactor/vrender-core";
2
+
3
+ import { interpolateNumber } from "./number";
4
+
5
+ export class InterpolateUpdateStore {
6
+ constructor() {
7
+ this.opacity = (key, from, to, ratio, step, target) => {
8
+ target.attribute.opacity = interpolateNumber(from, to, ratio);
9
+ }, this.fillOpacity = (key, from, to, ratio, step, target) => {
10
+ target.attribute.fillOpacity = interpolateNumber(from, to, ratio);
11
+ }, this.strokeOpacity = (key, from, to, ratio, step, target) => {
12
+ target.attribute.strokeOpacity = interpolateNumber(from, to, ratio);
13
+ }, this.zIndex = (key, from, to, ratio, step, target) => {
14
+ target.attribute.zIndex = interpolateNumber(from, to, ratio);
15
+ }, this.backgroundOpacity = (key, from, to, ratio, step, target) => {
16
+ target.attribute.backgroundOpacity = interpolateNumber(from, to, ratio);
17
+ }, this.shadowOffsetX = (key, from, to, ratio, step, target) => {
18
+ target.attribute.shadowOffsetX = interpolateNumber(from, to, ratio);
19
+ }, this.shadowOffsetY = (key, from, to, ratio, step, target) => {
20
+ target.attribute.shadowOffsetY = interpolateNumber(from, to, ratio);
21
+ }, this.shadowBlur = (key, from, to, ratio, step, target) => {
22
+ target.attribute.shadowBlur = interpolateNumber(from, to, ratio);
23
+ }, this.fill = (key, from, to, ratio, step, target) => {
24
+ target.attribute.fill = interpolateColor(from, to, ratio, !1);
25
+ }, this.fillPure = (key, from, to, ratio, step, target) => {
26
+ target.attribute.fill = interpolatePureColorArrayToStr(step.fromParsedProps.fill, step.toParsedProps.fill, ratio);
27
+ }, this.stroke = (key, from, to, ratio, step, target) => {
28
+ target.attribute.stroke = interpolateColor(from, to, ratio, !1);
29
+ }, this.strokePure = (key, from, to, ratio, step, target) => {
30
+ target.attribute.stroke = interpolatePureColorArrayToStr(step.fromParsedProps.stroke, step.toParsedProps.stroke, ratio);
31
+ }, this.width = (key, from, to, ratio, step, target) => {
32
+ target.attribute.width = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
33
+ }, this.height = (key, from, to, ratio, step, target) => {
34
+ target.attribute.height = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
35
+ }, this.x = (key, from, to, ratio, step, target) => {
36
+ target.attribute.x = interpolateNumber(from, to, ratio), target.addUpdateBoundTag(),
37
+ target.addUpdatePositionTag();
38
+ }, this.y = (key, from, to, ratio, step, target) => {
39
+ target.attribute.y = interpolateNumber(from, to, ratio), target.addUpdateBoundTag(),
40
+ target.addUpdatePositionTag();
41
+ }, this.angle = (key, from, to, ratio, step, target) => {
42
+ target.attribute.angle = interpolateNumber(from, to, ratio), target.addUpdateBoundTag(),
43
+ target.addUpdatePositionTag();
44
+ }, this.scaleX = (key, from, to, ratio, step, target) => {
45
+ target.attribute.scaleX = interpolateNumber(from, to, ratio), target.addUpdateBoundTag(),
46
+ target.addUpdatePositionTag();
47
+ }, this.scaleY = (key, from, to, ratio, step, target) => {
48
+ target.attribute.scaleY = interpolateNumber(from, to, ratio), target.addUpdateBoundTag(),
49
+ target.addUpdatePositionTag();
50
+ }, this.lineWidth = (key, from, to, ratio, step, target) => {
51
+ target.attribute.lineWidth = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
52
+ }, this.startAngle = (key, from, to, ratio, step, target) => {
53
+ target.attribute.startAngle = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
54
+ }, this.endAngle = (key, from, to, ratio, step, target) => {
55
+ target.attribute.endAngle = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
56
+ }, this.radius = (key, from, to, ratio, step, target) => {
57
+ target.attribute.radius = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
58
+ }, this.outerRadius = (key, from, to, ratio, step, target) => {
59
+ target.attribute.outerRadius = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
60
+ }, this.innerRadius = (key, from, to, ratio, step, target) => {
61
+ target.attribute.innerRadius = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
62
+ }, this.size = (key, from, to, ratio, step, target) => {
63
+ target.attribute.size = interpolateNumber(from, to, ratio), target.addUpdateBoundTag();
64
+ };
65
+ }
66
+ }
67
+
68
+ export const interpolateUpdateStore = new InterpolateUpdateStore;
69
+
70
+ export function commonInterpolateUpdate(key, from, to, ratio, step, target) {
71
+ if (Number.isFinite(to) && Number.isFinite(from)) return target.attribute[key] = from + (to - from) * ratio,
72
+ !0;
73
+ if (Array.isArray(to) && Array.isArray(from) && to.length === from.length) {
74
+ const nextList = [];
75
+ let valid = !0;
76
+ for (let i = 0; i < to.length; i++) {
77
+ const v = from[i], val = v + (to[i] - v) * ratio;
78
+ if (!Number.isFinite(val)) {
79
+ valid = !1;
80
+ break;
81
+ }
82
+ nextList.push(val);
83
+ }
84
+ return valid && (target.attribute[key] = nextList), !0;
85
+ }
86
+ return !1;
87
+ }
88
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/interpolate/store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAuD7C,MAAM,OAAO,sBAAsB;IAAnC;QACE,YAAO,GAAG,CAAC,GAAW,EAAE,IAAY,EAAE,EAAU,EAAE,KAAa,EAAE,IAAW,EAAE,MAAgB,EAAE,EAAE;YAChG,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG,iBAAiB,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;QAChE,CAAC,CAAC;QACF,gBAAW,GAAG,CAAC,GAAW,EAAE,IAAY,EAAE,EAAU,EAAE,KAAa,EAAE,IAAW,EAAE,MAAgB,EAAE,EAAE;YACpG,MAAM,CAAC,SAAS,CAAC,WAAW,GAAG,iBAAiB,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;QACpE,CAAC,CAAC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phic } from '@visactor/vrender-core';\nimport { interpolateColor, interpolatePureColorArrayToStr } from '@visactor/vrender-core';\nimport { interpolateNumber } from './number';\nimport type { IStep } from '../intreface/animate';\n\n// 直接设置,触发 隐藏类(Hidden Class)优化:\n/**\n *\nconst a = { type: 1 };\nconst ITERATIONS = 1e7; // 测试次数\n\n// 动态生成 keys 数组(确保引擎无法静态推断 key)\nconst keys = [];\nfor (let i = 0; i < ITERATIONS; i++) {\n // 通过条件确保 key 动态变化(但实际始终为 'type',避免属性缺失的开销)\n keys.push(Math.random() < 0 ? 'other' : 'type');\n}\n\n// 测试字面量访问\nfunction testLiteral() {\n let sum = 0;\n for (let i = 0; i < ITERATIONS; i++) {\n const key = keys[i]; // 读取 key(与动态测试完全一致)\n sum += a.type; // 差异仅在此处:使用字面量访问\n }\n return sum;\n}\n\n// 测试变量动态访问\nfunction testDynamic() {\n let sum = 0;\n for (let i = 0; i < ITERATIONS; i++) {\n const key = keys[i]; // 读取 key(与字面量测试完全一致)\n sum += a[key]; // 差异仅在此处:使用变量访问\n }\n return sum;\n}\n\n// 预热(避免 JIT 编译影响)\ntestLiteral();\ntestDynamic();\n\n// 正式测试\nconsole.time('literal');\ntestLiteral();\nconsole.timeEnd('literal');\n\nconsole.time('dynamic');\ntestDynamic();\nconsole.timeEnd('dynamic');\n\n\n// out:\n// literal: 7.1259765625 ms\n// dynamic: 9.322998046875 ms\n */\n\nexport class InterpolateUpdateStore {\n opacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.opacity = interpolateNumber(from, to, ratio);\n };\n fillOpacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.fillOpacity = interpolateNumber(from, to, ratio);\n };\n strokeOpacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.strokeOpacity = interpolateNumber(from, to, ratio);\n };\n zIndex = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.zIndex = interpolateNumber(from, to, ratio);\n };\n backgroundOpacity = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.backgroundOpacity = interpolateNumber(from, to, ratio);\n };\n shadowOffsetX = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.shadowOffsetX = interpolateNumber(from, to, ratio);\n };\n shadowOffsetY = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.shadowOffsetY = interpolateNumber(from, to, ratio);\n };\n shadowBlur = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.shadowBlur = interpolateNumber(from, to, ratio);\n };\n fill = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.fill = interpolateColor(from, to, ratio, false) as any;\n };\n fillPure = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.fill = interpolatePureColorArrayToStr(\n step.fromParsedProps.fill,\n step.toParsedProps.fill,\n ratio\n ) as any;\n };\n stroke = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.stroke = interpolateColor(from, to, ratio, false);\n };\n strokePure = (\n key: string,\n from: [number, number, number, number],\n to: [number, number, number, number],\n ratio: number,\n step: IStep,\n target: IGraphic\n ) => {\n target.attribute.stroke = interpolatePureColorArrayToStr(\n step.fromParsedProps.stroke,\n step.toParsedProps.stroke,\n ratio\n ) as any;\n };\n\n // 需要更新Bounds\n width = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).width = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n height = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).height = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n x = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.x = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n y = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.y = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n angle = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.angle = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n scaleX = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.scaleX = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n scaleY = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.scaleY = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n target.addUpdatePositionTag();\n };\n lineWidth = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n target.attribute.lineWidth = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n startAngle = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).startAngle = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n endAngle = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).endAngle = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n radius = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).radius = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n outerRadius = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).outerRadius = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n innerRadius = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).innerRadius = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n size = (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => {\n (target.attribute as any).size = interpolateNumber(from, to, ratio);\n target.addUpdateBoundTag();\n };\n}\n\nexport const interpolateUpdateStore = new InterpolateUpdateStore();\n\nexport function commonInterpolateUpdate(key: string, from: any, to: any, ratio: number, step: IStep, target: IGraphic) {\n if (Number.isFinite(to) && Number.isFinite(from)) {\n (target.attribute as any)[key] = from + (to - from) * ratio;\n return true;\n } else if (Array.isArray(to) && Array.isArray(from) && to.length === from.length) {\n const nextList = [];\n let valid = true;\n for (let i = 0; i < to.length; i++) {\n const v = from[i];\n const val = v + (to[i] - v) * ratio;\n if (!Number.isFinite(val)) {\n valid = false;\n break;\n }\n nextList.push(val);\n }\n if (valid) {\n (target.attribute as any)[key] = nextList;\n }\n return true;\n }\n return false;\n}\n"]}
@@ -0,0 +1,91 @@
1
+ import type { IGraphic } from '@visactor/vrender-core';
2
+ import type { EasingType, EasingTypeFunc } from './easing';
3
+ import type { AnimateStatus, IAnimateStepType } from './type';
4
+ import type { ITimeline } from './timeline';
5
+ export interface ICustomAnimate extends IStep {
6
+ type: IAnimateStepType;
7
+ }
8
+ export interface IStep {
9
+ type: IAnimateStepType;
10
+ prev?: IStep;
11
+ duration: number;
12
+ next?: IStep;
13
+ props?: Record<string, any>;
14
+ fromParsedProps?: Record<string, any>;
15
+ toParsedProps?: Record<string, any>;
16
+ fromProps?: Record<string, any>;
17
+ propKeys?: string[];
18
+ easing?: EasingTypeFunc;
19
+ append: (step: IStep) => void;
20
+ getLastProps: () => any;
21
+ animate: IAnimate;
22
+ setDuration: (duration: number, updateDownstream?: boolean) => void;
23
+ getDuration: () => number;
24
+ determineInterpolateUpdateFunction: () => void;
25
+ setStartTime: (time: number, updateDownstream?: boolean) => void;
26
+ getStartTime: () => number;
27
+ bind: (target: IGraphic, animate: IAnimate) => void;
28
+ onBind: () => void;
29
+ onFirstRun: () => void;
30
+ onStart: () => void;
31
+ onEnd: (cb?: (animate: IAnimate, step: IStep) => void) => void;
32
+ update: (end: boolean, ratio: number, out: Record<string, any>) => void;
33
+ onUpdate: (end: boolean, ratio: number, out: Record<string, any>) => void;
34
+ getEndProps: () => Record<string, any> | void;
35
+ getFromProps: () => Record<string, any> | void;
36
+ getMergedEndProps: () => Record<string, any> | void;
37
+ deleteSelfAttr: (key: string) => void;
38
+ }
39
+ export interface IAnimate {
40
+ readonly id: string | number;
41
+ status: AnimateStatus;
42
+ target: IGraphic;
43
+ priority: number;
44
+ interpolateUpdateFunction: ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void) | null;
45
+ _onStart?: (() => void)[];
46
+ _onFrame?: ((step: IStep, ratio: number) => void)[];
47
+ _onEnd?: (() => void)[];
48
+ _onRemove?: (() => void)[];
49
+ getStartProps: () => Record<string, any>;
50
+ getEndProps: () => Record<string, any>;
51
+ setTimeline: (timeline: ITimeline) => void;
52
+ getTimeline: () => ITimeline;
53
+ readonly timeline: ITimeline;
54
+ bind: (target: IGraphic) => this;
55
+ to: (props: Record<string, any>, duration: number, easing: EasingType) => this;
56
+ from: (props: Record<string, any>, duration: number, easing: EasingType) => this;
57
+ pause: () => void;
58
+ resume: () => void;
59
+ onStart: (cb?: () => void) => void;
60
+ onEnd: (cb?: () => void) => void;
61
+ onFrame: (cb: (step: IStep, ratio: number) => void) => void;
62
+ onRemove: (cb?: () => void) => void;
63
+ preventAttr: (key: string) => void;
64
+ preventAttrs: (key: string[]) => void;
65
+ validAttr: (key: string) => boolean;
66
+ runCb: (cb: (a: IAnimate, step: IStep) => void) => IAnimate;
67
+ customInterpolate: (key: string, ratio: number, from: any, to: any, target: IGraphic, ret: Record<string, any>) => boolean;
68
+ play: (customAnimate: ICustomAnimate) => this;
69
+ getFromValue: () => Record<string, any>;
70
+ getToValue: () => Record<string, any>;
71
+ stop: (type?: 'start' | 'end' | Record<string, any>) => void;
72
+ release: () => void;
73
+ getDuration: () => number;
74
+ getTotalDuration: () => number;
75
+ getStartTime: () => number;
76
+ wait: (delay: number) => this;
77
+ afterAll: (list: IAnimate[]) => this;
78
+ after: (animate: IAnimate) => this;
79
+ parallel: (animate: IAnimate) => this;
80
+ getLoop: () => number;
81
+ loop: (n: number | boolean) => IAnimate;
82
+ bounce: (b: boolean) => IAnimate;
83
+ advance: (delta: number) => void;
84
+ startAt: (t: number) => IAnimate;
85
+ reSyncProps: () => void;
86
+ updateDuration: () => void;
87
+ }
88
+ export declare enum AnimateMode {
89
+ NORMAL = 0,
90
+ SET_ATTR_IMMEDIATELY = 1
91
+ }
@@ -0,0 +1,6 @@
1
+ export var AnimateMode;
2
+
3
+ !function(AnimateMode) {
4
+ AnimateMode[AnimateMode.NORMAL = 0] = "NORMAL", AnimateMode[AnimateMode.SET_ATTR_IMMEDIATELY = 1] = "SET_ATTR_IMMEDIATELY";
5
+ }(AnimateMode || (AnimateMode = {}));
6
+ //# sourceMappingURL=animate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/animate.ts"],"names":[],"mappings":"AAmKA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,iDAAe,CAAA;IACf,6EAA6B,CAAA;AAC/B,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB","file":"animate.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { EasingType, EasingTypeFunc } from './easing';\nimport type { AnimateStatus, IAnimateStepType } from './type';\nimport type { ITimeline } from './timeline';\n\nexport interface ICustomAnimate extends IStep {\n type: IAnimateStepType;\n}\n\nexport interface IStep {\n type: IAnimateStepType;\n prev?: IStep;\n // 持续时间\n duration: number;\n // 链表,下一个\n next?: IStep;\n // 属性\n props?: Record<string, any>;\n // 解析后的属性(用于性能优化,避免每次tick都解析)\n fromParsedProps?: Record<string, any>;\n toParsedProps?: Record<string, any>;\n fromProps?: Record<string, any>;\n // 解析后的属性列表(用于性能优化,避免每次tick都解析)\n propKeys?: string[];\n // 缓动函数\n easing?: EasingTypeFunc;\n\n // 添加一个\n append: (step: IStep) => void;\n // 获取上一个props,用于完成这次的fromValue 和 toValue的插值\n getLastProps: () => any;\n\n animate: IAnimate;\n\n // 设置持续时间\n setDuration: (duration: number, updateDownstream?: boolean) => void;\n // 获取持续时间\n getDuration: () => number;\n // 确定插值更新函数(在开始的时候就确定,避免每次tick都解析)\n determineInterpolateUpdateFunction: () => void;\n\n // 设置开始时间\n setStartTime: (time: number, updateDownstream?: boolean) => void;\n // 获取开始时间\n getStartTime: () => number;\n\n bind: (target: IGraphic, animate: IAnimate) => void;\n // 在第一次绑定到Animate的时候触发\n onBind: () => void;\n // 第一次执行的时候调用\n onFirstRun: () => void;\n // 开始执行的时候调用(如果有循环,那每个周期都会调用)\n onStart: () => void;\n // 结束执行的时候调用(如果有循环,那每个周期都会调用)\n onEnd: (cb?: (animate: IAnimate, step: IStep) => void) => void;\n // 更新执行的时候调用(如果有循环,那每个周期都会调用)\n update: (end: boolean, ratio: number, out: Record<string, any>) => void;\n onUpdate: (end: boolean, ratio: number, out: Record<string, any>) => void;\n\n getEndProps: () => Record<string, any> | void;\n getFromProps: () => Record<string, any> | void;\n getMergedEndProps: () => Record<string, any> | void;\n\n // 屏蔽自身属性,会直接从props等内容里删除掉\n deleteSelfAttr: (key: string) => void;\n}\n\nexport interface IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n target: IGraphic;\n priority: number;\n interpolateUpdateFunction:\n | ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void)\n | null;\n\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n getStartProps: () => Record<string, any>;\n getEndProps: () => Record<string, any>;\n\n // 设置timeline\n setTimeline: (timeline: ITimeline) => void;\n // 获取timeline\n getTimeline: () => ITimeline;\n readonly timeline: ITimeline;\n\n bind: (target: IGraphic) => this;\n to: (props: Record<string, any>, duration: number, easing: EasingType) => this;\n from: (props: Record<string, any>, duration: number, easing: EasingType) => this;\n pause: () => void;\n resume: () => void;\n onStart: (cb?: () => void) => void;\n onEnd: (cb?: () => void) => void;\n onFrame: (cb: (step: IStep, ratio: number) => void) => void;\n onRemove: (cb?: () => void) => void;\n // 屏蔽属性\n preventAttr: (key: string) => void;\n // 屏蔽属性\n preventAttrs: (key: string[]) => void;\n // 属性是否合法\n validAttr: (key: string) => boolean;\n\n runCb: (cb: (a: IAnimate, step: IStep) => void) => IAnimate;\n\n // 自定义插值,返回false表示没有匹配上\n customInterpolate: (\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IGraphic,\n ret: Record<string, any>\n ) => boolean;\n play: (customAnimate: ICustomAnimate) => this;\n\n getFromValue: () => Record<string, any>;\n getToValue: () => Record<string, any>;\n // 停止,可以设置停止后设置target的属性为开始的值(fromValue),还是结束的值(toValue)\n stop: (type?: 'start' | 'end' | Record<string, any>) => void;\n /** 打上END标志,下一帧被删除 */\n release: () => void;\n // 获取持续的时长\n getDuration: () => number;\n getTotalDuration: () => number;\n // 获取动画开始时间(注意并不是子动画的startAt)\n getStartTime: () => number;\n // 等待delay\n wait: (delay: number) => this;\n\n /* 动画编排 */\n // 所有动画结束后执行\n afterAll: (list: IAnimate[]) => this;\n // 在某个动画结束后执行\n after: (animate: IAnimate) => this;\n // 并行执行\n parallel: (animate: IAnimate) => this;\n\n getLoop: () => number;\n\n // 反转动画\n // reversed: (r: boolean) => IAnimate;\n // 循环动画\n loop: (n: number | boolean) => IAnimate;\n // 反弹动画\n bounce: (b: boolean) => IAnimate;\n\n advance: (delta: number) => void;\n\n // 设置开始时间(startAt之前是完全不会进入动画生命周期的)\n // 它和wait不一样,如果调用的是wait,wait过程中还算是一个动画阶段,只是空的阶段,而startAt之前是完全不会进入动画生命周期的\n startAt: (t: number) => IAnimate;\n\n // 重新同步和计算props,用于内部某些step发生了变更后,重新计算自身\n reSyncProps: () => void;\n\n // 更新duration\n updateDuration: () => void;\n}\n\nexport enum AnimateMode {\n NORMAL = 0b0000,\n SET_ATTR_IMMEDIATELY = 0b0001\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export type EasingTypeStr = 'linear' | 'quadIn' | 'quadOut' | 'quadInOut' | 'quadInOut' | 'cubicIn' | 'cubicOut' | 'cubicInOut' | 'quartIn' | 'quartOut' | 'quartInOut' | 'quintIn' | 'quintOut' | 'quintInOut' | 'backIn' | 'backOut' | 'backInOut' | 'circIn' | 'circOut' | 'circInOut' | 'bounceOut' | 'bounceIn' | 'bounceInOut' | 'elasticIn' | 'elasticOut' | 'elasticInOut' | 'sineIn' | 'sineOut' | 'sineInOut' | 'expoIn' | 'expoOut' | 'expoInOut' | 'easeInOutQuad' | 'easeOutElastic' | 'easeInOutElastic' | '';
2
+ export type EasingTypeFunc = (t: number) => number;
3
+ export type EasingType = EasingTypeStr | EasingTypeFunc;
@@ -0,0 +1,2 @@
1
+ export { };
2
+ //# sourceMappingURL=easing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/easing.ts"],"names":[],"mappings":"","file":"easing.js","sourcesContent":["export type EasingTypeStr =\n | 'linear'\n | 'quadIn'\n | 'quadOut'\n | 'quadInOut'\n | 'quadInOut'\n | 'cubicIn'\n | 'cubicOut'\n | 'cubicInOut'\n | 'quartIn'\n | 'quartOut'\n | 'quartInOut'\n | 'quintIn'\n | 'quintOut'\n | 'quintInOut'\n | 'backIn'\n | 'backOut'\n | 'backInOut'\n | 'circIn'\n | 'circOut'\n | 'circInOut'\n | 'bounceOut'\n | 'bounceIn'\n | 'bounceInOut'\n | 'elasticIn'\n | 'elasticOut'\n | 'elasticInOut'\n | 'sineIn'\n | 'sineOut'\n | 'sineInOut'\n | 'expoIn'\n | 'expoOut'\n | 'expoInOut'\n // @since 0.21.0\n | 'easeInOutQuad'\n | 'easeOutElastic'\n | 'easeInOutElastic'\n | '';\nexport type EasingTypeFunc = (t: number) => number;\n\nexport type EasingType = EasingTypeStr | EasingTypeFunc;\n"]}
@@ -0,0 +1,35 @@
1
+ import type { IAnimationTypeConfig } from '../executor/executor';
2
+ import type { IGraphic, IGroup } from '@visactor/vrender-core';
3
+ export interface IAnimationStateConfig {
4
+ name: string;
5
+ animation: IAnimationTypeConfig;
6
+ priority?: number;
7
+ }
8
+ export interface IAnimationStateRule {
9
+ conflicts?: string[];
10
+ interruptibleBy?: string[];
11
+ queueable?: boolean;
12
+ transitionDelay?: number;
13
+ }
14
+ export interface IAnimationStateMachine {
15
+ applyState: (state: string | string[]) => void;
16
+ registerState: (config: IAnimationStateConfig, rule?: IAnimationStateRule) => void;
17
+ getActiveState: () => string | null;
18
+ reset: () => void;
19
+ on: (event: AnimationStateEventType, callback: (state: string, target: IGraphic | IGroup) => void) => void;
20
+ off: (event: AnimationStateEventType, callback: (state: string, target: IGraphic | IGroup) => void) => void;
21
+ }
22
+ export type AnimationStateEventType = 'stateStart' | 'stateEnd' | 'stateInterrupt' | 'stateReject';
23
+ export interface IAnimationStateRegistry {
24
+ register: (state: IAnimationStateConfig, rule?: IAnimationStateRule) => void;
25
+ getState: (name: string) => IAnimationStateConfig | undefined;
26
+ getRule: (name: string) => IAnimationStateRule | undefined;
27
+ hasConflict: (stateA: string, stateB: string) => boolean;
28
+ }
29
+ export interface IAnimationStateQueue {
30
+ enqueue: (states: string | string[]) => void;
31
+ processNextState: () => void;
32
+ onAnimationComplete: () => void;
33
+ cancel: () => void;
34
+ canApplyState: (state: string) => boolean;
35
+ }
@@ -0,0 +1,2 @@
1
+ export { };
2
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/state.ts"],"names":[],"mappings":"","file":"state.js","sourcesContent":["import type { IAnimationTypeConfig } from '../executor/executor';\nimport type { IAnimate } from './animate';\nimport type { IGraphic, IGroup } from '@visactor/vrender-core';\n\n/**\n * Animation state configuration\n */\nexport interface IAnimationStateConfig {\n /** State name */\n name: string;\n /** Animation configuration for this state */\n animation: IAnimationTypeConfig;\n /** Priority of this state (higher overrides lower when there's a conflict) */\n priority?: number;\n}\n\n/**\n * Rules for animation state behaviors\n */\nexport interface IAnimationStateRule {\n /** States that cannot run simultaneously with this state */\n conflicts?: string[];\n /** States that can interrupt this state */\n interruptibleBy?: string[];\n /** Whether this state can be queued */\n queueable?: boolean;\n /** Duration to wait before executing next state (if queueable) */\n transitionDelay?: number;\n}\n\n/**\n * Animation state machine interface\n */\nexport interface IAnimationStateMachine {\n /** Apply a state or sequence of states */\n applyState: (state: string | string[]) => void;\n\n /** Register new state animations and rules */\n registerState: (config: IAnimationStateConfig, rule?: IAnimationStateRule) => void;\n\n /** Get current active state */\n getActiveState: () => string | null;\n\n /** Cancel all animations and clear queue */\n reset: () => void;\n\n /** Add event listener for state events */\n on: (event: AnimationStateEventType, callback: (state: string, target: IGraphic | IGroup) => void) => void;\n\n /** Remove event listener */\n off: (event: AnimationStateEventType, callback: (state: string, target: IGraphic | IGroup) => void) => void;\n}\n\n/**\n * Animation state event types\n */\nexport type AnimationStateEventType = 'stateStart' | 'stateEnd' | 'stateInterrupt' | 'stateReject';\n\n/**\n * Animation state registry interface\n */\nexport interface IAnimationStateRegistry {\n /** Register a state with its animation config and rules */\n register: (state: IAnimationStateConfig, rule?: IAnimationStateRule) => void;\n\n /** Get state configuration by name */\n getState: (name: string) => IAnimationStateConfig | undefined;\n\n /** Get state rule by name */\n getRule: (name: string) => IAnimationStateRule | undefined;\n\n /** Check if two states conflict with each other */\n hasConflict: (stateA: string, stateB: string) => boolean;\n}\n\n/**\n * Animation state queue interface\n */\nexport interface IAnimationStateQueue {\n /** Add state(s) to queue */\n enqueue: (states: string | string[]) => void;\n\n /** Process the next state in queue */\n processNextState: () => void;\n\n /** Called when current animation completes */\n onAnimationComplete: () => void;\n\n /** Cancel current state and clear queue */\n cancel: () => void;\n\n /** Check if we can apply a specific state now */\n canApplyState: (state: string) => boolean;\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import type { EventEmitter } from '@visactor/vutils';
2
+ import type { ITimeline } from './timeline';
3
+ export type TickerMode = 'raf' | 'timeout' | 'manual';
4
+ export declare enum STATUS {
5
+ INITIAL = 0,
6
+ RUNNING = 1,
7
+ PAUSE = 2
8
+ }
9
+ export interface ITickHandler {
10
+ tick: (interval: number, cb: (handler: ITickHandler) => void) => void;
11
+ tickTo?: (t: number, cb: (handler: ITickHandler, params?: {
12
+ once: boolean;
13
+ }) => void) => void;
14
+ getTime: () => number;
15
+ release: () => void;
16
+ }
17
+ export interface ITickerHandlerStatic {
18
+ new (): ITickHandler;
19
+ }
20
+ export interface ITicker extends EventEmitter {
21
+ setFPS?: (fps: number) => void;
22
+ setInterval?: (interval: number) => void;
23
+ getFPS?: () => number;
24
+ getInterval?: () => number;
25
+ tick: (interval: number) => void;
26
+ tickAt?: (time: number) => void;
27
+ pause: () => boolean;
28
+ resume: () => boolean;
29
+ start: (force?: boolean) => boolean;
30
+ stop: () => void;
31
+ addTimeline: (timeline: ITimeline) => void;
32
+ remTimeline: (timeline: ITimeline) => void;
33
+ trySyncTickStatus: () => void;
34
+ getTimelines: () => ITimeline[];
35
+ release: () => void;
36
+ autoStop: boolean;
37
+ }
@@ -0,0 +1,6 @@
1
+ export var STATUS;
2
+
3
+ !function(STATUS) {
4
+ STATUS[STATUS.INITIAL = 0] = "INITIAL", STATUS[STATUS.RUNNING = 1] = "RUNNING",
5
+ STATUS[STATUS.PAUSE = 2] = "PAUSE";
6
+ }(STATUS || (STATUS = {}));
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/ticker.ts"],"names":[],"mappings":"AASA,MAAM,CAAN,IAAY,MAIX;AAJD,WAAY,MAAM;IAChB,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,qCAAS,CAAA;AACX,CAAC,EAJW,MAAM,KAAN,MAAM,QAIjB","file":"ticker.js","sourcesContent":["/**\n * Ticker Types for Animation Graph\n */\n\nimport type { EventEmitter } from '@visactor/vutils';\nimport type { ITimeline } from './timeline';\n\nexport type TickerMode = 'raf' | 'timeout' | 'manual';\n\nexport enum STATUS {\n INITIAL = 0, // initial represents initial state\n RUNNING = 1, // running represents executing\n PAUSE = 2 // PAUSE represents tick continues but functions are not executed\n}\n\nexport interface ITickHandler {\n /**\n * Start executing tick\n * @param interval Delay in ms\n * @param cb Callback to execute\n */\n tick: (interval: number, cb: (handler: ITickHandler) => void) => void;\n tickTo?: (t: number, cb: (handler: ITickHandler, params?: { once: boolean }) => void) => void;\n getTime: () => number; // Get current time\n release: () => void;\n}\n\nexport interface ITickerHandlerStatic {\n new (): ITickHandler;\n}\n\nexport interface ITicker extends EventEmitter {\n setFPS?: (fps: number) => void;\n setInterval?: (interval: number) => void;\n getFPS?: () => number;\n getInterval?: () => number;\n tick: (interval: number) => void;\n tickAt?: (time: number) => void;\n pause: () => boolean;\n resume: () => boolean;\n /**\n * Start ticking, if force is true, start regardless;\n * otherwise, don't start if timeline is empty\n */\n start: (force?: boolean) => boolean;\n stop: () => void;\n addTimeline: (timeline: ITimeline) => void;\n remTimeline: (timeline: ITimeline) => void;\n trySyncTickStatus: () => void;\n getTimelines: () => ITimeline[];\n release: () => void;\n\n // Whether to automatically stop, default is true\n autoStop: boolean;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { IAnimate } from './animate';
2
+ export interface ITimeline {
3
+ id: number;
4
+ isGlobal?: boolean;
5
+ animateCount: number;
6
+ addAnimate: (animate: IAnimate) => void;
7
+ removeAnimate: (animate: IAnimate, release?: boolean) => void;
8
+ tick: (delta: number) => void;
9
+ clear: () => void;
10
+ pause: () => void;
11
+ resume: () => void;
12
+ getTotalDuration: () => number;
13
+ getPlaySpeed: () => number;
14
+ setPlaySpeed: (speed: number) => void;
15
+ getPlayState: () => 'playing' | 'paused' | 'stopped';
16
+ isRunning: () => boolean;
17
+ }
@@ -0,0 +1,2 @@
1
+ export { };
2
+ //# sourceMappingURL=timeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/timeline.ts"],"names":[],"mappings":"","file":"timeline.js","sourcesContent":["import type { IAnimate } from './animate';\n\nexport interface ITimeline {\n id: number;\n isGlobal?: boolean;\n // 包含的动画数量(animate数组的数量),包含所有动画\n animateCount: number;\n // 添加动画\n addAnimate: (animate: IAnimate) => void;\n // 移除动画\n removeAnimate: (animate: IAnimate, release?: boolean) => void;\n // 更新动画\n tick: (delta: number) => void;\n // 清除动画\n clear: () => void;\n // 暂停动画\n pause: () => void;\n // 恢复动画\n resume: () => void;\n // 获取动画总时长\n getTotalDuration: () => number;\n // 获取动画的播放速度\n getPlaySpeed: () => number;\n // 设置动画的播放速度\n setPlaySpeed: (speed: number) => void;\n // 获取动画的播放状态\n getPlayState: () => 'playing' | 'paused' | 'stopped';\n // 获取动画是否正在运行\n isRunning: () => boolean;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ export declare enum AnimateStepType {
2
+ wait = "wait",
3
+ from = "from",
4
+ to = "to",
5
+ customAnimate = "customAnimate"
6
+ }
7
+ export declare enum AnimateStatus {
8
+ INITIAL = 0,
9
+ RUNNING = 1,
10
+ PAUSED = 2,
11
+ END = 3
12
+ }
13
+ export type IAnimateStepType = keyof typeof AnimateStepType;
@@ -0,0 +1,14 @@
1
+ export var AnimateStepType;
2
+
3
+ !function(AnimateStepType) {
4
+ AnimateStepType.wait = "wait", AnimateStepType.from = "from", AnimateStepType.to = "to",
5
+ AnimateStepType.customAnimate = "customAnimate";
6
+ }(AnimateStepType || (AnimateStepType = {}));
7
+
8
+ export var AnimateStatus;
9
+
10
+ !function(AnimateStatus) {
11
+ AnimateStatus[AnimateStatus.INITIAL = 0] = "INITIAL", AnimateStatus[AnimateStatus.RUNNING = 1] = "RUNNING",
12
+ AnimateStatus[AnimateStatus.PAUSED = 2] = "PAUSED", AnimateStatus[AnimateStatus.END = 3] = "END";
13
+ }(AnimateStatus || (AnimateStatus = {}));
14
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/type.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,4BAAS,CAAA;IACT,kDAA+B,CAAA;AACjC,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B;AAED,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,uDAAW,CAAA;IACX,uDAAW,CAAA;IACX,qDAAU,CAAA;IACV,+CAAO,CAAA;AACT,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB","file":"type.js","sourcesContent":["export enum AnimateStepType {\n wait = 'wait',\n from = 'from',\n to = 'to',\n customAnimate = 'customAnimate'\n}\n\nexport enum AnimateStatus {\n INITIAL = 0,\n RUNNING = 1,\n PAUSED = 2,\n END = 3\n}\n\nexport type IAnimateStepType = keyof typeof AnimateStepType;\n"]}
@@ -0,0 +1 @@
1
+ export declare function registerAnimate(): void;
package/es/register.js ADDED
@@ -0,0 +1,20 @@
1
+ import { Graphic } from "@visactor/vrender-core";
2
+
3
+ import { Animate } from "./animate";
4
+
5
+ import { defaultTimeline, DefaultTimeline } from "./timeline";
6
+
7
+ import { DefaultTicker } from "./ticker/default-ticker";
8
+
9
+ import { mixin } from "@visactor/vutils";
10
+
11
+ import { GraphicStateExtension } from "./state/graphic-extension";
12
+
13
+ import { AnimateExtension } from "./animate-extension";
14
+
15
+ export function registerAnimate() {
16
+ Graphic.Animate || (Graphic.Animate = Animate), Graphic.Timeline || (Graphic.Timeline = DefaultTimeline),
17
+ Graphic.defaultTimeline || (Graphic.defaultTimeline = defaultTimeline), Graphic.Ticker || (Graphic.Ticker = DefaultTicker),
18
+ mixin(Graphic, GraphicStateExtension), mixin(Graphic, AnimateExtension);
19
+ }
20
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAE,OAAe,CAAC,OAAO,EAAE;QAC5B,OAAe,CAAC,OAAO,GAAG,OAAO,CAAC;KACpC;IACD,IAAI,CAAE,OAAe,CAAC,QAAQ,EAAE;QAC7B,OAAe,CAAC,QAAQ,GAAG,eAAe,CAAC;KAC7C;IACD,IAAI,CAAE,OAAe,CAAC,eAAe,EAAE;QACpC,OAAe,CAAC,eAAe,GAAG,eAAe,CAAC;KACpD;IACD,IAAI,CAAE,OAAe,CAAC,MAAM,EAAE;QAC3B,OAAe,CAAC,MAAM,GAAG,aAAa,CAAC;KACzC;IAGD,KAAK,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;IACtC,KAAK,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACnC,CAAC","file":"register.js","sourcesContent":["import { Graphic } from '@visactor/vrender-core';\nimport { Animate } from './animate';\nimport { defaultTimeline, DefaultTimeline } from './timeline';\nimport { DefaultTicker } from './ticker/default-ticker';\nimport { mixin } from '@visactor/vutils';\nimport { GraphicStateExtension } from './state/graphic-extension';\nimport { AnimateExtension } from './animate-extension';\n\nexport function registerAnimate() {\n if (!(Graphic as any).Animate) {\n (Graphic as any).Animate = Animate;\n }\n if (!(Graphic as any).Timeline) {\n (Graphic as any).Timeline = DefaultTimeline;\n }\n if (!(Graphic as any).defaultTimeline) {\n (Graphic as any).defaultTimeline = defaultTimeline;\n }\n if (!(Graphic as any).Ticker) {\n (Graphic as any).Ticker = DefaultTicker;\n }\n\n // Mix in animation state methods to Graphic prototype\n mixin(Graphic, GraphicStateExtension);\n mixin(Graphic, AnimateExtension);\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import type { IGraphic, IGroup } from '@visactor/vrender-core';
2
+ import type { AnimationStateEventType, IAnimationStateConfig, IAnimationStateRule, IAnimationStateMachine } from '../intreface/state';
3
+ import type { AnimateExecutor } from '../executor/animate-executor';
4
+ type StateEventCallback = (state: string, target: IGraphic | IGroup) => void;
5
+ export declare class AnimationStateMachine implements IAnimationStateMachine {
6
+ private target;
7
+ private executor;
8
+ private registry;
9
+ private stateQueue;
10
+ private eventListeners;
11
+ constructor(target: IGraphic | IGroup, executor: AnimateExecutor);
12
+ applyState(state: string | string[]): void;
13
+ registerState(config: IAnimationStateConfig, rule?: IAnimationStateRule): void;
14
+ getActiveState(): string | null;
15
+ reset(): void;
16
+ on(event: AnimationStateEventType, callback: StateEventCallback): void;
17
+ off(event: AnimationStateEventType, callback: StateEventCallback): void;
18
+ private handleStateEvent;
19
+ hasState(state: string): boolean;
20
+ getRegisteredStates(): string[];
21
+ }
22
+ export {};
@@ -0,0 +1,47 @@
1
+ import { AnimationStateRegistry } from "./animation-state-registry";
2
+
3
+ import { AnimationStateQueue } from "./animation-state-queue";
4
+
5
+ export class AnimationStateMachine {
6
+ constructor(target, executor) {
7
+ this.target = target, this.executor = executor, this.eventListeners = new Map, this.registry = new AnimationStateRegistry,
8
+ this.stateQueue = new AnimationStateQueue(target, this.registry, executor, this.handleStateEvent.bind(this));
9
+ }
10
+ applyState(state) {
11
+ this.stateQueue.enqueue(state);
12
+ }
13
+ registerState(config, rule) {
14
+ this.registry.register(config, rule);
15
+ }
16
+ getActiveState() {
17
+ return this.stateQueue.getActiveState();
18
+ }
19
+ reset() {
20
+ this.stateQueue.cancel();
21
+ }
22
+ on(event, callback) {
23
+ var _a;
24
+ this.eventListeners.has(event) || this.eventListeners.set(event, new Set), null === (_a = this.eventListeners.get(event)) || void 0 === _a || _a.add(callback);
25
+ }
26
+ off(event, callback) {
27
+ const listeners = this.eventListeners.get(event);
28
+ listeners && listeners.delete(callback);
29
+ }
30
+ handleStateEvent(event, state) {
31
+ const listeners = this.eventListeners.get(event);
32
+ listeners && listeners.forEach((callback => {
33
+ try {
34
+ callback(state, this.target);
35
+ } catch (error) {
36
+ console.error(`Error in animation state event listener for ${event}:`, error);
37
+ }
38
+ }));
39
+ }
40
+ hasState(state) {
41
+ return !!this.registry.getState(state);
42
+ }
43
+ getRegisteredStates() {
44
+ return this.registry.getAllStateNames();
45
+ }
46
+ }
47
+ //# sourceMappingURL=animation-state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/state/animation-state-machine.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQ9D,MAAM,OAAO,qBAAqB;IAKhC,YAAoB,MAAyB,EAAU,QAAyB;QAA5D,WAAM,GAAN,MAAM,CAAmB;QAAU,aAAQ,GAAR,QAAQ,CAAiB;QAFxE,mBAAc,GAA0D,IAAI,GAAG,EAAE,CAAC;QAGxF,IAAI,CAAC,QAAQ,GAAG,IAAI,sBAAsB,EAAE,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/G,CAAC;IAKD,UAAU,CAAC,KAAwB;QACjC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAKD,aAAa,CAAC,MAA6B,EAAE,IAA0B;QACrE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAKD,cAAc;QACZ,OAAO,IAAI,CAAC,UAA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B,EAAE,CAAC;IAC1C,CAAC;CACF","file":"animation-state-machine.js","sourcesContent":["import type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport type {\n AnimationStateEventType,\n IAnimationStateConfig,\n IAnimationStateRule,\n IAnimationStateMachine\n} from '../intreface/state';\nimport { AnimationStateRegistry } from './animation-state-registry';\nimport { AnimationStateQueue } from './animation-state-queue';\nimport type { AnimateExecutor } from '../executor/animate-executor';\n\ntype StateEventCallback = (state: string, target: IGraphic | IGroup) => void;\n\n/**\n * State machine for managing animation states and transitions\n */\nexport class AnimationStateMachine implements IAnimationStateMachine {\n private registry: AnimationStateRegistry;\n private stateQueue: AnimationStateQueue;\n private eventListeners: Map<AnimationStateEventType, Set<StateEventCallback>> = new Map();\n\n constructor(private target: IGraphic | IGroup, private executor: AnimateExecutor) {\n this.registry = new AnimationStateRegistry();\n this.stateQueue = new AnimationStateQueue(target, this.registry, executor, this.handleStateEvent.bind(this));\n }\n\n /**\n * Apply a state or sequence of states\n */\n applyState(state: string | string[]): void {\n this.stateQueue.enqueue(state);\n }\n\n /**\n * Register new state animations and rules\n */\n registerState(config: IAnimationStateConfig, rule?: IAnimationStateRule): void {\n this.registry.register(config, rule);\n }\n\n /**\n * Get current active state\n */\n getActiveState(): string | null {\n return this.stateQueue.getActiveState();\n }\n\n /**\n * Cancel all animations and clear queue\n */\n reset(): void {\n this.stateQueue.cancel();\n }\n\n /**\n * Add event listener for state events\n */\n on(event: AnimationStateEventType, callback: StateEventCallback): void {\n if (!this.eventListeners.has(event)) {\n this.eventListeners.set(event, new Set());\n }\n this.eventListeners.get(event)?.add(callback);\n }\n\n /**\n * Remove event listener\n */\n off(event: AnimationStateEventType, callback: StateEventCallback): void {\n const listeners = this.eventListeners.get(event);\n if (listeners) {\n listeners.delete(callback);\n }\n }\n\n /**\n * Handle state change events from the queue\n */\n private handleStateEvent(event: 'stateStart' | 'stateEnd' | 'stateInterrupt' | 'stateReject', state: string): void {\n const listeners = this.eventListeners.get(event);\n if (listeners) {\n listeners.forEach(callback => {\n try {\n callback(state, this.target);\n } catch (error) {\n console.error(`Error in animation state event listener for ${event}:`, error);\n }\n });\n }\n }\n\n /**\n * Check if a specific state is registered\n */\n hasState(state: string): boolean {\n return !!this.registry.getState(state);\n }\n\n /**\n * Get all registered state names\n */\n getRegisteredStates(): string[] {\n return this.registry.getAllStateNames();\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import type { IGraphic, IGroup } from '@visactor/vrender-core';
2
+ import type { IAnimationStateQueue } from '../intreface/state';
3
+ import type { AnimationStateRegistry } from './animation-state-registry';
4
+ import type { AnimateExecutor } from '../executor/animate-executor';
5
+ export declare class AnimationStateQueue implements IAnimationStateQueue {
6
+ private target;
7
+ private registry;
8
+ private executor;
9
+ private onStateChange;
10
+ private queue;
11
+ private activeState;
12
+ private activeAnimation;
13
+ private processingQueue;
14
+ constructor(target: IGraphic | IGroup, registry: AnimationStateRegistry, executor: AnimateExecutor, onStateChange: (event: 'stateStart' | 'stateEnd' | 'stateInterrupt' | 'stateReject', state: string) => void);
15
+ enqueue(states: string | string[]): void;
16
+ processNextState(): void;
17
+ private applyState;
18
+ onAnimationComplete(): void;
19
+ private interruptCurrentState;
20
+ cancel(): void;
21
+ canApplyState(state: string): boolean;
22
+ getActiveState(): string | null;
23
+ getPendingStates(): string[];
24
+ }
@@ -0,0 +1,58 @@
1
+ import { isArray } from "@visactor/vutils";
2
+
3
+ export class AnimationStateQueue {
4
+ constructor(target, registry, executor, onStateChange) {
5
+ this.target = target, this.registry = registry, this.executor = executor, this.onStateChange = onStateChange,
6
+ this.queue = [], this.activeState = null, this.activeAnimation = null, this.processingQueue = !1;
7
+ }
8
+ enqueue(states) {
9
+ if (isArray(states)) for (const state of states) this.queue.push(state); else this.queue.push(states);
10
+ this.processingQueue || this.processNextState();
11
+ }
12
+ processNextState() {
13
+ if (0 === this.queue.length || this.processingQueue) return;
14
+ this.processingQueue = !0;
15
+ const nextState = this.queue[0];
16
+ this.canApplyState(nextState) ? (this.queue.shift(), this.activeState && this.registry.hasConflict(this.activeState, nextState) ? this.registry.canInterrupt(this.activeState, nextState) ? (this.interruptCurrentState(),
17
+ this.applyState(nextState)) : (this.onStateChange("stateReject", nextState), this.processingQueue = !1,
18
+ this.processNextState()) : this.applyState(nextState)) : (this.queue.shift(), this.onStateChange("stateReject", nextState),
19
+ this.processingQueue = !1, this.processNextState());
20
+ }
21
+ applyState(state) {
22
+ const stateConfig = this.registry.getState(state);
23
+ if (!stateConfig) return console.warn(`Animation state "${state}" not found`), this.processingQueue = !1,
24
+ void this.processNextState();
25
+ this.activeState = state, this.onStateChange("stateStart", state), this.activeAnimation = this.executor.executeItem(stateConfig.animation, this.target),
26
+ this.activeAnimation ? this.activeAnimation.onEnd((() => {
27
+ this.onAnimationComplete();
28
+ })) : this.onAnimationComplete();
29
+ }
30
+ onAnimationComplete() {
31
+ if (this.activeState) {
32
+ const completedState = this.activeState;
33
+ this.onStateChange("stateEnd", completedState);
34
+ const transitionDelay = this.registry.getTransitionDelay(completedState);
35
+ this.activeState = null, this.activeAnimation = null, this.processingQueue = !1,
36
+ transitionDelay > 0 ? setTimeout((() => {
37
+ this.processNextState();
38
+ }), transitionDelay) : this.processNextState();
39
+ }
40
+ }
41
+ interruptCurrentState() {
42
+ this.activeState && this.activeAnimation && (this.onStateChange("stateInterrupt", this.activeState),
43
+ this.activeAnimation.stop("end"), this.activeAnimation = null, this.activeState = null);
44
+ }
45
+ cancel() {
46
+ this.interruptCurrentState(), this.queue = [], this.processingQueue = !1;
47
+ }
48
+ canApplyState(state) {
49
+ return !!this.registry.getState(state) && (!this.activeState || (!this.registry.hasConflict(this.activeState, state) || this.registry.canInterrupt(this.activeState, state)));
50
+ }
51
+ getActiveState() {
52
+ return this.activeState;
53
+ }
54
+ getPendingStates() {
55
+ return [ ...this.queue ];
56
+ }
57
+ }
58
+ //# sourceMappingURL=animation-state-queue.js.map