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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/cjs/animate-extension.d.ts +1 -3
  2. package/cjs/animate-extension.js +0 -7
  3. package/cjs/animate-extension.js.map +1 -1
  4. package/cjs/animate.d.ts +1 -5
  5. package/cjs/animate.js +12 -12
  6. package/cjs/animate.js.map +1 -1
  7. package/cjs/component/component-animator.d.ts +3 -2
  8. package/cjs/component/component-animator.js +18 -32
  9. package/cjs/component/component-animator.js.map +1 -1
  10. package/cjs/custom/clip-graphic.d.ts +1 -1
  11. package/cjs/custom/clip-graphic.js.map +1 -1
  12. package/cjs/custom/clip.d.ts +1 -1
  13. package/cjs/custom/clip.js.map +1 -1
  14. package/cjs/custom/common.d.ts +1 -2
  15. package/cjs/custom/common.js +12 -10
  16. package/cjs/custom/common.js.map +1 -1
  17. package/cjs/custom/custom-animate.d.ts +2 -4
  18. package/cjs/custom/custom-animate.js +2 -2
  19. package/cjs/custom/custom-animate.js.map +1 -1
  20. package/cjs/custom/fade.d.ts +1 -1
  21. package/cjs/custom/fade.js.map +1 -1
  22. package/cjs/custom/from-to.d.ts +9 -0
  23. package/cjs/custom/from-to.js +38 -0
  24. package/cjs/custom/from-to.js.map +1 -0
  25. package/cjs/custom/group-fade.d.ts +8 -14
  26. package/cjs/custom/group-fade.js +9 -50
  27. package/cjs/custom/group-fade.js.map +1 -1
  28. package/cjs/custom/growAngle.d.ts +2 -2
  29. package/cjs/custom/growAngle.js +17 -12
  30. package/cjs/custom/growAngle.js.map +1 -1
  31. package/cjs/custom/growCenter.d.ts +1 -2
  32. package/cjs/custom/growCenter.js +8 -7
  33. package/cjs/custom/growCenter.js.map +1 -1
  34. package/cjs/custom/growHeight.d.ts +1 -3
  35. package/cjs/custom/growHeight.js +7 -7
  36. package/cjs/custom/growHeight.js.map +1 -1
  37. package/cjs/custom/growPoints.d.ts +1 -2
  38. package/cjs/custom/growPoints.js +19 -17
  39. package/cjs/custom/growPoints.js.map +1 -1
  40. package/cjs/custom/growRadius.d.ts +4 -5
  41. package/cjs/custom/growRadius.js +12 -12
  42. package/cjs/custom/growRadius.js.map +1 -1
  43. package/cjs/custom/growWidth.d.ts +1 -3
  44. package/cjs/custom/growWidth.js +7 -6
  45. package/cjs/custom/growWidth.js.map +1 -1
  46. package/cjs/custom/input-text.d.ts +1 -2
  47. package/cjs/custom/input-text.js.map +1 -1
  48. package/cjs/custom/label-item-animate.js +2 -2
  49. package/cjs/custom/label-item-animate.js.map +1 -1
  50. package/cjs/custom/move.d.ts +92 -0
  51. package/cjs/custom/move.js +131 -0
  52. package/cjs/custom/move.js.map +1 -0
  53. package/cjs/custom/number.d.ts +1 -2
  54. package/cjs/custom/number.js.map +1 -1
  55. package/cjs/custom/poptip-animate.js +2 -1
  56. package/cjs/custom/poptip-animate.js.map +1 -1
  57. package/cjs/custom/register.js +21 -2
  58. package/cjs/custom/register.js.map +1 -1
  59. package/cjs/custom/richtext/input-richtext.d.ts +33 -0
  60. package/cjs/custom/richtext/input-richtext.js +70 -0
  61. package/cjs/custom/richtext/input-richtext.js.map +1 -0
  62. package/cjs/custom/richtext/output-richtext.d.ts +37 -0
  63. package/cjs/custom/richtext/output-richtext.js +94 -0
  64. package/cjs/custom/richtext/output-richtext.js.map +1 -0
  65. package/cjs/custom/richtext/slide-out-richtext.d.ts +38 -0
  66. package/cjs/custom/richtext/slide-out-richtext.js +146 -0
  67. package/cjs/custom/richtext/slide-out-richtext.js.map +1 -0
  68. package/cjs/custom/richtext/slide-richtext.d.ts +36 -0
  69. package/cjs/custom/richtext/slide-richtext.js +144 -0
  70. package/cjs/custom/richtext/slide-richtext.js.map +1 -0
  71. package/cjs/custom/rotate.d.ts +33 -0
  72. package/cjs/custom/rotate.js +76 -0
  73. package/cjs/custom/rotate.js.map +1 -0
  74. package/cjs/custom/scale.d.ts +2 -2
  75. package/cjs/custom/scale.js +25 -21
  76. package/cjs/custom/scale.js.map +1 -1
  77. package/cjs/custom/sphere.js +1 -2
  78. package/cjs/custom/state.d.ts +1 -1
  79. package/cjs/custom/state.js.map +1 -1
  80. package/cjs/custom/story.d.ts +128 -0
  81. package/cjs/custom/story.js +347 -0
  82. package/cjs/custom/story.js.map +1 -0
  83. package/cjs/custom/tag-points.d.ts +2 -3
  84. package/cjs/custom/tag-points.js +18 -5
  85. package/cjs/custom/tag-points.js.map +1 -1
  86. package/cjs/custom/update.d.ts +2 -1
  87. package/cjs/custom/update.js +10 -2
  88. package/cjs/custom/update.js.map +1 -1
  89. package/cjs/executor/animate-executor.d.ts +6 -5
  90. package/cjs/executor/animate-executor.js +57 -29
  91. package/cjs/executor/animate-executor.js.map +1 -1
  92. package/cjs/executor/executor.d.ts +6 -3
  93. package/cjs/executor/executor.js.map +1 -1
  94. package/cjs/index.d.ts +3 -6
  95. package/cjs/index.js +16 -4
  96. package/cjs/index.js.map +1 -1
  97. package/cjs/interpolate/store.d.ts +2 -2
  98. package/cjs/interpolate/store.js +2 -0
  99. package/cjs/interpolate/store.js.map +1 -1
  100. package/cjs/state/animation-state.d.ts +2 -2
  101. package/cjs/state/animation-state.js +3 -3
  102. package/cjs/state/animation-state.js.map +1 -1
  103. package/cjs/state/graphic-extension.d.ts +1 -1
  104. package/cjs/state/graphic-extension.js.map +1 -1
  105. package/cjs/step.d.ts +2 -4
  106. package/cjs/step.js +1 -1
  107. package/cjs/step.js.map +1 -1
  108. package/cjs/ticker/default-ticker.d.ts +2 -3
  109. package/cjs/ticker/default-ticker.js +14 -12
  110. package/cjs/ticker/default-ticker.js.map +1 -1
  111. package/cjs/ticker/manual-ticker.d.ts +1 -1
  112. package/cjs/ticker/manual-ticker.js.map +1 -1
  113. package/cjs/timeline.d.ts +1 -2
  114. package/cjs/timeline.js.map +1 -1
  115. package/cjs/utils/easing-func.js +2 -1
  116. package/dist/index.es.js +1859 -554
  117. package/es/animate-extension.d.ts +1 -3
  118. package/es/animate-extension.js +0 -7
  119. package/es/animate-extension.js.map +1 -1
  120. package/es/animate.d.ts +1 -5
  121. package/es/animate.js +1 -3
  122. package/es/animate.js.map +1 -1
  123. package/es/component/component-animator.d.ts +3 -2
  124. package/es/component/component-animator.js +18 -32
  125. package/es/component/component-animator.js.map +1 -1
  126. package/es/custom/clip-graphic.d.ts +1 -1
  127. package/es/custom/clip-graphic.js.map +1 -1
  128. package/es/custom/clip.d.ts +1 -1
  129. package/es/custom/clip.js.map +1 -1
  130. package/es/custom/common.d.ts +1 -2
  131. package/es/custom/common.js +12 -10
  132. package/es/custom/common.js.map +1 -1
  133. package/es/custom/custom-animate.d.ts +2 -4
  134. package/es/custom/custom-animate.js +2 -2
  135. package/es/custom/custom-animate.js.map +1 -1
  136. package/es/custom/fade.d.ts +1 -1
  137. package/es/custom/fade.js.map +1 -1
  138. package/es/custom/from-to.d.ts +9 -0
  139. package/es/custom/from-to.js +30 -0
  140. package/es/custom/from-to.js.map +1 -0
  141. package/es/custom/group-fade.d.ts +8 -14
  142. package/es/custom/group-fade.js +9 -50
  143. package/es/custom/group-fade.js.map +1 -1
  144. package/es/custom/growAngle.d.ts +2 -2
  145. package/es/custom/growAngle.js +20 -12
  146. package/es/custom/growAngle.js.map +1 -1
  147. package/es/custom/growCenter.d.ts +1 -2
  148. package/es/custom/growCenter.js +8 -7
  149. package/es/custom/growCenter.js.map +1 -1
  150. package/es/custom/growHeight.d.ts +1 -3
  151. package/es/custom/growHeight.js +8 -8
  152. package/es/custom/growHeight.js.map +1 -1
  153. package/es/custom/growPoints.d.ts +1 -2
  154. package/es/custom/growPoints.js +19 -17
  155. package/es/custom/growPoints.js.map +1 -1
  156. package/es/custom/growRadius.d.ts +4 -5
  157. package/es/custom/growRadius.js +12 -10
  158. package/es/custom/growRadius.js.map +1 -1
  159. package/es/custom/growWidth.d.ts +1 -3
  160. package/es/custom/growWidth.js +8 -7
  161. package/es/custom/growWidth.js.map +1 -1
  162. package/es/custom/input-text.d.ts +1 -2
  163. package/es/custom/input-text.js.map +1 -1
  164. package/es/custom/label-item-animate.js +2 -2
  165. package/es/custom/label-item-animate.js.map +1 -1
  166. package/es/custom/move.d.ts +92 -0
  167. package/es/custom/move.js +116 -0
  168. package/es/custom/move.js.map +1 -0
  169. package/es/custom/number.d.ts +1 -2
  170. package/es/custom/number.js.map +1 -1
  171. package/es/custom/poptip-animate.js +2 -1
  172. package/es/custom/poptip-animate.js.map +1 -1
  173. package/es/custom/register.js +41 -16
  174. package/es/custom/register.js.map +1 -1
  175. package/es/custom/richtext/input-richtext.d.ts +33 -0
  176. package/es/custom/richtext/input-richtext.js +64 -0
  177. package/es/custom/richtext/input-richtext.js.map +1 -0
  178. package/es/custom/richtext/output-richtext.d.ts +37 -0
  179. package/es/custom/richtext/output-richtext.js +88 -0
  180. package/es/custom/richtext/output-richtext.js.map +1 -0
  181. package/es/custom/richtext/slide-out-richtext.d.ts +38 -0
  182. package/es/custom/richtext/slide-out-richtext.js +140 -0
  183. package/es/custom/richtext/slide-out-richtext.js.map +1 -0
  184. package/es/custom/richtext/slide-richtext.d.ts +36 -0
  185. package/es/custom/richtext/slide-richtext.js +138 -0
  186. package/es/custom/richtext/slide-richtext.js.map +1 -0
  187. package/es/custom/rotate.d.ts +33 -0
  188. package/es/custom/rotate.js +62 -0
  189. package/es/custom/rotate.js.map +1 -0
  190. package/es/custom/scale.d.ts +2 -2
  191. package/es/custom/scale.js +25 -21
  192. package/es/custom/scale.js.map +1 -1
  193. package/es/custom/sphere.js +1 -2
  194. package/es/custom/state.d.ts +1 -1
  195. package/es/custom/state.js.map +1 -1
  196. package/es/custom/story.d.ts +128 -0
  197. package/es/custom/story.js +323 -0
  198. package/es/custom/story.js.map +1 -0
  199. package/es/custom/tag-points.d.ts +2 -3
  200. package/es/custom/tag-points.js +19 -6
  201. package/es/custom/tag-points.js.map +1 -1
  202. package/es/custom/update.d.ts +2 -1
  203. package/es/custom/update.js +10 -2
  204. package/es/custom/update.js.map +1 -1
  205. package/es/executor/animate-executor.d.ts +6 -5
  206. package/es/executor/animate-executor.js +55 -29
  207. package/es/executor/animate-executor.js.map +1 -1
  208. package/es/executor/executor.d.ts +6 -3
  209. package/es/executor/executor.js.map +1 -1
  210. package/es/index.d.ts +3 -6
  211. package/es/index.js +4 -10
  212. package/es/index.js.map +1 -1
  213. package/es/interpolate/store.d.ts +2 -2
  214. package/es/interpolate/store.js +2 -0
  215. package/es/interpolate/store.js.map +1 -1
  216. package/es/state/animation-state.d.ts +2 -2
  217. package/es/state/animation-state.js +4 -2
  218. package/es/state/animation-state.js.map +1 -1
  219. package/es/state/graphic-extension.d.ts +1 -1
  220. package/es/state/graphic-extension.js.map +1 -1
  221. package/es/step.d.ts +2 -4
  222. package/es/step.js +2 -2
  223. package/es/step.js.map +1 -1
  224. package/es/ticker/default-ticker.d.ts +2 -3
  225. package/es/ticker/default-ticker.js +5 -5
  226. package/es/ticker/default-ticker.js.map +1 -1
  227. package/es/ticker/manual-ticker.d.ts +1 -1
  228. package/es/ticker/manual-ticker.js.map +1 -1
  229. package/es/timeline.d.ts +1 -2
  230. package/es/timeline.js +1 -1
  231. package/es/timeline.js.map +1 -1
  232. package/es/utils/easing-func.js +2 -1
  233. package/package.json +5 -5
  234. package/cjs/custom/label-animate.d.ts +0 -4
  235. package/cjs/custom/label-animate.js +0 -48
  236. package/cjs/custom/label-animate.js.map +0 -1
  237. package/cjs/intreface/animate.d.ts +0 -92
  238. package/cjs/intreface/animate.js +0 -10
  239. package/cjs/intreface/animate.js.map +0 -1
  240. package/cjs/intreface/easing.d.ts +0 -3
  241. package/cjs/intreface/easing.js +0 -6
  242. package/cjs/intreface/easing.js.map +0 -1
  243. package/cjs/intreface/ticker.d.ts +0 -37
  244. package/cjs/intreface/ticker.js +0 -11
  245. package/cjs/intreface/ticker.js.map +0 -1
  246. package/cjs/intreface/timeline.d.ts +0 -17
  247. package/cjs/intreface/timeline.js +0 -6
  248. package/cjs/intreface/timeline.js.map +0 -1
  249. package/cjs/intreface/type.d.ts +0 -13
  250. package/cjs/intreface/type.js +0 -15
  251. package/cjs/intreface/type.js.map +0 -1
  252. package/es/custom/label-animate.d.ts +0 -4
  253. package/es/custom/label-animate.js +0 -42
  254. package/es/custom/label-animate.js.map +0 -1
  255. package/es/intreface/animate.d.ts +0 -92
  256. package/es/intreface/animate.js +0 -6
  257. package/es/intreface/animate.js.map +0 -1
  258. package/es/intreface/easing.d.ts +0 -3
  259. package/es/intreface/easing.js +0 -2
  260. package/es/intreface/easing.js.map +0 -1
  261. package/es/intreface/ticker.d.ts +0 -37
  262. package/es/intreface/ticker.js +0 -7
  263. package/es/intreface/ticker.js.map +0 -1
  264. package/es/intreface/timeline.d.ts +0 -17
  265. package/es/intreface/timeline.js +0 -2
  266. package/es/intreface/timeline.js.map +0 -1
  267. package/es/intreface/type.d.ts +0 -13
  268. package/es/intreface/type.js +0 -14
  269. package/es/intreface/type.js.map +0 -1
@@ -0,0 +1,92 @@
1
+ import type { EasingType, IGraphic, IGroup } from '@visactor/vrender-core';
2
+ import { ACustomAnimate } from './custom-animate';
3
+ export type FunctionCallback<T> = (...args: any[]) => T;
4
+ export interface IMoveAnimationOptions {
5
+ direction?: 'x' | 'y' | 'xy';
6
+ orient?: 'positive' | 'negative';
7
+ offset?: number;
8
+ point?: {
9
+ x?: number;
10
+ y?: number;
11
+ } | FunctionCallback<{
12
+ x?: number;
13
+ y?: number;
14
+ }>;
15
+ excludeChannels?: string[];
16
+ }
17
+ interface IAnimationParameters {
18
+ width: number;
19
+ height: number;
20
+ group: IGroup;
21
+ elementIndex: number;
22
+ elementCount: number;
23
+ view: any;
24
+ }
25
+ export declare const moveIn: (graphic: IGraphic, options: IMoveAnimationOptions, animationParameters: IAnimationParameters) => {
26
+ from: {
27
+ x: any;
28
+ y?: undefined;
29
+ };
30
+ to: {
31
+ x: any;
32
+ y?: undefined;
33
+ };
34
+ } | {
35
+ from: {
36
+ y: any;
37
+ x?: undefined;
38
+ };
39
+ to: {
40
+ y: any;
41
+ x?: undefined;
42
+ };
43
+ } | {
44
+ from: {
45
+ x: any;
46
+ y: any;
47
+ };
48
+ to: {
49
+ x: any;
50
+ y: any;
51
+ };
52
+ };
53
+ export declare const moveOut: (graphic: IGraphic, options: IMoveAnimationOptions, animationParameters: IAnimationParameters) => {
54
+ from: {
55
+ x: number;
56
+ y?: undefined;
57
+ };
58
+ to: {
59
+ x: any;
60
+ y?: undefined;
61
+ };
62
+ } | {
63
+ from: {
64
+ y: number;
65
+ x?: undefined;
66
+ };
67
+ to: {
68
+ y: any;
69
+ x?: undefined;
70
+ };
71
+ } | {
72
+ from: {
73
+ x: number;
74
+ y: number;
75
+ };
76
+ to: {
77
+ x: any;
78
+ y: any;
79
+ };
80
+ };
81
+ export declare class MoveBase extends ACustomAnimate<Record<string, number>> {
82
+ valid: boolean;
83
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: any);
84
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
85
+ }
86
+ export declare class MoveIn extends MoveBase {
87
+ onBind(): void;
88
+ }
89
+ export declare class MoveOut extends MoveBase {
90
+ onBind(): void;
91
+ }
92
+ export {};
@@ -0,0 +1,116 @@
1
+ import { isFunction, isValidNumber } from "@visactor/vutils";
2
+
3
+ import { ACustomAnimate } from "./custom-animate";
4
+
5
+ export const moveIn = (graphic, options, animationParameters) => {
6
+ var _a, _b;
7
+ const {offset: offset = 0, orient: orient, direction: direction, point: pointOpt, excludeChannels: excludeChannels = []} = null != options ? options : {};
8
+ let changedX = 0, changedY = 0;
9
+ "negative" === orient && (animationParameters.group ? (changedX = null !== (_a = animationParameters.groupWidth) && void 0 !== _a ? _a : animationParameters.group.getBounds().width(),
10
+ changedY = null !== (_b = animationParameters.groupHeight) && void 0 !== _b ? _b : animationParameters.group.getBounds().height(),
11
+ animationParameters.groupWidth = changedX, animationParameters.groupHeight = changedY) : (changedX = animationParameters.width,
12
+ changedY = animationParameters.height)), changedX += offset, changedY += offset;
13
+ const point = isFunction(pointOpt) ? pointOpt.call(null, graphic.getDatum(), graphic, animationParameters) : pointOpt, fromX = point && isValidNumber(point.x) ? point.x : changedX, fromY = point && isValidNumber(point.y) ? point.y : changedY, finalAttrs = graphic.getFinalAttribute(), finalAttrsX = excludeChannels.includes("x") ? graphic.attribute.x : finalAttrs.x, finalAttrsY = excludeChannels.includes("y") ? graphic.attribute.y : finalAttrs.y;
14
+ switch (direction) {
15
+ case "x":
16
+ return {
17
+ from: {
18
+ x: fromX
19
+ },
20
+ to: {
21
+ x: finalAttrsX
22
+ }
23
+ };
24
+
25
+ case "y":
26
+ return {
27
+ from: {
28
+ y: fromY
29
+ },
30
+ to: {
31
+ y: finalAttrsY
32
+ }
33
+ };
34
+
35
+ default:
36
+ return {
37
+ from: {
38
+ x: fromX,
39
+ y: fromY
40
+ },
41
+ to: {
42
+ x: finalAttrsX,
43
+ y: finalAttrsY
44
+ }
45
+ };
46
+ }
47
+ };
48
+
49
+ export const moveOut = (graphic, options, animationParameters) => {
50
+ var _a, _b;
51
+ const {offset: offset = 0, orient: orient, direction: direction, point: pointOpt} = null != options ? options : {}, groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null, groupWidth = null !== (_a = null == groupBounds ? void 0 : groupBounds.width()) && void 0 !== _a ? _a : animationParameters.width, groupHeight = null !== (_b = null == groupBounds ? void 0 : groupBounds.height()) && void 0 !== _b ? _b : animationParameters.height, changedX = ("negative" === orient ? groupWidth : 0) + offset, changedY = ("negative" === orient ? groupHeight : 0) + offset, point = isFunction(pointOpt) ? pointOpt.call(null, graphic.getDatum(), graphic, animationParameters) : pointOpt, fromX = point && isValidNumber(point.x) ? point.x : changedX, fromY = point && isValidNumber(point.y) ? point.y : changedY;
52
+ switch (direction) {
53
+ case "x":
54
+ return {
55
+ from: {
56
+ x: graphic.attribute.x
57
+ },
58
+ to: {
59
+ x: fromX
60
+ }
61
+ };
62
+
63
+ case "y":
64
+ return {
65
+ from: {
66
+ y: graphic.attribute.y
67
+ },
68
+ to: {
69
+ y: fromY
70
+ }
71
+ };
72
+
73
+ default:
74
+ return {
75
+ from: {
76
+ x: graphic.attribute.x,
77
+ y: graphic.attribute.y
78
+ },
79
+ to: {
80
+ x: fromX,
81
+ y: fromY
82
+ }
83
+ };
84
+ }
85
+ };
86
+
87
+ export class MoveBase extends ACustomAnimate {
88
+ constructor(from, to, duration, easing, params) {
89
+ super(from, to, duration, easing, params);
90
+ }
91
+ onUpdate(end, ratio, out) {
92
+ const attribute = this.target.attribute;
93
+ this.propKeys.forEach((key => {
94
+ attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
95
+ })), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
96
+ }
97
+ }
98
+
99
+ export class MoveIn extends MoveBase {
100
+ onBind() {
101
+ const {from: from, to: to} = moveIn(this.target, this.params.options, this.params);
102
+ this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
103
+ this.from = from, this.to = to;
104
+ const finalAttribute = this.target.getFinalAttribute();
105
+ finalAttribute && Object.assign(this.target.attribute, finalAttribute), this.target.setAttributes(from);
106
+ }
107
+ }
108
+
109
+ export class MoveOut extends MoveBase {
110
+ onBind() {
111
+ const {from: from, to: to} = moveOut(this.target, this.params.options, this.params);
112
+ this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
113
+ this.from = from, this.to = to;
114
+ }
115
+ }
116
+ //# sourceMappingURL=move.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/custom/move.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAwBlD,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,OAAiB,EACjB,OAA8B,EAC9B,mBAAyC,EACzC,EAAE;;IACF,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EA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C,CAAC;QAC3E,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAE,EAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QAGb,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QACvD,IAAI,cAAc,EAAE;YAClB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;SACtD;QACD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAED,MAAM,OAAO,OAAQ,SAAQ,QAAQ;IACnC,MAAM;QACJ,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5E,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAE,EAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;CACF","file":"move.js","sourcesContent":["import type { EasingType, IGraphic, IGroup } from '@visactor/vrender-core';\nimport { isFunction, isValidNumber } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\nexport type FunctionCallback<T> = (...args: any[]) => T;\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n excludeChannels?: string[];\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [] } = options ?? {};\n let changedX = 0;\n let changedY = 0;\n\n if (orient === 'negative') {\n // consider the offset of group\n if (animationParameters.group) {\n changedX = (animationParameters as any).groupWidth ?? animationParameters.group.getBounds().width();\n changedY = (animationParameters as any).groupHeight ?? animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupWidth = changedX;\n (animationParameters as any).groupHeight = changedY;\n } else {\n changedX = animationParameters.width;\n changedY = animationParameters.height;\n }\n }\n\n changedX += offset;\n changedY += offset;\n const point = isFunction(pointOpt) ? pointOpt.call(null, graphic.getDatum(), graphic, animationParameters) : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n const finalAttrs = graphic.getFinalAttribute();\n const finalAttrsX = excludeChannels.includes('x') ? graphic.attribute.x : finalAttrs.x;\n const finalAttrsY = excludeChannels.includes('y') ? graphic.attribute.y : finalAttrs.y;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: fromX },\n to: { x: finalAttrsX }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: finalAttrsY }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: finalAttrsX,\n y: finalAttrsY\n }\n };\n }\n};\n\nexport const moveOut = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt } = options ?? {};\n\n // consider the offset of group\n const groupBounds = animationParameters.group ? animationParameters.group.getBounds() : null;\n const groupWidth = groupBounds?.width() ?? animationParameters.width;\n const groupHeight = groupBounds?.height() ?? animationParameters.height;\n const changedX = (orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(pointOpt) ? pointOpt.call(null, graphic.getDatum(), graphic, animationParameters) : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: graphic.attribute.x },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: graphic.attribute.y },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: graphic.attribute.x,\n y: graphic.attribute.y\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n\nexport class MoveBase 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 const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\n/**\n * 增长渐入\n */\nexport class MoveIn extends MoveBase {\n onBind(): void {\n const { from, to } = moveIn(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n Object.assign(this.target.attribute, finalAttribute);\n }\n this.target.setAttributes(from);\n }\n}\n\nexport class MoveOut extends MoveBase {\n onBind(): void {\n const { from, to } = moveOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n }\n}\n"]}
@@ -1,5 +1,4 @@
1
- import type { IAnimate, IStep } from '../intreface/animate';
2
- import type { EasingType } from '../intreface/easing';
1
+ import type { EasingType, IAnimate, IStep } from '@visactor/vrender-core';
3
2
  import { ACustomAnimate } from './custom-animate';
4
3
  export declare class IncreaseCount extends ACustomAnimate<{
5
4
  text: string | number;
@@ -1 +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,QAAQ,GAAG,MAAA,SAAS,CAAC,IAAI,mCAAI,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,CAAC,CAAC;QAGjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,OAAO,GAAG,CAAC,CA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ACF","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"]}
1
+ {"version":3,"sources":["../src/custom/number.ts"],"names":[],"mappings":"AACA,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,QAAQ,GAAG,MAAA,SAAS,CAAC,IAAI,mCAAI,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,MAAA,OAAO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,wBAAwB,CAAC;SAC1C;QAGD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAClD,CAAC;CACF","file":"number.js","sourcesContent":["import type { EasingType, IAnimate, IStep } from '@visactor/vrender-core';\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"]}
@@ -78,6 +78,7 @@ export class PoptipAppear extends AComponentAnimate {
78
78
  } ]
79
79
  });
80
80
  }
81
+ this.completeBind(animator);
81
82
  }
82
83
  }
83
84
 
@@ -94,7 +95,7 @@ export class PoptipDisappear extends AComponentAnimate {
94
95
  },
95
96
  duration: duration,
96
97
  easing: easing
97
- });
98
+ }), this.completeBind(animator);
98
99
  }
99
100
  }
100
101
  //# sourceMappingURL=poptip-animate.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/custom/poptip-animate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAKzC,MAAM,OAAO,YAAa,SAAQ,iBAAsB;IACtD,MAAM;QACJ,MAAM,QAAQ,GAAG,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,MAAM,GAAG,IAAI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E,IAAI,EAAE;4BACnB,MAAM;yBACP;qBACF;oBACD;wBACE,QAAQ,EAAE,GAAG,GAAG,CAAC;wBACjB,OAAO,EAAE;4BACP,IAAI,EAAE,IAAI;4BACV,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE;4BACpB,MAAM;yBACP;qBACF;oBACD;wBACE,QAAQ,EAAE,GAAG,GAAG,CAAC;wBACjB,OAAO,EAAE;4BACP,IAAI,EAAE,IAAI;4BACV,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;4BACnB,MAAM;yBACP;qBACF;oBACD;wBACE,QAAQ,EAAE,GAAG;wBACb,OAAO,EAAE;4BACP,IAAI,EAAE,IAAI;4BACV,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;4BAChB,MAAM;yBACP;qBACF;iBACF;aACF,CAAC,CAAC;SACJ;IACH,CAAC;CACF;AAKD,MAAM,OAAO,eAAgB,SAAQ,iBAAsB;IACzD,MAAM;QACJ,MAAM,QAAQ,GAAG,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAa,CAAC;QAElC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE;YACvB,IAAI,EAAE,IAAI;YACV,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;YAC5B,QAAQ;YACR,MAAM;SACP,CAAC,CAAC;IACL,CAAC;CACF","file":"poptip-animate.js","sourcesContent":["import { AComponentAnimate } from './custom-animate';\nimport { createComponentAnimator } from '../component';\nimport { InputText } from './input-text';\n\n/**\n * PoptipAppear class handles the appear animation for Poptip components\n */\nexport class PoptipAppear extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n\n const duration = this.duration;\n const easing = this.easing;\n const target = this.target as any;\n\n const { wave } = this.params;\n\n target.setAttributes({ scaleX: 0, scaleY: 0 });\n\n animator.animate(target, {\n type: 'to',\n to: { scaleX: 1, scaleY: 1 },\n duration: (duration / 3) * 2,\n easing\n });\n\n target.titleShape &&\n animator.animate(target.titleShape, {\n type: 'custom',\n to: { text: target.titleShape.attribute.text as string },\n duration,\n easing,\n custom: InputText\n });\n\n target.contentShape &&\n animator.animate(target.contentShape, {\n type: 'custom',\n to: { text: target.contentShape.attribute.text as string },\n duration,\n easing,\n custom: InputText\n });\n\n if (wave) {\n const dur = duration / 6;\n animator.animate(target.group, {\n timeSlices: [\n {\n duration: dur,\n effects: {\n type: 'to',\n to: { angle: wave },\n easing\n }\n },\n {\n duration: dur * 2,\n effects: {\n type: 'to',\n to: { angle: -wave },\n easing\n }\n },\n {\n duration: dur * 2,\n effects: {\n type: 'to',\n to: { angle: wave },\n easing\n }\n },\n {\n duration: dur,\n effects: {\n type: 'to',\n to: { angle: 0 },\n easing\n }\n }\n ]\n });\n }\n }\n}\n\n/**\n * PoptipDisappear class handles the disappear animation for Poptip components\n */\nexport class PoptipDisappear extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n\n const duration = this.duration;\n const easing = this.easing;\n const target = this.target as any;\n\n animator.animate(target, {\n type: 'to',\n to: { scaleX: 0, scaleY: 0 },\n duration,\n easing\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/custom/poptip-animate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAKzC,MAAM,OAAO,YAAa,SAAQ,iBAAsB;IACtD,MAAM;QACJ,MAAM,QAAQ,G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AAE;YAC5B,QAAQ;YACR,MAAM;SACP,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;CACF","file":"poptip-animate.js","sourcesContent":["import { AComponentAnimate } from './custom-animate';\nimport { createComponentAnimator } from '../component';\nimport { InputText } from './input-text';\n\n/**\n * PoptipAppear class handles the appear animation for Poptip components\n */\nexport class PoptipAppear extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n\n const duration = this.duration;\n const easing = this.easing;\n const target = this.target as any;\n\n const { wave } = this.params;\n\n target.setAttributes({ scaleX: 0, scaleY: 0 });\n\n animator.animate(target, {\n type: 'to',\n to: { scaleX: 1, scaleY: 1 },\n duration: (duration / 3) * 2,\n easing\n });\n\n target.titleShape &&\n animator.animate(target.titleShape, {\n type: 'custom',\n to: { text: target.titleShape.attribute.text as string },\n duration,\n easing,\n custom: InputText\n });\n\n target.contentShape &&\n animator.animate(target.contentShape, {\n type: 'custom',\n to: { text: target.contentShape.attribute.text as string },\n duration,\n easing,\n custom: InputText\n });\n\n if (wave) {\n const dur = duration / 6;\n animator.animate(target.group, {\n timeSlices: [\n {\n duration: dur,\n effects: {\n type: 'to',\n to: { angle: wave },\n easing\n }\n },\n {\n duration: dur * 2,\n effects: {\n type: 'to',\n to: { angle: -wave },\n easing\n }\n },\n {\n duration: dur * 2,\n effects: {\n type: 'to',\n to: { angle: wave },\n easing\n }\n },\n {\n duration: dur,\n effects: {\n type: 'to',\n to: { angle: 0 },\n easing\n }\n }\n ]\n });\n }\n\n this.completeBind(animator);\n }\n}\n\n/**\n * PoptipDisappear class handles the disappear animation for Poptip components\n */\nexport class PoptipDisappear extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n\n const duration = this.duration;\n const easing = this.easing;\n const target = this.target as any;\n\n animator.animate(target, {\n type: 'to',\n to: { scaleX: 0, scaleY: 0 },\n duration,\n easing\n });\n\n this.completeBind(animator);\n }\n}\n"]}
@@ -16,7 +16,7 @@ import { GrowRadiusIn, GrowRadiusOut } from "./growRadius";
16
16
 
17
17
  import { GrowWidthIn, GrowWidthOut } from "./growWidth";
18
18
 
19
- import { LabelUpdate } from "./label-animate";
19
+ import { InputText } from "./input-text";
20
20
 
21
21
  import { LabelItemAppear, LabelItemDisappear } from "./label-item-animate";
22
22
 
@@ -24,28 +24,53 @@ import { IncreaseCount } from "./number";
24
24
 
25
25
  import { PoptipAppear, PoptipDisappear } from "./poptip-animate";
26
26
 
27
+ import { InputRichText } from "./richtext/input-richtext";
28
+
29
+ import { OutputRichText } from "./richtext/output-richtext";
30
+
31
+ import { SlideRichText } from "./richtext/slide-richtext";
32
+
33
+ import { SlideOutRichText } from "./richtext/slide-out-richtext";
34
+
27
35
  import { ScaleIn, ScaleOut } from "./scale";
28
36
 
29
37
  import { State } from "./state";
30
38
 
39
+ import { GrowIn, GrowOut, MoveRotateIn, MoveRotateOut, MoveScaleIn, MoveScaleOut, SlideIn, SlideOut, SpinIn, SpinOut } from "./story";
40
+
31
41
  import { Update } from "./update";
32
42
 
43
+ import { MoveIn, MoveOut } from "./move";
44
+
45
+ import { RotateIn, RotateOut } from "./rotate";
46
+
47
+ import { FromTo } from "./from-to";
48
+
33
49
  export const registerCustomAnimate = () => {
34
- AnimateExecutor.registerBuiltInAnimate("increaseCount", IncreaseCount), AnimateExecutor.registerBuiltInAnimate("scaleIn", ScaleIn),
35
- AnimateExecutor.registerBuiltInAnimate("scaleOut", ScaleOut), AnimateExecutor.registerBuiltInAnimate("growHeightIn", GrowHeightIn),
36
- AnimateExecutor.registerBuiltInAnimate("growHeightOut", GrowHeightOut), AnimateExecutor.registerBuiltInAnimate("growWidthIn", GrowWidthIn),
37
- AnimateExecutor.registerBuiltInAnimate("growWidthOut", GrowWidthOut), AnimateExecutor.registerBuiltInAnimate("growCenterIn", GrowCenterIn),
38
- AnimateExecutor.registerBuiltInAnimate("growCenterOut", GrowCenterOut), AnimateExecutor.registerBuiltInAnimate("clipIn", ClipIn),
39
- AnimateExecutor.registerBuiltInAnimate("clipOut", ClipOut), AnimateExecutor.registerBuiltInAnimate("fadeIn", FadeIn),
40
- AnimateExecutor.registerBuiltInAnimate("fadeOut", FadeOut), AnimateExecutor.registerBuiltInAnimate("growPointsIn", GrowPointsIn),
41
- AnimateExecutor.registerBuiltInAnimate("growPointsOut", GrowPointsOut), AnimateExecutor.registerBuiltInAnimate("growPointsXIn", GrowPointsXIn),
42
- AnimateExecutor.registerBuiltInAnimate("growPointsXOut", GrowPointsXOut), AnimateExecutor.registerBuiltInAnimate("growPointsYIn", GrowPointsYIn),
43
- AnimateExecutor.registerBuiltInAnimate("growPointsYOut", GrowPointsYOut), AnimateExecutor.registerBuiltInAnimate("growAngleIn", GrowAngleIn),
44
- AnimateExecutor.registerBuiltInAnimate("growAngleOut", GrowAngleOut), AnimateExecutor.registerBuiltInAnimate("growRadiusIn", GrowRadiusIn),
45
- AnimateExecutor.registerBuiltInAnimate("growRadiusOut", GrowRadiusOut), AnimateExecutor.registerBuiltInAnimate("update", Update),
46
- AnimateExecutor.registerBuiltInAnimate("state", State), AnimateExecutor.registerBuiltInAnimate("labelItemAppear", LabelItemAppear),
47
- AnimateExecutor.registerBuiltInAnimate("labelItemDisappear", LabelItemDisappear),
50
+ AnimateExecutor.registerBuiltInAnimate("increaseCount", IncreaseCount), AnimateExecutor.registerBuiltInAnimate("fromTo", FromTo),
51
+ AnimateExecutor.registerBuiltInAnimate("scaleIn", ScaleIn), AnimateExecutor.registerBuiltInAnimate("scaleOut", ScaleOut),
52
+ AnimateExecutor.registerBuiltInAnimate("growHeightIn", GrowHeightIn), AnimateExecutor.registerBuiltInAnimate("growHeightOut", GrowHeightOut),
53
+ AnimateExecutor.registerBuiltInAnimate("growWidthIn", GrowWidthIn), AnimateExecutor.registerBuiltInAnimate("growWidthOut", GrowWidthOut),
54
+ AnimateExecutor.registerBuiltInAnimate("growCenterIn", GrowCenterIn), AnimateExecutor.registerBuiltInAnimate("growCenterOut", GrowCenterOut),
55
+ AnimateExecutor.registerBuiltInAnimate("clipIn", ClipIn), AnimateExecutor.registerBuiltInAnimate("clipOut", ClipOut),
56
+ AnimateExecutor.registerBuiltInAnimate("fadeIn", FadeIn), AnimateExecutor.registerBuiltInAnimate("fadeOut", FadeOut),
57
+ AnimateExecutor.registerBuiltInAnimate("growPointsIn", GrowPointsIn), AnimateExecutor.registerBuiltInAnimate("growPointsOut", GrowPointsOut),
58
+ AnimateExecutor.registerBuiltInAnimate("growPointsXIn", GrowPointsXIn), AnimateExecutor.registerBuiltInAnimate("growPointsXOut", GrowPointsXOut),
59
+ AnimateExecutor.registerBuiltInAnimate("growPointsYIn", GrowPointsYIn), AnimateExecutor.registerBuiltInAnimate("growPointsYOut", GrowPointsYOut),
60
+ AnimateExecutor.registerBuiltInAnimate("growAngleIn", GrowAngleIn), AnimateExecutor.registerBuiltInAnimate("growAngleOut", GrowAngleOut),
61
+ AnimateExecutor.registerBuiltInAnimate("growRadiusIn", GrowRadiusIn), AnimateExecutor.registerBuiltInAnimate("growRadiusOut", GrowRadiusOut),
62
+ AnimateExecutor.registerBuiltInAnimate("moveIn", MoveIn), AnimateExecutor.registerBuiltInAnimate("moveOut", MoveOut),
63
+ AnimateExecutor.registerBuiltInAnimate("rotateIn", RotateIn), AnimateExecutor.registerBuiltInAnimate("rotateOut", RotateOut),
64
+ AnimateExecutor.registerBuiltInAnimate("update", Update), AnimateExecutor.registerBuiltInAnimate("state", State),
65
+ AnimateExecutor.registerBuiltInAnimate("labelItemAppear", LabelItemAppear), AnimateExecutor.registerBuiltInAnimate("labelItemDisappear", LabelItemDisappear),
48
66
  AnimateExecutor.registerBuiltInAnimate("poptipAppear", PoptipAppear), AnimateExecutor.registerBuiltInAnimate("poptipDisappear", PoptipDisappear),
49
- AnimateExecutor.registerBuiltInAnimate("labelUpdate", LabelUpdate);
67
+ AnimateExecutor.registerBuiltInAnimate("inputText", InputText), AnimateExecutor.registerBuiltInAnimate("inputRichText", InputRichText),
68
+ AnimateExecutor.registerBuiltInAnimate("outputRichText", OutputRichText), AnimateExecutor.registerBuiltInAnimate("slideRichText", SlideRichText),
69
+ AnimateExecutor.registerBuiltInAnimate("slideOutRichText", SlideOutRichText), AnimateExecutor.registerBuiltInAnimate("slideIn", SlideIn),
70
+ AnimateExecutor.registerBuiltInAnimate("growIn", GrowIn), AnimateExecutor.registerBuiltInAnimate("spinIn", SpinIn),
71
+ AnimateExecutor.registerBuiltInAnimate("moveScaleIn", MoveScaleIn), AnimateExecutor.registerBuiltInAnimate("moveRotateIn", MoveRotateIn),
72
+ AnimateExecutor.registerBuiltInAnimate("slideOut", SlideOut), AnimateExecutor.registerBuiltInAnimate("growOut", GrowOut),
73
+ AnimateExecutor.registerBuiltInAnimate("spinOut", SpinOut), AnimateExecutor.registerBuiltInAnimate("moveScaleOut", MoveScaleOut),
74
+ AnimateExecutor.registerBuiltInAnimate("moveRotateOut", MoveRotateOut);
50
75
  };
51
76
  //# sourceMappingURL=register.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/custom/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC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executor';\nimport { ClipIn, ClipOut } from './clip';\nimport { FadeIn, FadeOut } from './fade';\nimport { GrowAngleIn, GrowAngleOut } from './growAngle';\nimport { GrowCenterIn, GrowCenterOut } from './growCenter';\nimport { GrowHeightIn, GrowHeightOut } from './growHeight';\nimport {\n GrowPointsIn,\n GrowPointsOut,\n GrowPointsXIn,\n GrowPointsXOut,\n GrowPointsYIn,\n GrowPointsYOut\n} from './growPoints';\nimport { GrowRadiusIn, GrowRadiusOut } from './growRadius';\nimport { GrowWidthIn, GrowWidthOut } from './growWidth';\nimport { LabelUpdate } from './label-animate';\nimport { LabelItemAppear, LabelItemDisappear } from './label-item-animate';\nimport { IncreaseCount } from './number';\nimport { PoptipAppear, PoptipDisappear } from './poptip-animate';\nimport { ScaleIn, ScaleOut } from './scale';\nimport { State } from './state';\nimport { Update } from './update';\n\nexport const registerCustomAnimate = () => {\n // 基础动画\n AnimateExecutor.registerBuiltInAnimate('increaseCount', IncreaseCount);\n\n AnimateExecutor.registerBuiltInAnimate('scaleIn', ScaleIn);\n AnimateExecutor.registerBuiltInAnimate('scaleOut', ScaleOut);\n AnimateExecutor.registerBuiltInAnimate('growHeightIn', GrowHeightIn);\n AnimateExecutor.registerBuiltInAnimate('growHeightOut', GrowHeightOut);\n AnimateExecutor.registerBuiltInAnimate('growWidthIn', GrowWidthIn);\n AnimateExecutor.registerBuiltInAnimate('growWidthOut', GrowWidthOut);\n AnimateExecutor.registerBuiltInAnimate('growCenterIn', GrowCenterIn);\n AnimateExecutor.registerBuiltInAnimate('growCenterOut', GrowCenterOut);\n AnimateExecutor.registerBuiltInAnimate('clipIn', ClipIn);\n AnimateExecutor.registerBuiltInAnimate('clipOut', ClipOut);\n AnimateExecutor.registerBuiltInAnimate('fadeIn', FadeIn);\n AnimateExecutor.registerBuiltInAnimate('fadeOut', FadeOut);\n AnimateExecutor.registerBuiltInAnimate('growPointsIn', GrowPointsIn);\n AnimateExecutor.registerBuiltInAnimate('growPointsOut', GrowPointsOut);\n AnimateExecutor.registerBuiltInAnimate('growPointsXIn', GrowPointsXIn);\n AnimateExecutor.registerBuiltInAnimate('growPointsXOut', GrowPointsXOut);\n AnimateExecutor.registerBuiltInAnimate('growPointsYIn', GrowPointsYIn);\n AnimateExecutor.registerBuiltInAnimate('growPointsYOut', GrowPointsYOut);\n AnimateExecutor.registerBuiltInAnimate('growAngleIn', GrowAngleIn);\n AnimateExecutor.registerBuiltInAnimate('growAngleOut', GrowAngleOut);\n AnimateExecutor.registerBuiltInAnimate('growRadiusIn', GrowRadiusIn);\n AnimateExecutor.registerBuiltInAnimate('growRadiusOut', GrowRadiusOut);\n // state和update共用一个自定义动画类\n AnimateExecutor.registerBuiltInAnimate('update', Update);\n AnimateExecutor.registerBuiltInAnimate('state', State);\n // Label item animations\n AnimateExecutor.registerBuiltInAnimate('labelItemAppear', LabelItemAppear);\n AnimateExecutor.registerBuiltInAnimate('labelItemDisappear', LabelItemDisappear);\n // Poptip animations\n AnimateExecutor.registerBuiltInAnimate('poptipAppear', PoptipAppear);\n AnimateExecutor.registerBuiltInAnimate('poptipDisappear', PoptipDisappear);\n // Label update animation\n AnimateExecutor.registerBuiltInAnimate('labelUpdate', LabelUpdate);\n};\n"]}
1
+ {"version":3,"sources":["../src/custom/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,cAAc,E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EAAE,MAAM,CAAC,CAAC;IACzD,eAAe,CAAC,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzD,eAAe,CAAC,sBAAsB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IACnE,eAAe,CAAC,sBAAsB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IAGrE,eAAe,CAAC,sBAAsB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC7D,eAAe,CAAC,sBAAsB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC3D,eAAe,CAAC,sBAAsB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC3D,eAAe,CAAC,sBAAsB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACrE,eAAe,CAAC,sBAAsB,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;AACzE,CAAC,CAAC","file":"register.js","sourcesContent":["import { AnimateExecutor } from '../executor/animate-executor';\nimport { ClipIn, ClipOut } from './clip';\nimport { FadeIn, FadeOut } from './fade';\nimport { GrowAngleIn, GrowAngleOut } from './growAngle';\nimport { GrowCenterIn, GrowCenterOut } from './growCenter';\nimport { GrowHeightIn, GrowHeightOut } from './growHeight';\nimport {\n GrowPointsIn,\n GrowPointsOut,\n GrowPointsXIn,\n GrowPointsXOut,\n GrowPointsYIn,\n GrowPointsYOut\n} from './growPoints';\nimport { GrowRadiusIn, GrowRadiusOut } from './growRadius';\nimport { GrowWidthIn, GrowWidthOut } from './growWidth';\nimport { InputText } from './input-text';\nimport { LabelItemAppear, LabelItemDisappear } from './label-item-animate';\nimport { IncreaseCount } from './number';\nimport { PoptipAppear, PoptipDisappear } from './poptip-animate';\nimport { InputRichText } from './richtext/input-richtext';\nimport { OutputRichText } from './richtext/output-richtext';\nimport { SlideRichText } from './richtext/slide-richtext';\nimport { SlideOutRichText } from './richtext/slide-out-richtext';\nimport { ScaleIn, ScaleOut } from './scale';\nimport { State } from './state';\nimport {\n GrowIn,\n GrowOut,\n MoveRotateIn,\n MoveRotateOut,\n MoveScaleIn,\n MoveScaleOut,\n SlideIn,\n SlideOut,\n SpinIn,\n SpinOut\n} from './story';\nimport { Update } from './update';\nimport { MoveIn, MoveOut } from './move';\nimport { RotateIn, RotateOut } from './rotate';\nimport { FromTo } from './from-to';\n\nexport const registerCustomAnimate = () => {\n // 基础动画\n AnimateExecutor.registerBuiltInAnimate('increaseCount', IncreaseCount);\n\n AnimateExecutor.registerBuiltInAnimate('fromTo', FromTo);\n AnimateExecutor.registerBuiltInAnimate('scaleIn', ScaleIn);\n AnimateExecutor.registerBuiltInAnimate('scaleOut', ScaleOut);\n AnimateExecutor.registerBuiltInAnimate('growHeightIn', GrowHeightIn);\n AnimateExecutor.registerBuiltInAnimate('growHeightOut', GrowHeightOut);\n AnimateExecutor.registerBuiltInAnimate('growWidthIn', GrowWidthIn);\n AnimateExecutor.registerBuiltInAnimate('growWidthOut', GrowWidthOut);\n AnimateExecutor.registerBuiltInAnimate('growCenterIn', GrowCenterIn);\n AnimateExecutor.registerBuiltInAnimate('growCenterOut', GrowCenterOut);\n AnimateExecutor.registerBuiltInAnimate('clipIn', ClipIn);\n AnimateExecutor.registerBuiltInAnimate('clipOut', ClipOut);\n AnimateExecutor.registerBuiltInAnimate('fadeIn', FadeIn);\n AnimateExecutor.registerBuiltInAnimate('fadeOut', FadeOut);\n AnimateExecutor.registerBuiltInAnimate('growPointsIn', GrowPointsIn);\n AnimateExecutor.registerBuiltInAnimate('growPointsOut', GrowPointsOut);\n AnimateExecutor.registerBuiltInAnimate('growPointsXIn', GrowPointsXIn);\n AnimateExecutor.registerBuiltInAnimate('growPointsXOut', GrowPointsXOut);\n AnimateExecutor.registerBuiltInAnimate('growPointsYIn', GrowPointsYIn);\n AnimateExecutor.registerBuiltInAnimate('growPointsYOut', GrowPointsYOut);\n AnimateExecutor.registerBuiltInAnimate('growAngleIn', GrowAngleIn);\n AnimateExecutor.registerBuiltInAnimate('growAngleOut', GrowAngleOut);\n AnimateExecutor.registerBuiltInAnimate('growRadiusIn', GrowRadiusIn);\n AnimateExecutor.registerBuiltInAnimate('growRadiusOut', GrowRadiusOut);\n AnimateExecutor.registerBuiltInAnimate('moveIn', MoveIn);\n AnimateExecutor.registerBuiltInAnimate('moveOut', MoveOut);\n AnimateExecutor.registerBuiltInAnimate('rotateIn', RotateIn);\n AnimateExecutor.registerBuiltInAnimate('rotateOut', RotateOut);\n // state和update共用一个自定义动画类\n AnimateExecutor.registerBuiltInAnimate('update', Update);\n AnimateExecutor.registerBuiltInAnimate('state', State);\n // Label item animations\n AnimateExecutor.registerBuiltInAnimate('labelItemAppear', LabelItemAppear);\n AnimateExecutor.registerBuiltInAnimate('labelItemDisappear', LabelItemDisappear);\n // Poptip animations\n AnimateExecutor.registerBuiltInAnimate('poptipAppear', PoptipAppear);\n AnimateExecutor.registerBuiltInAnimate('poptipDisappear', PoptipDisappear);\n\n // Text input animations\n AnimateExecutor.registerBuiltInAnimate('inputText', InputText);\n AnimateExecutor.registerBuiltInAnimate('inputRichText', InputRichText);\n AnimateExecutor.registerBuiltInAnimate('outputRichText', OutputRichText);\n AnimateExecutor.registerBuiltInAnimate('slideRichText', SlideRichText);\n AnimateExecutor.registerBuiltInAnimate('slideOutRichText', SlideOutRichText);\n\n // 故事化动画 - 入场\n AnimateExecutor.registerBuiltInAnimate('slideIn', SlideIn);\n AnimateExecutor.registerBuiltInAnimate('growIn', GrowIn);\n AnimateExecutor.registerBuiltInAnimate('spinIn', SpinIn);\n AnimateExecutor.registerBuiltInAnimate('moveScaleIn', MoveScaleIn);\n AnimateExecutor.registerBuiltInAnimate('moveRotateIn', MoveRotateIn);\n\n // 故事化动画 - 出场\n AnimateExecutor.registerBuiltInAnimate('slideOut', SlideOut);\n AnimateExecutor.registerBuiltInAnimate('growOut', GrowOut);\n AnimateExecutor.registerBuiltInAnimate('spinOut', SpinOut);\n AnimateExecutor.registerBuiltInAnimate('moveScaleOut', MoveScaleOut);\n AnimateExecutor.registerBuiltInAnimate('moveRotateOut', MoveRotateOut);\n};\n"]}
@@ -0,0 +1,33 @@
1
+ import { ACustomAnimate } from '../custom-animate';
2
+ import type { IRichTextCharacter, IAnimate, IStep, EasingType } from '@visactor/vrender-core';
3
+ export declare class InputRichText extends ACustomAnimate<{
4
+ textConfig: IRichTextCharacter[];
5
+ }> {
6
+ valid: boolean;
7
+ private fromTextConfig;
8
+ private toTextConfig;
9
+ private originalTextConfig;
10
+ private showCursor;
11
+ private cursorChar;
12
+ private blinkCursor;
13
+ private beforeText;
14
+ private afterText;
15
+ private fadeInChars;
16
+ private fadeInDuration;
17
+ constructor(from: {
18
+ textConfig: IRichTextCharacter[];
19
+ }, to: {
20
+ textConfig: IRichTextCharacter[];
21
+ }, duration: number, easing: EasingType, params?: {
22
+ showCursor?: boolean;
23
+ cursorChar?: string;
24
+ blinkCursor?: boolean;
25
+ beforeText?: string;
26
+ afterText?: string;
27
+ fadeInChars?: boolean;
28
+ fadeInDuration?: number;
29
+ });
30
+ onFirstRun(): void;
31
+ onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
32
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
33
+ }
@@ -0,0 +1,64 @@
1
+ import { ACustomAnimate } from "../custom-animate";
2
+
3
+ import { RichText } from "@visactor/vrender-core";
4
+
5
+ export class InputRichText extends ACustomAnimate {
6
+ constructor(from, to, duration, easing, params) {
7
+ super(from, to, duration, easing, params), this.fromTextConfig = [], this.toTextConfig = [],
8
+ this.originalTextConfig = [], this.showCursor = !1, this.cursorChar = "|", this.blinkCursor = !0,
9
+ this.beforeText = "", this.afterText = "", this.fadeInChars = !1, this.fadeInDuration = .3,
10
+ void 0 !== (null == params ? void 0 : params.showCursor) && (this.showCursor = params.showCursor),
11
+ void 0 !== (null == params ? void 0 : params.cursorChar) && (this.cursorChar = params.cursorChar),
12
+ void 0 !== (null == params ? void 0 : params.blinkCursor) && (this.blinkCursor = params.blinkCursor),
13
+ void 0 !== (null == params ? void 0 : params.beforeText) && (this.beforeText = params.beforeText),
14
+ void 0 !== (null == params ? void 0 : params.afterText) && (this.afterText = params.afterText),
15
+ void 0 !== (null == params ? void 0 : params.fadeInChars) && (this.fadeInChars = params.fadeInChars),
16
+ void 0 !== (null == params ? void 0 : params.fadeInDuration) && (this.fadeInDuration = params.fadeInDuration);
17
+ }
18
+ onFirstRun() {
19
+ const fromProps = this.getLastProps(), toProps = this.getEndProps();
20
+ this.originalTextConfig = toProps.textConfig ? [ ...toProps.textConfig ] : [], this.valid = !0,
21
+ this.originalTextConfig && 0 !== this.originalTextConfig.length ? (this.fromTextConfig = fromProps.textConfig && fromProps.textConfig.length > 0 ? RichText.TransformTextConfig2SingleCharacter(fromProps.textConfig) : [],
22
+ this.toTextConfig = RichText.TransformTextConfig2SingleCharacter(this.originalTextConfig)) : this.valid = !1;
23
+ }
24
+ onEnd(cb) {
25
+ super.onEnd(cb), cb || this.target.setAttribute("textConfig", this.originalTextConfig);
26
+ }
27
+ onUpdate(end, ratio, out) {
28
+ if (!this.valid) return;
29
+ const totalItems = this.toTextConfig.length, fromItems = this.fromTextConfig.length, maxTextShowRatio = this.fadeInChars ? 1 - this.fadeInDuration : 1;
30
+ let currentLength, currentTextConfig;
31
+ if (fromItems > totalItems) currentLength = Math.round(fromItems - (fromItems - totalItems) * ratio); else if (this.fadeInChars) {
32
+ const adjustedRatio = Math.min(1, ratio / maxTextShowRatio);
33
+ currentLength = Math.round(fromItems + (totalItems - fromItems) * adjustedRatio);
34
+ } else currentLength = Math.round(fromItems + (totalItems - fromItems) * ratio);
35
+ if (currentTextConfig = fromItems > totalItems ? this.fromTextConfig.slice(0, currentLength) : this.toTextConfig.slice(0, currentLength).map(((item, index) => {
36
+ if (this.fadeInChars && "text" in item) {
37
+ const fadeProgress = (ratio - index / totalItems * maxTextShowRatio) / this.fadeInDuration, opacity = Math.max(0, Math.min(1, fadeProgress));
38
+ return Object.assign(Object.assign({}, item), {
39
+ opacity: opacity
40
+ });
41
+ }
42
+ return item;
43
+ })), this.showCursor && currentLength < totalItems) {
44
+ let shouldShowCursor = !0;
45
+ if (this.blinkCursor) {
46
+ const blinkRate = .1;
47
+ shouldShowCursor = Math.floor(ratio / blinkRate) % 2 == 0;
48
+ }
49
+ if (shouldShowCursor && currentTextConfig.length > 0) {
50
+ const lastIndex = currentTextConfig.length - 1, lastItem = currentTextConfig[lastIndex];
51
+ if ("text" in lastItem) currentTextConfig[lastIndex] = Object.assign(Object.assign({}, lastItem), {
52
+ text: String(lastItem.text) + this.cursorChar
53
+ }); else {
54
+ const cursorItem = {
55
+ text: this.cursorChar,
56
+ fontSize: 16
57
+ };
58
+ currentTextConfig.push(cursorItem);
59
+ }
60
+ }
61
+ }
62
+ this.target.setAttribute("textConfig", currentTextConfig);
63
+ }
64
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/custom/richtext/input-richtext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAQlD,MAAM,OAAO,aAAc,SAAQ,cAAoD;IAcrF,YACE,IAA0C,EAC1C,EAAwC,EACxC,QAAgB,EAChB,MAAkB,EAClB,MAQC;QAED,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QA1BpC,mBAAc,GAAyB,EAAE,CAAC;QAC1C,iBAAY,GAAyB,EAAE,CAAC;QACxC,uBAAkB,GAAyB,EAAE,CAAC;QAC9C,eAAU,GAAY,KAAK,CAAC;QAC5B,eAAU,GAAW,GAAG,CAAC;QACzB,gBAAW,GAAY,IAAI,CAAC;QAC5B,eAAU,GAAW,EAAE,CAAC;QACxB,cAAS,GAAW,EAAE,CAAC;QACvB,gBAAW,GAAY,KAAK,CAAC;QAC7B,mBAAc,GAAW,GAAG,CAAC;QAoBnC,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM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W,EAAE;gBAEpB,MAAM,SAAS,GAAG,GAAG,CAAC;gBACtB,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;aAC5D;YAED,IAAI,gBAAgB,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;gBAEpD,MAAM,SAAS,GAAG,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC;gBAC/C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;gBAE9C,IAAI,MAAM,IAAI,QAAQ,EAAE;oBAEtB,iBAAiB,CAAC,SAAS,CAAC,mCACvB,QAAQ,KACX,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,GAC9C,CAAC;iBACH;qBAAM;oBAEL,MAAM,UAAU,GAAgC;wBAC9C,IAAI,EAAE,IAAI,CAAC,UAAU;wBACrB,QAAQ,EAAE,EAAE;qBACb,CAAC;oBACF,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;iBACpC;aACF;SACF;QAGD,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IAC5D,CAAC;CACF","file":"input-richtext.js","sourcesContent":["import { ACustomAnimate } from '../custom-animate';\nimport type {\n IRichTextCharacter,\n IRichTextParagraphCharacter,\n IAnimate,\n IStep,\n EasingType\n} from '@visactor/vrender-core';\nimport { RichText } from '@visactor/vrender-core';\n\n/**\n * 富文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n * 支持通过fadeInChars参数开启字符透明度渐变效果\n */\nexport class InputRichText extends ACustomAnimate<{ textConfig: IRichTextCharacter[] }> {\n declare valid: boolean;\n\n private fromTextConfig: IRichTextCharacter[] = [];\n private toTextConfig: IRichTextCharacter[] = [];\n private originalTextConfig: IRichTextCharacter[] = [];\n private showCursor: boolean = false;\n private cursorChar: string = '|';\n private blinkCursor: boolean = true;\n private beforeText: string = '';\n private afterText: string = '';\n private fadeInChars: boolean = false;\n private fadeInDuration: number = 0.3; // 透明度渐变持续时间,以动画总时长的比例表示\n\n constructor(\n from: { textConfig: IRichTextCharacter[] },\n to: { textConfig: IRichTextCharacter[] },\n duration: number,\n easing: EasingType,\n params?: {\n showCursor?: boolean;\n cursorChar?: string;\n blinkCursor?: boolean;\n beforeText?: string;\n afterText?: string;\n fadeInChars?: boolean;\n fadeInDuration?: number;\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 if (params?.fadeInChars !== undefined) {\n this.fadeInChars = params.fadeInChars;\n }\n if (params?.fadeInDuration !== undefined) {\n this.fadeInDuration = params.fadeInDuration;\n }\n }\n\n onFirstRun(): void {\n const fromProps = this.getLastProps();\n const toProps = this.getEndProps();\n\n // 存储原始配置\n this.originalTextConfig = toProps.textConfig ? [...toProps.textConfig] : [];\n\n // 初始化解析结果\n this.valid = true;\n\n // 确保to不为空\n if (!this.originalTextConfig || this.originalTextConfig.length === 0) {\n this.valid = false;\n return;\n }\n\n // 将文本拆分为单个字符,使用RichText的静态方法\n this.fromTextConfig =\n fromProps.textConfig && fromProps.textConfig.length > 0\n ? RichText.TransformTextConfig2SingleCharacter(fromProps.textConfig)\n : [];\n\n this.toTextConfig = RichText.TransformTextConfig2SingleCharacter(this.originalTextConfig);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n if (!cb) {\n // 动画结束时,恢复原始textConfig\n this.target.setAttribute('textConfig', this.originalTextConfig);\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 totalItems = this.toTextConfig.length;\n const fromItems = this.fromTextConfig.length;\n\n // 计算文本显示比例上限 - 如果有渐变效果,需要为尾部字符的渐变留出时间\n // 例如,如果fadeInDuration为0.3,则文本显示部分最多占用动画时间的70%\n const maxTextShowRatio = this.fadeInChars ? 1 - this.fadeInDuration : 1;\n\n // 确定当前应该显示多少个项目\n let currentLength: number;\n\n // 如果fromItems比totalItems长,则是删除动画,否则是添加动画\n if (fromItems > totalItems) {\n // 删除文本动画(从多到少)\n currentLength = Math.round(fromItems - (fromItems - totalItems) * ratio);\n } else {\n // 添加文本动画(从少到多)- 需要更快显示字符以便留出时间让最后的字符完成渐变\n if (this.fadeInChars) {\n // 当ratio达到maxTextShowRatio时,应该已经显示全部文本\n const adjustedRatio = Math.min(1, ratio / maxTextShowRatio);\n currentLength = Math.round(fromItems + (totalItems - fromItems) * adjustedRatio);\n } else {\n // 无渐变效果时,正常显示\n currentLength = Math.round(fromItems + (totalItems - fromItems) * ratio);\n }\n }\n\n // 构建当前要显示的textConfig\n let currentTextConfig: IRichTextCharacter[];\n if (fromItems > totalItems) {\n // 删除动画:显示from的前currentLength项\n currentTextConfig = this.fromTextConfig.slice(0, currentLength);\n } else {\n // 添加文本动画:显示to的前currentLength项,可能需要应用透明度\n currentTextConfig = this.toTextConfig.slice(0, currentLength).map((item, index) => {\n // 如果启用了透明度渐变效果\n if (this.fadeInChars && 'text' in item) {\n // 计算每个字符从出现到结束的渐变进度\n // 字符在特定时间点出现:出现时刻 = (index / totalItems) * maxTextShowRatio\n // 当前时刻 = ratio\n // 渐变持续时间 = fadeInDuration\n // 渐变进度 = (当前时刻 - 出现时刻) / 渐变持续时间\n\n const appearTime = (index / totalItems) * maxTextShowRatio;\n const fadeProgress = (ratio - appearTime) / this.fadeInDuration;\n\n // 限制透明度在0-1范围内\n const opacity = Math.max(0, Math.min(1, fadeProgress));\n\n // 如果是文本项,添加透明度\n return {\n ...item,\n opacity: opacity\n };\n }\n return item;\n });\n }\n\n // 如果启用了光标\n if (this.showCursor && currentLength < totalItems) {\n // 判断是否应该显示光标\n let shouldShowCursor = true;\n\n if (this.blinkCursor) {\n // 闪烁效果:在动画期间,光标每半个周期闪烁一次\n const blinkRate = 0.1; // 光标闪烁频率(每10%动画进度闪烁一次)\n shouldShowCursor = Math.floor(ratio / blinkRate) % 2 === 0;\n }\n\n if (shouldShowCursor && currentTextConfig.length > 0) {\n // 找到最后一个文本项,在其后添加光标\n const lastIndex = currentTextConfig.length - 1;\n const lastItem = currentTextConfig[lastIndex];\n\n if ('text' in lastItem) {\n // 如果最后一项是文本,将光标添加到文本后面\n currentTextConfig[lastIndex] = {\n ...lastItem,\n text: String(lastItem.text) + this.cursorChar\n };\n } else {\n // 如果最后一项是非文本(如图片),添加一个只包含光标的新文本项\n const cursorItem: IRichTextParagraphCharacter = {\n text: this.cursorChar,\n fontSize: 16 // 使用默认字体大小,或者从context获取\n };\n currentTextConfig.push(cursorItem);\n }\n }\n }\n\n // 更新富文本的textConfig属性\n this.target.setAttribute('textConfig', currentTextConfig);\n }\n}\n"]}