@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,105 @@
1
+ import { ACustomAnimate } from "./custom-animate";
2
+
3
+ import { isNumber } from "@visactor/vutils";
4
+
5
+ const growRadiusInIndividual = (graphic, options, animationParameters) => {
6
+ const attrs = graphic.getFinalAttribute();
7
+ return options && "inside" === options.orient ? {
8
+ from: {
9
+ innerRadius: null == attrs ? void 0 : attrs.outerRadius
10
+ },
11
+ to: {
12
+ innerRadius: null == attrs ? void 0 : attrs.innerRadius
13
+ }
14
+ } : {
15
+ from: {
16
+ outerRadius: null == attrs ? void 0 : attrs.innerRadius
17
+ },
18
+ to: {
19
+ outerRadius: null == attrs ? void 0 : attrs.outerRadius
20
+ }
21
+ };
22
+ }, growRadiusInOverall = (graphic, options, animationParameters) => {
23
+ const attrs = graphic.getFinalAttribute(), overallValue = isNumber(null == options ? void 0 : options.overall) ? options.overall : 0;
24
+ return {
25
+ from: {
26
+ innerRadius: overallValue,
27
+ outerRadius: overallValue
28
+ },
29
+ to: {
30
+ innerRadius: null == attrs ? void 0 : attrs.innerRadius,
31
+ outerRadius: null == attrs ? void 0 : attrs.outerRadius
32
+ }
33
+ };
34
+ };
35
+
36
+ export const growRadiusIn = (graphic, options, animationParameters) => {
37
+ var _a;
38
+ return !1 !== (null !== (_a = null == options ? void 0 : options.overall) && void 0 !== _a && _a) ? growRadiusInOverall(graphic, options) : growRadiusInIndividual(graphic, options);
39
+ };
40
+
41
+ const growRadiusOutIndividual = (graphic, options, animationParameters) => {
42
+ const attrs = graphic.getFinalAttribute();
43
+ return options && "inside" === options.orient ? {
44
+ from: {
45
+ innerRadius: graphic.getGraphicAttribute("innerRadius", !0)
46
+ },
47
+ to: {
48
+ innerRadius: null == attrs ? void 0 : attrs.outerRadius
49
+ }
50
+ } : {
51
+ from: {
52
+ outerRadius: graphic.getGraphicAttribute("outerRadius", !0)
53
+ },
54
+ to: {
55
+ outerRadius: null == attrs ? void 0 : attrs.innerRadius
56
+ }
57
+ };
58
+ }, growRadiusOutOverall = (graphic, options, animationParameters) => {
59
+ const overallValue = isNumber(null == options ? void 0 : options.overall) ? options.overall : 0;
60
+ return {
61
+ from: {
62
+ innerRadius: graphic.getGraphicAttribute("innerRadius", !0),
63
+ outerRadius: graphic.getGraphicAttribute("outerRadius", !0)
64
+ },
65
+ to: {
66
+ innerRadius: overallValue,
67
+ outerRadius: overallValue
68
+ }
69
+ };
70
+ };
71
+
72
+ export const growRadiusOut = (graphic, options, animationParameters) => {
73
+ var _a;
74
+ return !1 !== (null !== (_a = null == options ? void 0 : options.overall) && void 0 !== _a && _a) ? growRadiusOutOverall(graphic, options) : growRadiusOutIndividual(graphic, options);
75
+ };
76
+
77
+ export class GworPointsBase extends ACustomAnimate {
78
+ constructor(from, to, duration, easing, params) {
79
+ super(from, to, duration, easing, params);
80
+ }
81
+ onUpdate(end, ratio, out) {
82
+ this.propKeys.forEach((key => {
83
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
84
+ })), this.target.setAttributes(out);
85
+ }
86
+ }
87
+
88
+ export class GrowRadiusIn extends GworPointsBase {
89
+ onBind() {
90
+ var _a;
91
+ const {from: from, to: to} = growRadiusIn(this.target, this.params.options, this.params), fromAttrs = null !== (_a = this.target.context.lastAttrs) && void 0 !== _a ? _a : from;
92
+ this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
93
+ this.animate.reSyncProps(), this.from = fromAttrs, this.to = to, this.target.setAttributes(fromAttrs);
94
+ }
95
+ }
96
+
97
+ export class GrowRadiusOut extends GworPointsBase {
98
+ onBind() {
99
+ var _a;
100
+ const {from: from, to: to} = growRadiusOut(this.target, this.params.options, this.params), fromAttrs = null !== (_a = this.target.context.lastAttrs) && void 0 !== _a ? _a : from;
101
+ this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
102
+ this.animate.reSyncProps(), this.from = fromAttrs, this.to = to, this.target.setAttributes(fromAttrs);
103
+ }
104
+ }
105
+ //#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AG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;CACF","file":"growRadius.js","sourcesContent":["import { type IGraphic, type IGroup } from '@visactor/vrender-core';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\nimport { isNumber } from '@visactor/vutils';\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\ntype TypeAnimation<T extends IGraphic> = (\n graphic: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nexport interface IGrowAngleAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n overall?: boolean | number;\n}\n\nexport interface IGrowRadiusAnimationOptions {\n orient?: 'inside' | 'outside';\n overall?: boolean | number;\n}\n\nconst growRadiusInIndividual = (\n graphic: IGraphic,\n options: IGrowRadiusAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.getFinalAttribute();\n\n if (options && options.orient === 'inside') {\n return {\n from: { innerRadius: attrs?.outerRadius },\n to: { innerRadius: attrs?.innerRadius }\n };\n }\n return {\n from: { outerRadius: attrs?.innerRadius },\n to: { outerRadius: attrs?.outerRadius }\n };\n};\n\nconst growRadiusInOverall = (\n graphic: IGraphic,\n options: IGrowRadiusAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.getFinalAttribute();\n const overallValue = isNumber(options?.overall) ? options.overall : 0;\n return {\n from: {\n innerRadius: overallValue,\n outerRadius: overallValue\n },\n to: {\n innerRadius: attrs?.innerRadius,\n outerRadius: attrs?.outerRadius\n }\n };\n};\n\nexport const growRadiusIn: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowRadiusAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growRadiusInOverall(graphic, options, animationParameters)\n : growRadiusInIndividual(graphic, options, animationParameters);\n};\n\nconst growRadiusOutIndividual = (\n graphic: IGraphic,\n options: IGrowRadiusAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.getFinalAttribute();\n if (options && options.orient === 'inside') {\n return {\n from: { innerRadius: graphic.getGraphicAttribute('innerRadius', true) },\n to: { innerRadius: attrs?.outerRadius }\n };\n }\n return {\n from: { outerRadius: graphic.getGraphicAttribute('outerRadius', true) },\n to: { outerRadius: attrs?.innerRadius }\n };\n};\n\nconst growRadiusOutOverall = (\n graphic: IGraphic,\n options: IGrowRadiusAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const overallValue = isNumber(options?.overall) ? options.overall : 0;\n return {\n from: {\n innerRadius: graphic.getGraphicAttribute('innerRadius', true),\n outerRadius: graphic.getGraphicAttribute('outerRadius', true)\n },\n to: {\n innerRadius: overallValue,\n outerRadius: overallValue\n }\n };\n};\n\nexport const growRadiusOut: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowRadiusAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growRadiusOutOverall(graphic, options, animationParameters)\n : growRadiusOutIndividual(graphic, options, animationParameters);\n};\n\nexport class GworPointsBase extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n this.propKeys.forEach(key => {\n out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.setAttributes(out);\n }\n}\n\n/**\n * 增长渐入\n */\nexport class GrowRadiusIn extends GworPointsBase {\n onBind(): void {\n const { from, to } = growRadiusIn(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.animate.reSyncProps();\n this.from = fromAttrs;\n this.to = to;\n this.target.setAttributes(fromAttrs);\n }\n}\n\nexport class GrowRadiusOut extends GworPointsBase {\n onBind(): void {\n const { from, to } = growRadiusOut(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.animate.reSyncProps();\n this.from = fromAttrs;\n this.to = to;\n this.target.setAttributes(fromAttrs);\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import type { IGraphic, IGroup } from '@visactor/vrender-core';
2
+ import type { IAnimate, IStep } from '../intreface/animate';
3
+ import type { EasingType } from '../intreface/easing';
4
+ import { ACustomAnimate } from './custom-animate';
5
+ interface IAnimationParameters {
6
+ width: number;
7
+ height: number;
8
+ group: IGroup;
9
+ elementIndex: number;
10
+ elementCount: number;
11
+ view: any;
12
+ }
13
+ type TypeAnimation<T extends IGraphic> = (graphic: T, options: any, animationParameters: IAnimationParameters) => {
14
+ from?: {
15
+ [channel: string]: any;
16
+ };
17
+ to?: {
18
+ [channel: string]: any;
19
+ };
20
+ };
21
+ export declare const growWidthOut: TypeAnimation<IGraphic>;
22
+ export declare class GrowWidthIn extends ACustomAnimate<Record<string, number>> {
23
+ valid: boolean;
24
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: any);
25
+ onBind(): void;
26
+ onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
27
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
28
+ }
29
+ export declare class GrowWidthOut extends ACustomAnimate<Record<string, number>> {
30
+ valid: boolean;
31
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: any);
32
+ onBind(): void;
33
+ onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
34
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
35
+ }
36
+ export {};
@@ -0,0 +1,144 @@
1
+ import { isNil, isNumber, isValid } from "@visactor/vutils";
2
+
3
+ import { ACustomAnimate } from "./custom-animate";
4
+
5
+ function growWidthInIndividual(graphic, options, animationParameters) {
6
+ const attrs = graphic.getFinalAttribute(), x = attrs.x, x1 = attrs.x1, width = attrs.width;
7
+ if (options && "negative" === options.orient) {
8
+ const computedX1 = isValid(width) ? Math.max(x, x + width) : Math.max(x, x1);
9
+ return {
10
+ from: {
11
+ x: computedX1,
12
+ x1: isNil(x1) ? void 0 : computedX1,
13
+ width: isNil(width) ? void 0 : 0
14
+ },
15
+ to: {
16
+ x: x,
17
+ x1: x1,
18
+ width: width
19
+ }
20
+ };
21
+ }
22
+ const computedX = isValid(width) ? Math.min(x, x + width) : Math.min(x, x1);
23
+ return {
24
+ from: {
25
+ x: computedX,
26
+ x1: isNil(x1) ? void 0 : computedX,
27
+ width: isNil(width) ? void 0 : 0
28
+ },
29
+ to: {
30
+ x: x,
31
+ x1: x1,
32
+ width: width
33
+ }
34
+ };
35
+ }
36
+
37
+ function growWidthInOverall(graphic, options, animationParameters) {
38
+ var _a;
39
+ const attrs = graphic.getFinalAttribute(), x = attrs.x, x1 = attrs.x1, width = attrs.width;
40
+ let overallValue;
41
+ return options && "negative" === options.orient ? isNumber(options.overall) ? overallValue = options.overall : animationParameters.group ? (overallValue = null !== (_a = animationParameters.groupWidth) && void 0 !== _a ? _a : animationParameters.group.getBounds().width(),
42
+ animationParameters.groupWidth = overallValue) : overallValue = animationParameters.width : overallValue = isNumber(null == options ? void 0 : options.overall) ? null == options ? void 0 : options.overall : 0,
43
+ {
44
+ from: {
45
+ x: overallValue,
46
+ x1: isNil(x1) ? void 0 : overallValue,
47
+ width: isNil(width) ? void 0 : 0
48
+ },
49
+ to: {
50
+ x: x,
51
+ x1: x1,
52
+ width: width
53
+ }
54
+ };
55
+ }
56
+
57
+ const growWidthIn = (graphic, options, animationParameters) => {
58
+ var _a;
59
+ return !1 !== (null !== (_a = null == options ? void 0 : options.overall) && void 0 !== _a && _a) ? growWidthInOverall(graphic, options, animationParameters) : growWidthInIndividual(graphic, options, animationParameters);
60
+ };
61
+
62
+ function growWidthOutIndividual(graphic, options, animationParameters) {
63
+ const attrs = graphic.getFinalAttribute(), x = attrs.x, x1 = attrs.x1, width = attrs.width;
64
+ if (options && "negative" === options.orient) {
65
+ const computedX1 = isValid(width) ? Math.max(x, x + width) : Math.max(x, x1);
66
+ return {
67
+ to: {
68
+ x: computedX1,
69
+ x1: isNil(x1) ? void 0 : computedX1,
70
+ width: isNil(width) ? void 0 : 0
71
+ }
72
+ };
73
+ }
74
+ const computedX = isValid(width) ? Math.min(x, x + width) : Math.min(x, x1);
75
+ return {
76
+ to: {
77
+ x: computedX,
78
+ x1: isNil(x1) ? void 0 : computedX,
79
+ width: isNil(width) ? void 0 : 0
80
+ }
81
+ };
82
+ }
83
+
84
+ function growWidthOutOverall(graphic, options, animationParameters) {
85
+ var _a;
86
+ const attrs = graphic.getFinalAttribute(), x1 = attrs.x1, width = attrs.width;
87
+ let overallValue;
88
+ return options && "negative" === options.orient ? isNumber(options.overall) ? overallValue = options.overall : animationParameters.group ? (overallValue = null !== (_a = animationParameters.groupWidth) && void 0 !== _a ? _a : animationParameters.group.getBounds().width(),
89
+ animationParameters.groupWidth = overallValue) : overallValue = animationParameters.width : overallValue = isNumber(null == options ? void 0 : options.overall) ? options.overall : 0,
90
+ {
91
+ to: {
92
+ x: overallValue,
93
+ x1: isNil(x1) ? void 0 : overallValue,
94
+ width: isNil(width) ? void 0 : 0
95
+ }
96
+ };
97
+ }
98
+
99
+ export const growWidthOut = (graphic, options, animationParameters) => {
100
+ var _a;
101
+ return !1 !== (null !== (_a = null == options ? void 0 : options.overall) && void 0 !== _a && _a) ? growWidthOutOverall(graphic, options, animationParameters) : growWidthOutIndividual(graphic, options, animationParameters);
102
+ };
103
+
104
+ export class GrowWidthIn extends ACustomAnimate {
105
+ constructor(from, to, duration, easing, params) {
106
+ super(from, to, duration, easing, params);
107
+ }
108
+ onBind() {
109
+ var _a;
110
+ const {from: from, to: to} = growWidthIn(this.target, this.params.options, this.params), fromAttrs = null !== (_a = this.target.context.lastAttrs) && void 0 !== _a ? _a : from;
111
+ this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
112
+ this.animate.reSyncProps(), this.from = fromAttrs, this.to = to, this.target.setAttributes(fromAttrs);
113
+ }
114
+ onEnd(cb) {
115
+ super.onEnd(cb);
116
+ }
117
+ onUpdate(end, ratio, out) {
118
+ this.propKeys.forEach((key => {
119
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
120
+ })), this.target.setAttributes(out);
121
+ }
122
+ }
123
+
124
+ export class GrowWidthOut extends ACustomAnimate {
125
+ constructor(from, to, duration, easing, params) {
126
+ super(from, to, duration, easing, params);
127
+ }
128
+ onBind() {
129
+ const attrs = this.target.getFinalAttribute(), {from: from, to: to} = (graphic = this.target,
130
+ options = this.params.options, animationParameters = this.params, !1 !== (null !== (_a = null == options ? void 0 : options.overall) && void 0 !== _a && _a) ? growWidthOutOverall(graphic, options, animationParameters) : growWidthOutIndividual(graphic, options, animationParameters));
131
+ var graphic, options, animationParameters, _a;
132
+ this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
133
+ this.animate.reSyncProps(), this.from = from || attrs, this.to = to;
134
+ }
135
+ onEnd(cb) {
136
+ super.onEnd(cb);
137
+ }
138
+ onUpdate(end, ratio, out) {
139
+ this.propKeys.forEach((key => {
140
+ out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
141
+ })), this.target.setAttributes(out);
142
+ }
143
+ }
144
+ //# sourceMappingURL=growWidth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/custom/growWidth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAA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AC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC9C,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACjF,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,KAAK,CAAC;QAC1B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IAEf,CAAC;IAED,KAAK,CAAC,EAA6C;QACjD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACtE,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;CACF","file":"growWidth.js","sourcesContent":["import type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport { isNil, isNumber, isValid } from '@visactor/vutils';\nimport type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\ninterface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\ntype TypeAnimation<T extends IGraphic> = (\n graphic: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nfunction growWidthInIndividual(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n\n if (options && options.orient === 'negative') {\n const computedX1 = isValid(width) ? Math.max(x, x + width) : Math.max(x, x1);\n\n return {\n from: { x: computedX1, x1: isNil(x1) ? undefined : computedX1, width: isNil(width) ? undefined : 0 },\n to: { x: x, x1: x1, width: width }\n };\n }\n\n const computedX = isValid(width) ? Math.min(x, x + width) : Math.min(x, x1);\n return {\n from: { x: computedX, x1: isNil(x1) ? undefined : computedX, width: isNil(width) ? undefined : 0 },\n to: { x: x, x1: x1, width: width }\n };\n}\n\nfunction growWidthInOverall(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n // no need to handle the situation where x > x1\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n let overallValue: number;\n if (options && options.orient === 'negative') {\n if (isNumber(options.overall)) {\n overallValue = options.overall;\n } else if (animationParameters.group) {\n overallValue = (animationParameters as any).groupWidth ?? animationParameters.group.getBounds().width();\n\n (animationParameters as any).groupWidth = overallValue;\n } else {\n overallValue = animationParameters.width;\n }\n } else {\n overallValue = isNumber(options?.overall) ? options?.overall : 0;\n }\n return {\n from: { x: overallValue, x1: isNil(x1) ? undefined : overallValue, width: isNil(width) ? undefined : 0 },\n to: { x: x, x1: x1, width: width }\n };\n}\n\nconst growWidthIn: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growWidthInOverall(graphic, options, animationParameters)\n : growWidthInIndividual(graphic, options, animationParameters);\n};\n\nfunction growWidthOutIndividual(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n\n if (options && options.orient === 'negative') {\n const computedX1 = isValid(width) ? Math.max(x, x + width) : Math.max(x, x1);\n\n return {\n to: { x: computedX1, x1: isNil(x1) ? undefined : computedX1, width: isNil(width) ? undefined : 0 }\n };\n }\n\n const computedX = isValid(width) ? Math.min(x, x + width) : Math.min(x, x1);\n return {\n to: { x: computedX, x1: isNil(x1) ? undefined : computedX, width: isNil(width) ? undefined : 0 }\n };\n}\n\nfunction growWidthOutOverall(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const x1 = attrs.x1;\n const width = attrs.width;\n\n let overallValue: number;\n if (options && options.orient === 'negative') {\n if (isNumber(options.overall)) {\n overallValue = options.overall;\n } else if (animationParameters.group) {\n overallValue = (animationParameters as any).groupWidth ?? animationParameters.group.getBounds().width();\n\n (animationParameters as any).groupWidth = overallValue;\n } else {\n overallValue = animationParameters.width;\n }\n } else {\n overallValue = isNumber(options?.overall) ? options.overall : 0;\n }\n return {\n to: { x: overallValue, x1: isNil(x1) ? undefined : overallValue, width: isNil(width) ? undefined : 0 }\n };\n}\n\nexport const growWidthOut: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growWidthOutOverall(graphic, options, animationParameters)\n : growWidthOutIndividual(graphic, options, animationParameters);\n};\n\n/**\n * 增长渐入\n */\nexport class GrowWidthIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n const { from, to } = growWidthIn(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.animate.reSyncProps();\n this.from = fromAttrs;\n this.to = to;\n this.target.setAttributes(fromAttrs);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n this.propKeys.forEach(key => {\n out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.setAttributes(out);\n }\n}\n\nexport class GrowWidthOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n const attrs = this.target.getFinalAttribute();\n const { from, to } = growWidthOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.animate.reSyncProps();\n this.from = from || attrs;\n this.to = to;\n // this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n this.propKeys.forEach(key => {\n out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.setAttributes(out);\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import type { IAnimate, IStep } from '../intreface/animate';
2
+ import type { EasingType } from '../intreface/easing';
3
+ import { ACustomAnimate } from './custom-animate';
4
+ export declare class InputText extends ACustomAnimate<{
5
+ text: string;
6
+ }> {
7
+ valid: boolean;
8
+ private fromText;
9
+ private toText;
10
+ private showCursor;
11
+ private cursorChar;
12
+ private blinkCursor;
13
+ private beforeText;
14
+ private afterText;
15
+ constructor(from: {
16
+ text: string;
17
+ }, to: {
18
+ text: string;
19
+ }, duration: number, easing: EasingType, params?: {
20
+ showCursor?: boolean;
21
+ cursorChar?: string;
22
+ blinkCursor?: boolean;
23
+ beforeText?: string;
24
+ afterText?: string;
25
+ });
26
+ onFirstRun(): void;
27
+ onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
28
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
29
+ }
@@ -0,0 +1,37 @@
1
+ import { ACustomAnimate } from "./custom-animate";
2
+
3
+ export class InputText extends ACustomAnimate {
4
+ constructor(from, to, duration, easing, params) {
5
+ super(from, to, duration, easing, params), this.fromText = "", this.toText = "",
6
+ this.showCursor = !1, this.cursorChar = "|", this.blinkCursor = !0, this.beforeText = "",
7
+ this.afterText = "", void 0 !== (null == params ? void 0 : params.showCursor) && (this.showCursor = params.showCursor),
8
+ void 0 !== (null == params ? void 0 : params.cursorChar) && (this.cursorChar = params.cursorChar),
9
+ void 0 !== (null == params ? void 0 : params.blinkCursor) && (this.blinkCursor = params.blinkCursor),
10
+ void 0 !== (null == params ? void 0 : params.beforeText) && (this.beforeText = params.beforeText),
11
+ void 0 !== (null == params ? void 0 : params.afterText) && (this.afterText = params.afterText);
12
+ }
13
+ onFirstRun() {
14
+ var _a, _b;
15
+ const fromProps = this.getLastProps(), toProps = this.getEndProps(), fromText = null !== (_a = fromProps.text) && void 0 !== _a ? _a : "", toText = null !== (_b = toProps.text) && void 0 !== _b ? _b : "";
16
+ this.valid = !0, this.fromText = fromText.toString(), this.toText = toText.toString(),
17
+ this.toText || "" === this.toText || (this.valid = !1);
18
+ }
19
+ onEnd(cb) {
20
+ super.onEnd(cb), cb || (this.showCursor && !this.blinkCursor ? this.target.setAttribute("text", this.beforeText + this.toText + this.cursorChar + this.afterText) : this.target.setAttribute("text", this.beforeText + this.toText + this.afterText));
21
+ }
22
+ onUpdate(end, ratio, out) {
23
+ if (!this.valid) return;
24
+ const totalChars = this.toText.length, fromChars = this.fromText.length;
25
+ let currentLength, currentText;
26
+ fromChars > totalChars ? (currentLength = Math.round(fromChars - (fromChars - totalChars) * ratio),
27
+ currentText = this.fromText.substring(0, currentLength)) : (currentLength = Math.round(fromChars + (totalChars - fromChars) * ratio),
28
+ currentText = this.toText.startsWith(this.fromText) ? this.toText.substring(0, currentLength) : currentLength <= fromChars ? this.fromText.substring(0, currentLength) : this.toText.substring(0, currentLength - fromChars + Math.min(fromChars, currentLength)));
29
+ let displayText = this.beforeText + currentText + this.afterText;
30
+ if (this.showCursor) if (this.blinkCursor) {
31
+ const blinkRate = .1;
32
+ Math.floor(ratio / blinkRate) % 2 == 0 && (displayText = this.beforeText + currentText + this.cursorChar + this.afterText);
33
+ } else displayText = this.beforeText + currentText + this.cursorChar + this.afterText;
34
+ this.target.setAttribute("text", displayText);
35
+ }
36
+ }
37
+ //# sourceMappingURL=input-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/custom/input-text.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOlD,MAAM,OAAO,SAAU,SAAQ,cAAgC;IAW7D,YACE,IAAsB,EACtB,EAAoB,EACpB,QAAgB,EAChB,MAAkB,EAClB,MAMC;QAED,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QArBpC,aAAQ,GAAW,EAAE,CAAC;QACtB,WAAM,GAAW,EAAE,CAAC;QACpB,eAAU,GAAY,KAAK,CAAC;QAC5B,eAAU,GAAW,GAAG,CAAC;QACzB,gBAAW,GAAY,IAAI,CAAC;QAC5B,eAAU,GAAW,EAAE,CAAC;QACxB,cAAS,GAAW,EAAE,CAAC;QAkB7B,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,MAAK,SAAS,EAAE;YACpC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAA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AAI,aAAa,IAAI,SAAS,EAAE;oBAC9B,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;iBACzD;qBAAM;oBACL,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;iBACxG;aACF;SACF;QAGD,IAAI,WAAW,GAAG,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC;QAGjE,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,IAAI,CAAC,WAAW,EAAE;gBAEpB,MAAM,SAAS,GAAG,GAAG,CAAC;gBACtB,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAE9D,IAAI,aAAa,EAAE;oBACjB,WAAW,GAAG,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;iBAChF;aACF;iBAAM;gBAEL,WAAW,GAAG,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;aAChF;SACF;QAGD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAChD,CAAC;CACF","file":"input-text.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\n/**\n * 文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n */\nexport class InputText extends ACustomAnimate<{ text: string }> {\n declare valid: boolean;\n\n private fromText: string = '';\n private toText: string = '';\n private showCursor: boolean = false;\n private cursorChar: string = '|';\n private blinkCursor: boolean = true;\n private beforeText: string = '';\n private afterText: string = '';\n\n constructor(\n from: { text: string },\n to: { text: string },\n duration: number,\n easing: EasingType,\n params?: {\n showCursor?: boolean;\n cursorChar?: string;\n blinkCursor?: boolean;\n beforeText?: string;\n afterText?: string;\n }\n ) {\n super(from, to, duration, easing, params);\n\n // 配置光标相关选项\n if (params?.showCursor !== undefined) {\n this.showCursor = params.showCursor;\n }\n if (params?.cursorChar !== undefined) {\n this.cursorChar = params.cursorChar;\n }\n if (params?.blinkCursor !== undefined) {\n this.blinkCursor = params.blinkCursor;\n }\n\n // 配置前缀和后缀文本\n if (params?.beforeText !== undefined) {\n this.beforeText = params.beforeText;\n }\n if (params?.afterText !== undefined) {\n this.afterText = params.afterText;\n }\n }\n\n onFirstRun(): void {\n const fromProps = this.getLastProps();\n const toProps = this.getEndProps();\n const fromText = fromProps.text ?? '';\n const toText = toProps.text ?? '';\n\n // 初始化解析结果\n this.valid = true;\n\n // 存储文本用于动画\n this.fromText = fromText.toString();\n this.toText = toText.toString();\n\n // 确保to不为空\n if (!this.toText && this.toText !== '') {\n this.valid = false;\n return;\n }\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n if (!cb) {\n // 动画结束时,显示完整文本(不带闪烁光标)\n if (this.showCursor && !this.blinkCursor) {\n // 如果有光标但不闪烁,保留光标\n this.target.setAttribute('text', this.beforeText + this.toText + this.cursorChar + this.afterText);\n } else {\n // 不显示光标\n this.target.setAttribute('text', this.beforeText + this.toText + this.afterText);\n }\n }\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this.valid) {\n return;\n }\n\n // 计算当前应该显示的字符数量\n const totalChars = this.toText.length;\n const fromChars = this.fromText.length;\n\n // 如果fromText比toText长,则是删除动画\n // 否则是添加动画\n let currentLength: number;\n let currentText: string;\n\n if (fromChars > totalChars) {\n // 删除文本动画(从多到少)\n currentLength = Math.round(fromChars - (fromChars - totalChars) * ratio);\n currentText = this.fromText.substring(0, currentLength);\n } else {\n // 添加文本动画(从少到多)\n currentLength = Math.round(fromChars + (totalChars - fromChars) * ratio);\n\n // 如果fromText是toText的前缀,则直接使用toText的子串\n if (this.toText.startsWith(this.fromText)) {\n currentText = this.toText.substring(0, currentLength);\n } else {\n // 否则需要在fromText和toText之间进行过渡\n if (currentLength <= fromChars) {\n currentText = this.fromText.substring(0, currentLength);\n } else {\n currentText = this.toText.substring(0, currentLength - fromChars + Math.min(fromChars, currentLength));\n }\n }\n }\n\n // 构建最终显示的文本\n let displayText = this.beforeText + currentText + this.afterText;\n\n // 添加光标效果\n if (this.showCursor) {\n if (this.blinkCursor) {\n // 闪烁效果:在动画期间,光标每半个周期闪烁一次\n const blinkRate = 0.1; // 光标闪烁频率(每10%动画进度闪烁一次)\n const showCursorNow = Math.floor(ratio / blinkRate) % 2 === 0;\n\n if (showCursorNow) {\n displayText = this.beforeText + currentText + this.cursorChar + this.afterText;\n }\n } else {\n // 固定光标(不闪烁)\n displayText = this.beforeText + currentText + this.cursorChar + this.afterText;\n }\n }\n\n // 更新图形的text属性\n this.target.setAttribute('text', displayText);\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import type { IAnimate, IStep } from '../intreface/animate';
2
+ import type { EasingType } from '../intreface/easing';
3
+ import { ACustomAnimate } from './custom-animate';
4
+ export declare class IncreaseCount extends ACustomAnimate<{
5
+ text: string | number;
6
+ }> {
7
+ valid: boolean;
8
+ private fromNumber;
9
+ private toNumber;
10
+ private decimalLength;
11
+ private format;
12
+ private formatTemplate;
13
+ constructor(from: {
14
+ text: string | number;
15
+ }, to: {
16
+ text: string | number;
17
+ }, duration: number, easing: EasingType, params?: {
18
+ decimalLength?: number;
19
+ format?: 'percent' | 'thousandth' | 'none';
20
+ formatTemplate?: string;
21
+ });
22
+ onFirstRun(): void;
23
+ onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
24
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
25
+ }
@@ -0,0 +1,94 @@
1
+ import { ACustomAnimate } from "./custom-animate";
2
+
3
+ export class IncreaseCount extends ACustomAnimate {
4
+ constructor(from, to, duration, easing, params) {
5
+ super(from, to, duration, easing, params), this.formatTemplate = null, this.decimalLength = null == params ? void 0 : params.decimalLength,
6
+ (null == params ? void 0 : params.formatTemplate) && params.formatTemplate.includes("{{var}}") && (this.formatTemplate = params.formatTemplate);
7
+ }
8
+ onFirstRun() {
9
+ var _a, _b, _c;
10
+ const fromProps = this.getLastProps(), toProps = this.getEndProps(), fromText = null !== (_a = fromProps.text) && void 0 !== _a ? _a : 0, toText = null !== (_b = toProps.text) && void 0 !== _b ? _b : 0;
11
+ this.valid = !0;
12
+ let fromNum = 0, toNum = 0, fromFormat = "", toFormat = "", maxDecimalLength = 0;
13
+ if ("number" == typeof fromText) {
14
+ fromNum = fromText;
15
+ const decimalPart = fromText.toString().split(".")[1] || "";
16
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
17
+ } else {
18
+ if ("string" != typeof fromText) return void (this.valid = !1);
19
+ if (fromText.endsWith("%")) {
20
+ fromFormat = "%";
21
+ const cleanNumStr = fromText.substring(0, fromText.length - 1).replace(/,/g, "");
22
+ if (fromNum = parseFloat(cleanNumStr) / 100, isNaN(fromNum)) return void (this.valid = !1);
23
+ const decimalPart = cleanNumStr.split(".")[1] || "";
24
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length + 2);
25
+ } else {
26
+ const cleanNumStr = fromText.replace(/,/g, "");
27
+ if (fromNum = parseFloat(cleanNumStr), isNaN(fromNum)) return void (this.valid = !1);
28
+ fromText.includes(",") && (fromFormat = ",");
29
+ const decimalPart = cleanNumStr.split(".")[1] || "";
30
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
31
+ }
32
+ }
33
+ if ("number" == typeof toText) {
34
+ toNum = toText;
35
+ const decimalPart = toText.toString().split(".")[1] || "";
36
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
37
+ } else {
38
+ if ("string" != typeof toText) return void (this.valid = !1);
39
+ if (toText.endsWith("%")) {
40
+ toFormat = "%";
41
+ const cleanNumStr = toText.substring(0, toText.length - 1).replace(/,/g, "");
42
+ if (toNum = parseFloat(cleanNumStr) / 100, isNaN(toNum)) return void (this.valid = !1);
43
+ const decimalPart = cleanNumStr.split(".")[1] || "";
44
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length + 2);
45
+ } else {
46
+ const cleanNumStr = toText.replace(/,/g, "");
47
+ if (toNum = parseFloat(cleanNumStr), isNaN(toNum)) return void (this.valid = !1);
48
+ toText.includes(",") && (toFormat = ",");
49
+ const decimalPart = cleanNumStr.split(".")[1] || "";
50
+ maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);
51
+ }
52
+ }
53
+ if (null === (_c = this.params) || void 0 === _c ? void 0 : _c.format) {
54
+ switch (this.params.format) {
55
+ case "percent":
56
+ this.format = "%";
57
+ break;
58
+
59
+ case "thousandth":
60
+ this.format = ",";
61
+ break;
62
+
63
+ case "none":
64
+ this.format = "";
65
+ break;
66
+
67
+ default:
68
+ this.format = toFormat || fromFormat;
69
+ }
70
+ "%" === this.format && "%" !== toFormat && "%" !== fromFormat && void 0 === this.decimalLength && (this.decimalLength = 2),
71
+ "%" === this.format || "%" !== toFormat && "%" !== fromFormat || (fromNum *= 100,
72
+ toNum *= 100);
73
+ } else this.format = toFormat || fromFormat;
74
+ this.fromNumber = fromNum, this.toNumber = toNum, void 0 === this.decimalLength && (this.decimalLength = maxDecimalLength);
75
+ }
76
+ onEnd(cb) {
77
+ super.onEnd(cb), cb || this.props && this.target.setAttributes(this.props);
78
+ }
79
+ onUpdate(end, ratio, out) {
80
+ if (!this.valid) return;
81
+ const currentNumber = this.fromNumber + (this.toNumber - this.fromNumber) * ratio;
82
+ let formattedText = "";
83
+ const format = this.format, numberWithDecimals = ("%" === format ? 100 * currentNumber : currentNumber).toFixed(this.decimalLength);
84
+ let formattedWithBasicFormat, formattedNumber = numberWithDecimals;
85
+ if (parseFloat(numberWithDecimals) === Math.floor(parseFloat(numberWithDecimals)) && (formattedNumber = Math.floor(parseFloat(numberWithDecimals))),
86
+ "%" === format) formattedWithBasicFormat = `${formattedNumber}%`; else if ("," === format) {
87
+ const parts = formattedNumber.toString().split(".");
88
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","), formattedWithBasicFormat = parts.join(".");
89
+ } else formattedWithBasicFormat = formattedNumber;
90
+ formattedText = this.formatTemplate ? this.formatTemplate.replace("{{var}}", formattedWithBasicFormat.toString()) : formattedWithBasicFormat,
91
+ this.target.setAttribute("text", formattedText);
92
+ }
93
+ }
94
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/custom/number.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOlD,MAAM,OAAO,aAAc,SAAQ,cAAyC;IAS1E,YACE,IAA+B,EAC/B,EAA6B,EAC7B,QAAgB,EAChB,MAAkB,EAIlB,MAIC;QAED,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAhBpC,mBAAc,GAAkB,IAAI,CAAC;QAiB3C,IAAI,CAAC,aAAa,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,CAAC;QAG3C,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,KAAI,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YACvE,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;SAC7C;IACH,CAAC;IAED,UAAU;;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,QA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,CAAC,SAAS,EAAE,wBAAwB,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC7F;aAAM;YAEL,aAAa,GAAG,wBAAwB,CAAC;SAC1C;QAGD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAClD,CAAC;CACF","file":"number.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\n/**\n * 数字增加动画,支持string; number; xx%; xx,xxx; xxx.xx%\n * 也支持通过formatTemplate参数指定格式化模板,如 \"{{var}}m\"、\"${{var}}\"\n * format和formatTemplate可以同时生效,先应用format再应用模板\n */\nexport class IncreaseCount extends ACustomAnimate<{ text: string | number }> {\n declare valid: boolean;\n\n private fromNumber: number;\n private toNumber: number;\n private decimalLength: number;\n private format: string;\n private formatTemplate: string | null = null;\n\n constructor(\n from: { text: string | number },\n to: { text: string | number },\n duration: number,\n easing: EasingType,\n // 支持外部控制小数位数以及格式化\n // format控制数字本身的格式化方式\n // formatTemplate可以定义模板字符串如 \"{{var}}m\"、\"${{var}}\",两者可以同时使用\n params?: {\n decimalLength?: number;\n format?: 'percent' | 'thousandth' | 'none';\n formatTemplate?: string;\n }\n ) {\n super(from, to, duration, easing, params);\n this.decimalLength = params?.decimalLength;\n\n // 检查是否提供了格式化模板\n if (params?.formatTemplate && params.formatTemplate.includes('{{var}}')) {\n this.formatTemplate = params.formatTemplate;\n }\n }\n\n onFirstRun(): void {\n const fromProps = this.getLastProps();\n const toProps = this.getEndProps();\n const fromText = fromProps.text ?? 0;\n const toText = toProps.text ?? 0;\n\n // 初始化解析结果\n this.valid = true;\n let fromNum = 0;\n let toNum = 0;\n let fromFormat = '';\n let toFormat = '';\n let maxDecimalLength = 0;\n\n // 解析fromText\n if (typeof fromText === 'number') {\n fromNum = fromText;\n const str = fromText.toString();\n const decimalPart = str.split('.')[1] || '';\n maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);\n } else if (typeof fromText === 'string') {\n // 检查是否是百分比\n if (fromText.endsWith('%')) {\n fromFormat = '%';\n const numStr = fromText.substring(0, fromText.length - 1);\n // 去除可能的千分位逗号\n const cleanNumStr = numStr.replace(/,/g, '');\n fromNum = parseFloat(cleanNumStr) / 100;\n if (isNaN(fromNum)) {\n this.valid = false;\n return;\n }\n const decimalPart = cleanNumStr.split('.')[1] || '';\n maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length + 2); // 百分比需要加2\n } else {\n // 处理普通数字或带千分位逗号的数字\n const cleanNumStr = fromText.replace(/,/g, '');\n fromNum = parseFloat(cleanNumStr);\n if (isNaN(fromNum)) {\n this.valid = false;\n return;\n }\n // 检查是否有千分位\n if (fromText.includes(',')) {\n fromFormat = ',';\n }\n const decimalPart = cleanNumStr.split('.')[1] || '';\n maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);\n }\n } else {\n this.valid = false;\n return;\n }\n\n // 解析toText\n if (typeof toText === 'number') {\n toNum = toText;\n const str = toText.toString();\n const decimalPart = str.split('.')[1] || '';\n maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);\n } else if (typeof toText === 'string') {\n // 检查是否是百分比\n if (toText.endsWith('%')) {\n toFormat = '%';\n const numStr = toText.substring(0, toText.length - 1);\n // 去除可能的千分位逗号\n const cleanNumStr = numStr.replace(/,/g, '');\n toNum = parseFloat(cleanNumStr) / 100;\n if (isNaN(toNum)) {\n this.valid = false;\n return;\n }\n const decimalPart = cleanNumStr.split('.')[1] || '';\n maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length + 2); // 百分比需要加2\n } else {\n // 处理普通数字或带千分位逗号的数字\n const cleanNumStr = toText.replace(/,/g, '');\n toNum = parseFloat(cleanNumStr);\n if (isNaN(toNum)) {\n this.valid = false;\n return;\n }\n // 检查是否有千分位\n if (toText.includes(',')) {\n toFormat = ',';\n }\n const decimalPart = cleanNumStr.split('.')[1] || '';\n maxDecimalLength = Math.max(maxDecimalLength, decimalPart.length);\n }\n } else {\n this.valid = false;\n return;\n }\n\n // 设置最终格式\n // 检查是否有外部传入的格式\n if (this.params?.format) {\n // 使用外部传入的格式,将外部格式映射到内部格式\n switch (this.params.format) {\n case 'percent':\n this.format = '%';\n break;\n case 'thousandth':\n this.format = ',';\n break;\n case 'none':\n this.format = '';\n break;\n default:\n // 如果传入了未知格式,则使用自动检测的格式\n this.format = toFormat || fromFormat;\n }\n\n // 如果外部指定了百分比格式,但输入不是百分比,需要适配\n if (this.format === '%' && toFormat !== '%' && fromFormat !== '%') {\n // 不需要除以100,因为输入不是百分比\n if (this.decimalLength === undefined) {\n // 默认百分比显示2位小数\n this.decimalLength = 2;\n }\n }\n\n // 如果外部指定了不用百分比格式,但输入是百分比,需要适配\n if (this.format !== '%' && (toFormat === '%' || fromFormat === '%')) {\n // 需要乘以100,因为输入是百分比但不显示为百分比\n fromNum = fromNum * 100;\n toNum = toNum * 100;\n }\n } else {\n // 自动检测格式,优先使用toFormat,如果to没有特殊格式则使用fromFormat\n this.format = toFormat || fromFormat;\n }\n\n // 设置fromNumber和toNumber\n this.fromNumber = fromNum;\n this.toNumber = toNum;\n\n // 如果没有传入decimalLength,则根据输入格式设置\n if (this.decimalLength === undefined) {\n this.decimalLength = maxDecimalLength;\n }\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n if (!cb) {\n this.props && this.target.setAttributes(this.props as any);\n }\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this.valid) {\n return;\n }\n // 插值计算当前数值\n const currentNumber = this.fromNumber + (this.toNumber - this.fromNumber) * ratio;\n\n // 根据格式和小数位格式化数字\n let formattedText: string | number = '';\n const format = this.format;\n\n // 首先格式化数字值(保留小数位)\n // 对于百分比,乘以100\n const adjustedNumber = format === '%' ? currentNumber * 100 : currentNumber;\n // 保留指定小数位\n const numberWithDecimals = adjustedNumber.toFixed(this.decimalLength);\n // 如果小数位全是0,转为整数\n let formattedNumber: string | number = numberWithDecimals;\n if (parseFloat(numberWithDecimals) === Math.floor(parseFloat(numberWithDecimals))) {\n formattedNumber = Math.floor(parseFloat(numberWithDecimals));\n }\n\n // 应用基本格式(百分比、千分位)\n let formattedWithBasicFormat: string | number;\n if (format === '%') {\n // 百分比格式\n formattedWithBasicFormat = `${formattedNumber}%`;\n } else if (format === ',') {\n // 千分位格式\n const parts = formattedNumber.toString().split('.');\n parts[0] = parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\n formattedWithBasicFormat = parts.join('.');\n } else {\n // 普通数字格式\n formattedWithBasicFormat = formattedNumber;\n }\n\n // 应用模板(如果存在)\n if (this.formatTemplate) {\n // 使用模板格式化\n formattedText = this.formatTemplate.replace('{{var}}', formattedWithBasicFormat.toString());\n } else {\n // 不使用模板,直接使用基本格式的结果\n formattedText = formattedWithBasicFormat;\n }\n\n // 更新图形的text属性\n this.target.setAttribute('text', formattedText);\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const registerCustomAnimate: () => void;
@@ -0,0 +1,39 @@
1
+ import { AnimateExecutor } from "../executor/animate-executor";
2
+
3
+ import { ClipIn, ClipOut } from "./clip";
4
+
5
+ import { FadeIn, FadeOut } from "./fade";
6
+
7
+ import { GrowAngleIn, GrowAngleOut } from "./growAngle";
8
+
9
+ import { GrowCenterIn, GrowCenterOut } from "./growCenter";
10
+
11
+ import { GrowHeightIn, GrowHeightOut } from "./growHeight";
12
+
13
+ import { GrowPointsIn, GrowPointsOut, GrowPointsXIn, GrowPointsXOut, GrowPointsYIn, GrowPointsYOut } from "./growPoints";
14
+
15
+ import { GrowRadiusIn, GrowRadiusOut } from "./growRadius";
16
+
17
+ import { GrowWidthIn, GrowWidthOut } from "./growWidth";
18
+
19
+ import { ScaleIn, ScaleOut } from "./scale";
20
+
21
+ import { State } from "./state";
22
+
23
+ import { Update } from "./update";
24
+
25
+ export const registerCustomAnimate = () => {
26
+ AnimateExecutor.registerBuiltInAnimate("scaleIn", ScaleIn), AnimateExecutor.registerBuiltInAnimate("scaleOut", ScaleOut),
27
+ AnimateExecutor.registerBuiltInAnimate("growHeightIn", GrowHeightIn), AnimateExecutor.registerBuiltInAnimate("growHeightOut", GrowHeightOut),
28
+ AnimateExecutor.registerBuiltInAnimate("growWidthIn", GrowWidthIn), AnimateExecutor.registerBuiltInAnimate("growWidthOut", GrowWidthOut),
29
+ AnimateExecutor.registerBuiltInAnimate("growCenterIn", GrowCenterIn), AnimateExecutor.registerBuiltInAnimate("growCenterOut", GrowCenterOut),
30
+ AnimateExecutor.registerBuiltInAnimate("clipIn", ClipIn), AnimateExecutor.registerBuiltInAnimate("clipOut", ClipOut),
31
+ AnimateExecutor.registerBuiltInAnimate("fadeIn", FadeIn), AnimateExecutor.registerBuiltInAnimate("fadeOut", FadeOut),
32
+ AnimateExecutor.registerBuiltInAnimate("growPointsIn", GrowPointsIn), AnimateExecutor.registerBuiltInAnimate("growPointsOut", GrowPointsOut),
33
+ AnimateExecutor.registerBuiltInAnimate("growPointsXIn", GrowPointsXIn), AnimateExecutor.registerBuiltInAnimate("growPointsXOut", GrowPointsXOut),
34
+ AnimateExecutor.registerBuiltInAnimate("growPointsYIn", GrowPointsYIn), AnimateExecutor.registerBuiltInAnimate("growPointsYOut", GrowPointsYOut),
35
+ AnimateExecutor.registerBuiltInAnimate("growAngleIn", GrowAngleIn), AnimateExecutor.registerBuiltInAnimate("growAngleOut", GrowAngleOut),
36
+ AnimateExecutor.registerBuiltInAnimate("growRadiusIn", GrowRadiusIn), AnimateExecutor.registerBuiltInAnimate("growRadiusOut", GrowRadiusOut),
37
+ AnimateExecutor.registerBuiltInAnimate("update", Update), AnimateExecutor.registerBuiltInAnimate("state", State);
38
+ };
39
+ //# sourceMappingURL=register.js.map