@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,144 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.SlideRichText = void 0;
6
+
7
+ const custom_animate_1 = require("../custom-animate"), vrender_core_1 = require("@visactor/vrender-core");
8
+
9
+ class SlideRichText extends custom_animate_1.ACustomAnimate {
10
+ constructor(from, to, duration, easing, params) {
11
+ super(from, to, duration, easing, params), this.fromTextConfig = [], this.toTextConfig = [],
12
+ this.originalTextConfig = [], this.singleCharConfig = [], this.fadeInDuration = .3,
13
+ this.slideDirection = "right", this.slideDistance = 30, this.wordByWord = !1, this.wordRegex = /[a-zA-Z]+(-[a-zA-Z]+)*|[\u4e00-\u9fa5]+|[0-9]+|[^\s\w\u4e00-\u9fa5]/g,
14
+ this.wordGroups = [], void 0 !== (null == params ? void 0 : params.fadeInDuration) && (this.fadeInDuration = params.fadeInDuration),
15
+ void 0 !== (null == params ? void 0 : params.slideDirection) && (this.slideDirection = params.slideDirection),
16
+ void 0 !== (null == params ? void 0 : params.slideDistance) && (this.slideDistance = params.slideDistance),
17
+ void 0 !== (null == params ? void 0 : params.wordByWord) && (this.wordByWord = params.wordByWord),
18
+ void 0 !== (null == params ? void 0 : params.wordRegex) && (this.wordRegex = params.wordRegex);
19
+ }
20
+ onFirstRun() {
21
+ const fromProps = this.getLastProps(), toProps = this.getEndProps();
22
+ this.originalTextConfig = toProps.textConfig ? [ ...toProps.textConfig ] : [], this.valid = !0,
23
+ this.originalTextConfig && 0 !== this.originalTextConfig.length ? (this.fromTextConfig = fromProps.textConfig && fromProps.textConfig.length > 0 ? vrender_core_1.RichText.TransformTextConfig2SingleCharacter(fromProps.textConfig) : [],
24
+ this.toTextConfig = vrender_core_1.RichText.TransformTextConfig2SingleCharacter(this.originalTextConfig),
25
+ this.singleCharConfig = this.toTextConfig.map((item => "text" in item ? Object.assign(Object.assign({}, item), {
26
+ opacity: 0,
27
+ dx: this.getInitialDx(),
28
+ dy: this.getInitialDy()
29
+ }) : Object.assign(Object.assign({}, item), {
30
+ opacity: 0
31
+ }))), this.wordByWord && this.calculateWordGroups()) : this.valid = !1;
32
+ }
33
+ calculateWordGroups() {
34
+ this.wordGroups = [];
35
+ let fullText = "";
36
+ const charMap = {};
37
+ let match, fullTextIndex = 0;
38
+ for ((this.toTextConfig.forEach(((item, configIndex) => {
39
+ if ("text" in item) {
40
+ const text = String(item.text);
41
+ fullText += text, charMap[fullTextIndex] = configIndex, fullTextIndex++;
42
+ }
43
+ })), this.wordRegex.lastIndex = 0); null !== (match = this.wordRegex.exec(fullText)); ) {
44
+ const wordStart = match.index, wordEnd = match.index + match[0].length, wordIndices = [];
45
+ for (let i = wordStart; i < wordEnd; i++) void 0 !== charMap[i] && wordIndices.push(charMap[i]);
46
+ wordIndices.length > 0 && this.wordGroups.push(wordIndices);
47
+ }
48
+ const allocatedIndices = new Set;
49
+ this.wordGroups.forEach((group => {
50
+ group.forEach((index => allocatedIndices.add(index)));
51
+ }));
52
+ for (let i = 0; i < this.toTextConfig.length; i++) "text" in this.toTextConfig[i] && !allocatedIndices.has(i) && this.wordGroups.push([ i ]);
53
+ }
54
+ getInitialDx() {
55
+ switch (this.slideDirection) {
56
+ case "left":
57
+ return -this.slideDistance;
58
+
59
+ case "right":
60
+ return this.slideDistance;
61
+
62
+ default:
63
+ return 0;
64
+ }
65
+ }
66
+ getInitialDy() {
67
+ switch (this.slideDirection) {
68
+ case "up":
69
+ return -this.slideDistance;
70
+
71
+ case "down":
72
+ return this.slideDistance;
73
+
74
+ default:
75
+ return 0;
76
+ }
77
+ }
78
+ onEnd(cb) {
79
+ super.onEnd(cb), cb || this.target.setAttribute("textConfig", this.originalTextConfig);
80
+ }
81
+ onUpdate(end, ratio, out) {
82
+ if (!this.valid) return;
83
+ const maxTextShowRatio = 1 - this.fadeInDuration;
84
+ let updatedTextConfig;
85
+ updatedTextConfig = this.wordByWord && this.wordGroups.length > 0 ? this.updateByWord(ratio, maxTextShowRatio) : this.updateByCharacter(ratio, maxTextShowRatio),
86
+ this.target.setAttribute("textConfig", updatedTextConfig);
87
+ }
88
+ updateByWord(ratio, maxTextShowRatio) {
89
+ const totalGroups = this.wordGroups.length, updatedTextConfig = [ ...this.singleCharConfig ];
90
+ for (let groupIndex = 0; groupIndex < this.wordGroups.length; groupIndex++) {
91
+ let appearTime;
92
+ if (appearTime = "left" === this.slideDirection ? (totalGroups - 1 - groupIndex) / totalGroups * maxTextShowRatio : groupIndex / totalGroups * maxTextShowRatio,
93
+ ratio < appearTime) {
94
+ for (const charIndex of this.wordGroups[groupIndex]) {
95
+ const item = updatedTextConfig[charIndex];
96
+ "text" in item && (updatedTextConfig[charIndex] = Object.assign(Object.assign({}, item), {
97
+ opacity: 0,
98
+ dx: this.getInitialDx(),
99
+ dy: this.getInitialDy()
100
+ }));
101
+ }
102
+ continue;
103
+ }
104
+ const animProgress = (ratio - appearTime) / this.fadeInDuration, progress = Math.max(0, Math.min(1, animProgress)), dx = this.getInitialDx() * (1 - progress), dy = this.getInitialDy() * (1 - progress);
105
+ for (const charIndex of this.wordGroups[groupIndex]) {
106
+ const item = updatedTextConfig[charIndex];
107
+ "text" in item && (updatedTextConfig[charIndex] = Object.assign(Object.assign({}, item), {
108
+ opacity: progress,
109
+ dx: dx,
110
+ dy: dy
111
+ }));
112
+ }
113
+ }
114
+ return updatedTextConfig;
115
+ }
116
+ updateByCharacter(ratio, maxTextShowRatio) {
117
+ const totalItems = this.toTextConfig.length, updatedTextConfig = [ ...this.singleCharConfig ];
118
+ for (let index = 0; index < updatedTextConfig.length; index++) {
119
+ const item = updatedTextConfig[index];
120
+ if ("text" in item) {
121
+ let appearTime;
122
+ if (appearTime = "left" === this.slideDirection ? (totalItems - 1 - index) / totalItems * maxTextShowRatio : index / totalItems * maxTextShowRatio,
123
+ ratio < appearTime) {
124
+ updatedTextConfig[index] = Object.assign(Object.assign({}, item), {
125
+ opacity: 0,
126
+ dx: this.getInitialDx(),
127
+ dy: this.getInitialDy()
128
+ });
129
+ continue;
130
+ }
131
+ const animProgress = (ratio - appearTime) / this.fadeInDuration, progress = Math.max(0, Math.min(1, animProgress)), dx = this.getInitialDx() * (1 - progress), dy = this.getInitialDy() * (1 - progress);
132
+ updatedTextConfig[index] = Object.assign(Object.assign({}, item), {
133
+ opacity: progress,
134
+ dx: dx,
135
+ dy: dy
136
+ });
137
+ }
138
+ }
139
+ return updatedTextConfig;
140
+ }
141
+ }
142
+
143
+ exports.SlideRichText = SlideRichText;
144
+ //# sourceMappingURL=slide-richtext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/custom/richtext/slide-richtext.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD,yDAAkD;AAQlD,MAAa,aAAc,SAAQ,+BAAoD;IAerF,YACE,IAA0C,EAC1C,EAAwC,EACxC,QAAgB,EAChB,MAAkB,EAClB,MAMC;QAED,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAzBpC,mBAAc,GAAyB,EAAE,CAAC;QAC1C,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,GAAG,gBAAgB,CAAC;iBACtD;gBAGD,IAAI,KAAK,GAAG,UAAU,EAAE;oBACtB,iBAAiB,CAAC,KAAK,CAAC,mCACnB,IAAI,KACP,OAAO,EAAE,CAAC,EACV,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,EACvB,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,GACxB,CAAC;oBACF,SAAS;iBACV;gBAGD,MAAM,YAAY,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC;gBAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;gBAGxD,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;gBAChD,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;gBAEhD,iBAAiB,CAAC,KAAK,CAAC,mCACnB,IAAI,KACP,OAAO,EAAE,QAAQ,EACjB,EAAE;oBACF,EAAE,GACH,CAAC;aACH;SACF;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AA9TD,sCA8TC","file":"slide-richtext.js","sourcesContent":["import { ACustomAnimate } from '../custom-animate';\nimport type { IRichTextCharacter, IAnimate, IStep, EasingType } from '@visactor/vrender-core';\nimport { RichText } from '@visactor/vrender-core';\n\n/**\n * 滑动富文本动画,结合打字效果和方向滑动效果\n * 文字会从指定方向滑入,同时逐字显示和渐入\n * 支持上、下、左、右四个方向\n * 支持按单词或字符入场\n */\nexport class SlideRichText extends ACustomAnimate<{ textConfig: IRichTextCharacter[] }> {\n declare valid: boolean;\n\n private fromTextConfig: IRichTextCharacter[] = [];\n private toTextConfig: IRichTextCharacter[] = [];\n private originalTextConfig: IRichTextCharacter[] = [];\n private singleCharConfig: IRichTextCharacter[] = [];\n private fadeInDuration: number = 0.3; // 透明度渐变持续时间,以动画总时长的比例表示\n private slideDirection: 'up' | 'down' | 'left' | 'right' = 'right'; // 滑动方向\n private slideDistance: number = 30; // 滑动距离(像素)\n private wordByWord: boolean = false; // 是否按单词为单位进行动画\n // 默认正则表达式: 匹配英文单词(含中间连字符),连续中文字符,数字,以及独立的符号和空格\n private wordRegex: RegExp = /[a-zA-Z]+(-[a-zA-Z]+)*|[\\u4e00-\\u9fa5]+|[0-9]+|[^\\s\\w\\u4e00-\\u9fa5]/g;\n private wordGroups: number[][] = []; // 存储单词分组信息,每个数组包含属于同一单词的字符索引\n\n constructor(\n from: { textConfig: IRichTextCharacter[] },\n to: { textConfig: IRichTextCharacter[] },\n duration: number,\n easing: EasingType,\n params?: {\n fadeInDuration?: number;\n slideDirection?: 'up' | 'down' | 'left' | 'right';\n slideDistance?: number;\n wordByWord?: boolean;\n wordRegex?: RegExp;\n }\n ) {\n super(from, to, duration, easing, params);\n\n // 配置透明度渐变效果\n if (params?.fadeInDuration !== undefined) {\n this.fadeInDuration = params.fadeInDuration;\n }\n\n // 配置滑动方向和距离\n if (params?.slideDirection !== undefined) {\n this.slideDirection = params.slideDirection;\n }\n if (params?.slideDistance !== undefined) {\n this.slideDistance = params.slideDistance;\n }\n\n // 配置按单词动画\n if (params?.wordByWord !== undefined) {\n this.wordByWord = params.wordByWord;\n }\n if (params?.wordRegex !== undefined) {\n this.wordRegex = params.wordRegex;\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 this.singleCharConfig = this.toTextConfig.map(item => {\n if ('text' in item) {\n // 文本字符初始设置为透明\n return {\n ...item,\n opacity: 0,\n dx: this.getInitialDx(),\n dy: this.getInitialDy()\n };\n }\n return { ...item, opacity: 0 };\n });\n\n // 如果启用按单词动画,则计算单词分组\n if (this.wordByWord) {\n this.calculateWordGroups();\n }\n }\n\n // 计算单词分组\n private calculateWordGroups(): void {\n // 重置单词分组\n this.wordGroups = [];\n\n // 构建完整文本用于正则匹配\n let fullText = '';\n const charMap: Record<number, number> = {}; // 映射全文索引到字符配置索引\n let fullTextIndex = 0;\n\n // 构建全文和映射\n this.toTextConfig.forEach((item, configIndex) => {\n if ('text' in item) {\n const text = String(item.text);\n fullText += text;\n // 为每个字符创建映射\n charMap[fullTextIndex] = configIndex;\n fullTextIndex++;\n }\n });\n\n // 使用正则表达式查找单词\n let match;\n\n // 重置正则表达式状态\n this.wordRegex.lastIndex = 0;\n\n while ((match = this.wordRegex.exec(fullText)) !== null) {\n const wordStart = match.index;\n const wordEnd = match.index + match[0].length;\n\n // 找出属于这个单词的所有字符索引\n const wordIndices = [];\n\n for (let i = wordStart; i < wordEnd; i++) {\n if (charMap[i] !== undefined) {\n wordIndices.push(charMap[i]);\n }\n }\n\n // 添加到单词分组\n if (wordIndices.length > 0) {\n this.wordGroups.push(wordIndices);\n }\n }\n\n // 处理没有分配到任何单词的字符\n const allocatedIndices = new Set<number>();\n this.wordGroups.forEach(group => {\n group.forEach(index => allocatedIndices.add(index));\n });\n\n for (let i = 0; i < this.toTextConfig.length; i++) {\n if ('text' in this.toTextConfig[i] && !allocatedIndices.has(i)) {\n // 单独为每个未分配的字符创建一个\"单词\"\n this.wordGroups.push([i]);\n }\n }\n }\n\n // 根据滑动方向计算初始x偏移\n private getInitialDx(): number {\n switch (this.slideDirection) {\n case 'left':\n return -this.slideDistance;\n case 'right':\n return this.slideDistance;\n default:\n return 0;\n }\n }\n\n // 根据滑动方向计算初始y偏移\n private getInitialDy(): number {\n switch (this.slideDirection) {\n case 'up':\n return -this.slideDistance;\n case 'down':\n return this.slideDistance;\n default:\n return 0;\n }\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 maxTextShowRatio = 1 - this.fadeInDuration;\n\n let updatedTextConfig: IRichTextCharacter[];\n\n if (this.wordByWord && this.wordGroups.length > 0) {\n // 按单词动画\n updatedTextConfig = this.updateByWord(ratio, maxTextShowRatio);\n } else {\n // 按字符动画\n updatedTextConfig = this.updateByCharacter(ratio, maxTextShowRatio);\n }\n\n // 更新富文本的textConfig属性\n this.target.setAttribute('textConfig', updatedTextConfig);\n }\n\n // 按单词更新文本配置\n private updateByWord(ratio: number, maxTextShowRatio: number): IRichTextCharacter[] {\n const totalGroups = this.wordGroups.length;\n const updatedTextConfig = [...this.singleCharConfig];\n\n // 处理单词分组\n for (let groupIndex = 0; groupIndex < this.wordGroups.length; groupIndex++) {\n // 计算这个单词组的显示时间点\n let appearTime;\n if (this.slideDirection === 'left') {\n // 从右到左顺序(最后的单词先出现)\n appearTime = ((totalGroups - 1 - groupIndex) / totalGroups) * maxTextShowRatio;\n } else {\n // 标准顺序(第一个单词先出现)\n appearTime = (groupIndex / totalGroups) * maxTextShowRatio;\n }\n\n // 如果当前时间还没到显示这个单词的时间点,保持隐藏状态\n if (ratio < appearTime) {\n for (const charIndex of this.wordGroups[groupIndex]) {\n const item = updatedTextConfig[charIndex];\n if ('text' in item) {\n updatedTextConfig[charIndex] = {\n ...item,\n opacity: 0,\n dx: this.getInitialDx(),\n dy: this.getInitialDy()\n };\n }\n }\n continue;\n }\n\n // 计算动画进度(0-1之间)\n const animProgress = (ratio - appearTime) / this.fadeInDuration;\n const progress = Math.max(0, Math.min(1, animProgress));\n\n // 计算当前偏移和透明度\n const dx = this.getInitialDx() * (1 - progress);\n const dy = this.getInitialDy() * (1 - progress);\n\n // 更新这个单词的所有字符\n for (const charIndex of this.wordGroups[groupIndex]) {\n const item = updatedTextConfig[charIndex];\n if ('text' in item) {\n updatedTextConfig[charIndex] = {\n ...item,\n opacity: progress,\n dx,\n dy\n };\n }\n }\n }\n\n return updatedTextConfig;\n }\n\n // 按字符更新文本配置\n private updateByCharacter(ratio: number, maxTextShowRatio: number): IRichTextCharacter[] {\n const totalItems = this.toTextConfig.length;\n const updatedTextConfig = [...this.singleCharConfig];\n\n // 更新每个字符的状态\n for (let index = 0; index < updatedTextConfig.length; index++) {\n const item = updatedTextConfig[index];\n if ('text' in item) {\n // 计算每个字符的显示时间点\n // 对于left方向,反转显示顺序(从右到左)\n let appearTime;\n if (this.slideDirection === 'left') {\n // 从右到左的顺序 (最后的字符先出现)\n appearTime = ((totalItems - 1 - index) / totalItems) * maxTextShowRatio;\n } else {\n // 标准顺序 (第一个字符先出现)\n appearTime = (index / totalItems) * maxTextShowRatio;\n }\n\n // 如果当前时间还没到显示这个字符的时间点,保持隐藏状态\n if (ratio < appearTime) {\n updatedTextConfig[index] = {\n ...item,\n opacity: 0,\n dx: this.getInitialDx(),\n dy: this.getInitialDy()\n };\n continue;\n }\n\n // 计算动画进度(0-1之间)\n const animProgress = (ratio - appearTime) / this.fadeInDuration;\n const progress = Math.max(0, Math.min(1, animProgress));\n\n // 计算当前偏移和透明度\n const dx = this.getInitialDx() * (1 - progress);\n const dy = this.getInitialDy() * (1 - progress);\n\n updatedTextConfig[index] = {\n ...item,\n opacity: progress,\n dx,\n dy\n };\n }\n }\n\n return updatedTextConfig;\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import type { EasingType, IGraphic } from '@visactor/vrender-core';
2
+ import { ACustomAnimate } from './custom-animate';
3
+ export interface IRotateAnimationOptions {
4
+ orient?: 'clockwise' | 'anticlockwise';
5
+ angle?: number;
6
+ }
7
+ export declare const rotateIn: (graphic: IGraphic, options: IRotateAnimationOptions) => {
8
+ from: {
9
+ angle: number;
10
+ };
11
+ to: {
12
+ angle: any;
13
+ };
14
+ };
15
+ export declare const rotateOut: (graphic: IGraphic, options: IRotateAnimationOptions) => {
16
+ from: {
17
+ angle: any;
18
+ };
19
+ to: {
20
+ angle: number;
21
+ };
22
+ };
23
+ export declare class RotateBase extends ACustomAnimate<Record<string, number>> {
24
+ valid: boolean;
25
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: any);
26
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
27
+ }
28
+ export declare class RotateIn extends RotateBase {
29
+ onBind(): void;
30
+ }
31
+ export declare class RotateOut extends RotateBase {
32
+ onBind(): void;
33
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.RotateOut = exports.RotateIn = exports.RotateBase = exports.rotateOut = exports.rotateIn = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils"), custom_animate_1 = require("./custom-animate"), rotateIn = (graphic, options) => {
8
+ var _a;
9
+ const attributeAngle = null !== (_a = graphic.getFinalAttribute().angle) && void 0 !== _a ? _a : 0;
10
+ let angle = 0;
11
+ return angle = (0, vutils_1.isNumberClose)(attributeAngle / (2 * Math.PI), 0) ? Math.round(attributeAngle / (2 * Math.PI)) * Math.PI * 2 : (0,
12
+ vutils_1.isValidNumber)(null == options ? void 0 : options.angle) ? options.angle : "anticlockwise" === (null == options ? void 0 : options.orient) ? Math.ceil(attributeAngle / (2 * Math.PI)) * Math.PI * 2 : Math.floor(attributeAngle / (2 * Math.PI)) * Math.PI * 2,
13
+ {
14
+ from: {
15
+ angle: angle
16
+ },
17
+ to: {
18
+ angle: attributeAngle
19
+ }
20
+ };
21
+ };
22
+
23
+ exports.rotateIn = rotateIn;
24
+
25
+ const rotateOut = (graphic, options) => {
26
+ var _a;
27
+ const finalAngle = null !== (_a = graphic.getFinalAttribute().angle) && void 0 !== _a ? _a : 0;
28
+ let angle = 0;
29
+ return angle = (0, vutils_1.isNumberClose)(finalAngle / (2 * Math.PI), 0) ? Math.round(finalAngle / (2 * Math.PI)) * Math.PI * 2 : (0,
30
+ vutils_1.isValidNumber)(null == options ? void 0 : options.angle) ? options.angle : "anticlockwise" === (null == options ? void 0 : options.orient) ? Math.ceil(finalAngle / (2 * Math.PI)) * Math.PI * 2 : Math.floor(finalAngle / (2 * Math.PI)) * Math.PI * 2,
31
+ {
32
+ from: {
33
+ angle: finalAngle
34
+ },
35
+ to: {
36
+ angle: angle
37
+ }
38
+ };
39
+ };
40
+
41
+ exports.rotateOut = rotateOut;
42
+
43
+ class RotateBase extends custom_animate_1.ACustomAnimate {
44
+ constructor(from, to, duration, easing, params) {
45
+ super(from, to, duration, easing, params);
46
+ }
47
+ onUpdate(end, ratio, out) {
48
+ const attribute = this.target.attribute;
49
+ this.propKeys.forEach((key => {
50
+ attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
51
+ })), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
52
+ }
53
+ }
54
+
55
+ exports.RotateBase = RotateBase;
56
+
57
+ class RotateIn extends RotateBase {
58
+ onBind() {
59
+ const {from: from, to: to} = (0, exports.rotateIn)(this.target, this.params.options);
60
+ this.props = to, this.propKeys = [ "angle" ], this.from = from, this.to = to;
61
+ const finalAttribute = this.target.getFinalAttribute();
62
+ finalAttribute && Object.assign(this.target.attribute, finalAttribute), this.target.setAttributes(from);
63
+ }
64
+ }
65
+
66
+ exports.RotateIn = RotateIn;
67
+
68
+ class RotateOut extends RotateBase {
69
+ onBind() {
70
+ const {from: from, to: to} = (0, exports.rotateOut)(this.target, this.params.options);
71
+ this.props = to, this.propKeys = [ "angle" ], this.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C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;SACtD;QAED,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAlBD,4BAkBC;AAED,MAAa,SAAU,SAAQ,UAAU;IACvC,MAAM;QACJ,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,IAAA,iBAAS,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC,CAAC;QAE1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;CACF;AATD,8BASC","file":"rotate.js","sourcesContent":["import type { EasingType, IGraphic } from '@visactor/vrender-core';\nimport { isNumberClose, isValidNumber } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IRotateAnimationOptions {\n orient?: 'clockwise' | 'anticlockwise';\n angle?: number;\n}\n\nexport const rotateIn = (graphic: IGraphic, options: IRotateAnimationOptions) => {\n const finalAttrs = graphic.getFinalAttribute();\n const attributeAngle = finalAttrs.angle ?? 0;\n\n let angle = 0;\n if (isNumberClose(attributeAngle / (Math.PI * 2), 0)) {\n angle = Math.round(attributeAngle / (Math.PI * 2)) * Math.PI * 2;\n } else if (isValidNumber(options?.angle)) {\n angle = options.angle;\n } else if (options?.orient === 'anticlockwise') {\n angle = Math.ceil(attributeAngle / (Math.PI * 2)) * Math.PI * 2;\n } else {\n angle = Math.floor(attributeAngle / (Math.PI * 2)) * Math.PI * 2;\n }\n return {\n from: { angle },\n to: { angle: attributeAngle }\n };\n};\n\nexport const rotateOut = (graphic: IGraphic, options: IRotateAnimationOptions) => {\n const finalAttrs = graphic.getFinalAttribute();\n const finalAngle = finalAttrs.angle ?? 0;\n let angle = 0;\n if (isNumberClose(finalAngle / (Math.PI * 2), 0)) {\n angle = Math.round(finalAngle / (Math.PI * 2)) * Math.PI * 2;\n } else if (isValidNumber(options?.angle)) {\n angle = options.angle;\n } else if (options?.orient === 'anticlockwise') {\n angle = Math.ceil(finalAngle / (Math.PI * 2)) * Math.PI * 2;\n } else {\n angle = Math.floor(finalAngle / (Math.PI * 2)) * Math.PI * 2;\n }\n return {\n from: { angle: finalAngle },\n to: { angle }\n };\n};\n\nexport class RotateBase 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 RotateIn extends RotateBase {\n onBind(): void {\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const { from, to } = rotateIn(this.target, this.params.options);\n\n this.props = to;\n this.propKeys = ['angle'];\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\n this.target.setAttributes(from);\n }\n}\n\nexport class RotateOut extends RotateBase {\n onBind(): void {\n const { from, to } = rotateOut(this.target, this.params.options);\n this.props = to;\n this.propKeys = ['angle'];\n\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 interface IScaleAnimationOptions {
5
4
  direction?: 'x' | 'y' | 'xy';
@@ -13,6 +12,7 @@ export declare class ScaleIn extends ACustomAnimate<Record<string, number>> {
13
12
  updateX(ratio: number): void;
14
13
  updateY(ratio: number): void;
15
14
  updateXY(ratio: number): void;
15
+ deleteSelfAttr(key: string): void;
16
16
  onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
17
17
  }
18
18
  export declare class ScaleOut extends ACustomAnimate<Record<string, number>> {
@@ -11,38 +11,38 @@ class ScaleIn extends custom_animate_1.ACustomAnimate {
11
11
  super(from, to, duration, easing, params);
12
12
  }
13
13
  onBind() {
14
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
15
15
  let from, to;
16
- (null === (_a = this.params) || void 0 === _a ? void 0 : _a.diffAttrs) && Object.assign(this.target.attribute, this.params.diffAttrs);
17
- const attrs = this.target.getFinalAttribute(), fromAttrs = null !== (_c = null === (_b = this.target.context) || void 0 === _b ? void 0 : _b.lastAttrs) && void 0 !== _c ? _c : {};
18
- switch (null === (_d = this.params) || void 0 === _d ? void 0 : _d.direction) {
16
+ const attrs = this.target.getFinalAttribute(), fromAttrs = null !== (_a = this.target.attribute) && void 0 !== _a ? _a : {};
17
+ switch (null === (_b = this.params) || void 0 === _b ? void 0 : _b.direction) {
19
18
  case "x":
20
19
  from = {
21
- scaleX: null !== (_e = fromAttrs.scaleX) && void 0 !== _e ? _e : 0
20
+ scaleX: null !== (_c = fromAttrs.scaleX) && void 0 !== _c ? _c : 0
22
21
  }, to = {
23
- scaleX: null !== (_f = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _f ? _f : 1
24
- }, this.propKeys = [ "scaleX" ], this._updateFunction = this.updateX;
22
+ scaleX: null !== (_d = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _d ? _d : 1
23
+ }, this._updateFunction = this.updateX;
25
24
  break;
26
25
 
27
26
  case "y":
28
27
  from = {
29
- scaleY: null !== (_g = fromAttrs.scaleY) && void 0 !== _g ? _g : 0
28
+ scaleY: null !== (_e = fromAttrs.scaleY) && void 0 !== _e ? _e : 0
30
29
  }, to = {
31
- scaleY: null !== (_h = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _h ? _h : 1
32
- }, this.propKeys = [ "scaleY" ], this._updateFunction = this.updateY;
30
+ scaleY: null !== (_f = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _f ? _f : 1
31
+ }, this._updateFunction = this.updateY;
33
32
  break;
34
33
 
35
34
  default:
36
35
  from = {
37
- scaleX: null !== (_j = fromAttrs.scaleX) && void 0 !== _j ? _j : 0,
38
- scaleY: null !== (_k = fromAttrs.scaleY) && void 0 !== _k ? _k : 0
36
+ scaleX: null !== (_g = fromAttrs.scaleX) && void 0 !== _g ? _g : 0,
37
+ scaleY: null !== (_h = fromAttrs.scaleY) && void 0 !== _h ? _h : 0
39
38
  }, to = {
40
- scaleX: null !== (_l = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _l ? _l : 1,
41
- scaleY: null !== (_m = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _m ? _m : 1
42
- }, this.propKeys = [ "scaleX", "scaleY" ], this._updateFunction = this.updateXY;
39
+ scaleX: null !== (_j = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _j ? _j : 1,
40
+ scaleY: null !== (_k = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _k ? _k : 1
41
+ }, this._updateFunction = this.updateXY;
43
42
  }
44
- this.props = to, this.from = from, this.to = to, Object.assign(this.target.attribute, from),
45
- this.target.addUpdatePositionTag(), this.target.addUpdateBoundTag();
43
+ const finalAttribute = this.target.getFinalAttribute();
44
+ finalAttribute && Object.assign(this.target.attribute, finalAttribute), this.props = to,
45
+ this.from = from, this.to = to, this.target.setAttributes(from);
46
46
  }
47
47
  onEnd(cb) {
48
48
  super.onEnd(cb);
@@ -56,8 +56,13 @@ class ScaleIn extends custom_animate_1.ACustomAnimate {
56
56
  updateXY(ratio) {
57
57
  this.updateX(ratio), this.updateY(ratio);
58
58
  }
59
+ deleteSelfAttr(key) {
60
+ delete this.props[key], this.fromProps && delete this.fromProps[key];
61
+ const index = this.propKeys.indexOf(key);
62
+ -1 !== index && this.propKeys.splice(index, 1), this.propKeys && this.propKeys.length > 1 ? this._updateFunction = this.updateXY : "scaleX" === this.propKeys[0] ? this._updateFunction = this.updateX : "scaleY" === this.propKeys[0] ? this._updateFunction = this.updateY : this._updateFunction = null;
63
+ }
59
64
  onUpdate(end, ratio, out) {
60
- this._updateFunction(ratio), this.target.addUpdatePositionTag();
65
+ this._updateFunction && (this._updateFunction(ratio), this.target.addUpdatePositionTag());
61
66
  }
62
67
  }
63
68
 
@@ -70,7 +75,7 @@ class ScaleOut extends custom_animate_1.ACustomAnimate {
70
75
  onBind() {
71
76
  var _a, _b, _c, _d, _e;
72
77
  let from, to;
73
- const attrs = this.target.getFinalAttribute();
78
+ const attrs = this.target.attribute;
74
79
  switch (null === (_a = this.params) || void 0 === _a ? void 0 : _a.direction) {
75
80
  case "x":
76
81
  from = {
@@ -97,8 +102,7 @@ class ScaleOut extends custom_animate_1.ACustomAnimate {
97
102
  scaleY: 0
98
103
  };
99
104
  }
100
- this.props = to, this.propKeys = Object.keys(to), this.animate.reSyncProps(), this.from = from,
101
- this.to = to;
105
+ this.props = to, this.from = from, this.to = to;
102
106
  }
103
107
  onEnd(cb) {
104
108
  super.onEnd(cb);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/custom/scale.ts"],"names":[],"mappings":";;;AAEA,qDAAkD;AAMlD,MAAa,OAAQ,SAAQ,+BAAsC;IAGjE,YAAY,IAAU,EAAE,EAAQ,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAA+B;QACrG,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAID,MAAM;;QAEJ,IAAI,MAAA,IAAI,CAAC,MAA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E,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC,EAAE,CAAC;gBAClE,EAAE,GAAG;oBACH,MAAM,EAAE,CAAC;oBACT,MAAM,EAAE,CAAC;iBACV,CAAC;SACL;QACD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,KAAK,CAAC,EAA6C;QACjD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,MAAM,SAAS,GAAwB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QAC7D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,SAAS,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;QAC5E,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;IACrC,CAAC;CACF;AA/CD,4BA+CC","file":"scale.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport class ScaleIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n declare _updateFunction: (ratio: number) => void;\n\n onBind(): void {\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n if (this.params?.diffAttrs) {\n Object.assign(this.target.attribute, this.params.diffAttrs);\n }\n let from: Record<string, number>;\n let to: Record<string, number>;\n const attrs = this.target.getFinalAttribute();\n const fromAttrs = this.target.context?.lastAttrs ?? {};\n\n switch (this.params?.direction) {\n case 'x':\n from = { scaleX: fromAttrs.scaleX ?? 0 };\n to = { scaleX: attrs?.scaleX ?? 1 };\n this.propKeys = ['scaleX'];\n this._updateFunction = this.updateX;\n break;\n case 'y':\n from = { scaleY: fromAttrs.scaleY ?? 0 };\n to = { scaleY: attrs?.scaleY ?? 1 };\n this.propKeys = ['scaleY'];\n this._updateFunction = this.updateY;\n break;\n case 'xy':\n default:\n from = { scaleX: fromAttrs.scaleX ?? 0, scaleY: fromAttrs.scaleY ?? 0 };\n to = {\n scaleX: attrs?.scaleX ?? 1,\n scaleY: attrs?.scaleY ?? 1\n };\n this.propKeys = ['scaleX', 'scaleY'];\n this._updateFunction = this.updateXY;\n }\n\n this.props = to;\n // 性能消耗,不用reSyncProps\n // this.animate.reSyncProps();\n this.from = from;\n this.to = to;\n // 性能优化,不需要setAttributes\n Object.assign(this.target.attribute, from);\n this.target.addUpdatePositionTag();\n this.target.addUpdateBoundTag();\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n updateX(ratio: number): void {\n this.target.attribute.scaleX = this.from.scaleX + (this.to.scaleX - this.from.scaleX) * ratio;\n }\n\n updateY(ratio: number): void {\n this.target.attribute.scaleY = this.from.scaleY + (this.to.scaleY - this.from.scaleY) * ratio;\n }\n\n updateXY(ratio: number): void {\n this.updateX(ratio);\n this.updateY(ratio);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n this._updateFunction(ratio);\n this.target.addUpdatePositionTag();\n }\n}\n\nexport class ScaleOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n let from: Record<string, number>;\n let to: Record<string, number>;\n // 获取当前的数据\n const attrs = this.target.getFinalAttribute();\n switch (this.params?.direction) {\n case 'x':\n from = { scaleX: attrs?.scaleX ?? 1 };\n to = { scaleX: 0 };\n break;\n case 'y':\n from = { scaleY: attrs?.scaleY ?? 1 };\n to = { scaleY: 0 };\n break;\n case 'xy':\n default:\n from = { scaleX: attrs?.scaleX ?? 1, scaleY: attrs?.scaleY ?? 1 };\n to = {\n scaleX: 0,\n scaleY: 0\n };\n }\n this.props = to;\n this.propKeys = Object.keys(to);\n this.animate.reSyncProps();\n this.from = from;\n this.to = to;\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 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 }\n}\n"]}
1
+ {"version":3,"sources":["../src/custom/scale.ts"],"names":[],"mappings":";;;AACA,qDAAkD;AAMlD,MAAa,OAAQ,SAAQ,+BAAsC;IAGjE,YAAY,IAAU,EAAE,EAAQ,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAA+B;QACrG,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAID,MAAM;;QACJ,IAAI,IAA4B,CAAC;QACjC,IAAI,EAA0B,CAAC;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC9C,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC;QAE9C,QAAQ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asingType, IAnimate, IStep } from '@visactor/vrender-core';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport class ScaleIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n declare _updateFunction: (ratio: number) => void;\n\n onBind(): void {\n let from: Record<string, number>;\n let to: Record<string, number>;\n const attrs = this.target.getFinalAttribute();\n const fromAttrs = this.target.attribute ?? {};\n\n switch (this.params?.direction) {\n case 'x':\n from = { scaleX: fromAttrs.scaleX ?? 0 };\n to = { scaleX: attrs?.scaleX ?? 1 };\n this._updateFunction = this.updateX;\n break;\n case 'y':\n from = { scaleY: fromAttrs.scaleY ?? 0 };\n to = { scaleY: attrs?.scaleY ?? 1 };\n this._updateFunction = this.updateY;\n break;\n case 'xy':\n default:\n from = { scaleX: fromAttrs.scaleX ?? 0, scaleY: fromAttrs.scaleY ?? 0 };\n to = {\n scaleX: attrs?.scaleX ?? 1,\n scaleY: attrs?.scaleY ?? 1\n };\n this._updateFunction = this.updateXY;\n }\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n Object.assign(this.target.attribute, finalAttribute);\n }\n\n this.props = to;\n this.from = from;\n this.to = to;\n // 调用次数不多,可以setAttributes\n this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n updateX(ratio: number): void {\n this.target.attribute.scaleX = this.from.scaleX + (this.to.scaleX - this.from.scaleX) * ratio;\n }\n\n updateY(ratio: number): void {\n this.target.attribute.scaleY = this.from.scaleY + (this.to.scaleY - this.from.scaleY) * ratio;\n }\n\n updateXY(ratio: number): void {\n this.updateX(ratio);\n this.updateY(ratio);\n }\n\n /**\n * 删除自身属性,会直接从props等内容里删除掉\n */\n deleteSelfAttr(key: string): void {\n delete this.props[key];\n // fromProps在动画开始时才会计算,这时可能不在\n this.fromProps && delete this.fromProps[key];\n const index = this.propKeys.indexOf(key);\n if (index !== -1) {\n this.propKeys.splice(index, 1);\n }\n\n if (this.propKeys && this.propKeys.length > 1) {\n this._updateFunction = this.updateXY;\n } else if (this.propKeys[0] === 'scaleX') {\n this._updateFunction = this.updateX;\n } else if (this.propKeys[0] === 'scaleY') {\n this._updateFunction = this.updateY;\n } else {\n this._updateFunction = null;\n }\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (this._updateFunction) {\n this._updateFunction(ratio);\n this.target.addUpdatePositionTag();\n }\n }\n}\n\nexport class ScaleOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n let from: Record<string, number>;\n let to: Record<string, number>;\n // 获取当前的数据\n const attrs = this.target.attribute;\n switch (this.params?.direction) {\n case 'x':\n from = { scaleX: attrs?.scaleX ?? 1 };\n to = { scaleX: 0 };\n break;\n case 'y':\n from = { scaleY: attrs?.scaleY ?? 1 };\n to = { scaleY: 0 };\n break;\n case 'xy':\n default:\n from = { scaleX: attrs?.scaleX ?? 1, scaleY: attrs?.scaleY ?? 1 };\n to = {\n scaleX: 0,\n scaleY: 0\n };\n }\n this.props = to;\n this.from = from;\n this.to = to;\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 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 }\n}\n"]}
@@ -22,5 +22,4 @@ class RotateBySphereAnimate extends custom_animate_1.ACustomAnimate {
22
22
  }
23
23
  }
24
24
 
25
- exports.RotateBySphereAnimate = RotateBySphereAnimate;
26
- //# sourceMappingURL=sphere.js.map
25
+ exports.RotateBySphereAnimate = RotateBySphereAnimate;
@@ -1,4 +1,4 @@
1
- import type { EasingType } from '../intreface/easing';
1
+ import type { EasingType } from '@visactor/vrender-core';
2
2
  import { ACustomAnimate } from './custom-animate';
3
3
  export interface IUpdateAnimationOptions {
4
4
  diffAttrs: Record<string, any>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/custom/state.ts"],"names":[],"mappings":";;;AAEA,qDAAkD;AAclD,MAAa,KAAM,SAAQ,+BAAsC;IAG/D,YAAY,IAAU,EAAE,EAAQ,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAAgC;QACtG,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACjC,OAAO;SACR;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,yBAAyB;YACpC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YACnG,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBAEtD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;oBACjD,OAAO;iBACR;gBACD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACtC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAChC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/D,CAAC,CAAC,CAAC;QACP,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;CACF;AA5BD,sBA4BC","file":"state.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IUpdateAnimationOptions {\n diffAttrs: Record<string, any>;\n animationState: string;\n diffState: string;\n data: Record<string, any>[];\n}\n\n/**\n * 文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n */\nexport class State extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IUpdateAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n this.onStart();\n if (!this.props || !this.propKeys) {\n return;\n }\n // 应用缓动函数\n const easedRatio = this.easing(ratio);\n this.animate.interpolateUpdateFunction\n ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target)\n : this.interpolateUpdateFunctions.forEach((func, index) => {\n // 如果这个属性被屏蔽了,直接跳过\n if (!this.animate.validAttr(this.propKeys[index])) {\n return;\n }\n const key = this.propKeys[index];\n const fromValue = this.fromProps[key];\n const toValue = this.props[key];\n func(key, fromValue, toValue, easedRatio, this, this.target);\n });\n this.onUpdate(end, easedRatio, out);\n }\n}\n"]}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D,CAAC,CAAC,CAAC;QACP,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;CACF;AA5BD,sBA4BC","file":"state.js","sourcesContent":["import type { EasingType, IAnimate, IStep } from '@visactor/vrender-core';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IUpdateAnimationOptions {\n diffAttrs: Record<string, any>;\n animationState: string;\n diffState: string;\n data: Record<string, any>[];\n}\n\n/**\n * 文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n */\nexport class State extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IUpdateAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n this.onStart();\n if (!this.props || !this.propKeys) {\n return;\n }\n // 应用缓动函数\n const easedRatio = this.easing(ratio);\n this.animate.interpolateUpdateFunction\n ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target)\n : this.interpolateUpdateFunctions.forEach((func, index) => {\n // 如果这个属性被屏蔽了,直接跳过\n if (!this.animate.validAttr(this.propKeys[index])) {\n return;\n }\n const key = this.propKeys[index];\n const fromValue = this.fromProps[key];\n const toValue = this.props[key];\n func(key, fromValue, toValue, easedRatio, this, this.target);\n });\n this.onUpdate(end, easedRatio, out);\n }\n}\n"]}
@@ -0,0 +1,128 @@
1
+ import { FadeIn } from './fade';
2
+ import type { EasingType } from '@visactor/vrender-core';
3
+ import { ACustomAnimate } from './custom-animate';
4
+ export declare class StoryFadeIn extends FadeIn {
5
+ }
6
+ export interface ISlideAnimationOptions {
7
+ direction?: 'top' | 'bottom' | 'left' | 'right';
8
+ distance?: number;
9
+ fromOpacity?: number;
10
+ }
11
+ export interface IGrowAnimationOptions {
12
+ fromScale?: number;
13
+ direction?: 'x' | 'y' | 'xy';
14
+ fromOpacity?: number;
15
+ }
16
+ export interface ISpinAnimationOptions {
17
+ fromAngle?: number;
18
+ fromScale?: number;
19
+ fromOpacity?: number;
20
+ }
21
+ export declare class SlideIn extends ACustomAnimate<Record<string, number>> {
22
+ valid: boolean;
23
+ propKeys: string[];
24
+ from: Record<string, number>;
25
+ to: Record<string, number>;
26
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: ISlideAnimationOptions);
27
+ onBind(): void;
28
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
29
+ }
30
+ export declare class GrowIn extends ACustomAnimate<Record<string, number>> {
31
+ valid: boolean;
32
+ propKeys: string[];
33
+ from: Record<string, number>;
34
+ to: Record<string, number>;
35
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: IGrowAnimationOptions);
36
+ onBind(): void;
37
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
38
+ }
39
+ export declare class SpinIn extends ACustomAnimate<Record<string, number>> {
40
+ valid: boolean;
41
+ propKeys: string[];
42
+ from: Record<string, number>;
43
+ to: Record<string, number>;
44
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: ISpinAnimationOptions);
45
+ onBind(): void;
46
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
47
+ }
48
+ export interface IMoveScaleAnimationOptions {
49
+ slideDirection?: 'top' | 'bottom' | 'left' | 'right';
50
+ slideDistance?: number;
51
+ fromScale?: number;
52
+ scaleDirection?: 'x' | 'y' | 'xy';
53
+ slideRatio?: number;
54
+ fromOpacity?: number;
55
+ }
56
+ export declare class MoveScaleIn extends ACustomAnimate<any> {
57
+ valid: boolean;
58
+ private readonly slideInDuration;
59
+ private readonly growInDuration;
60
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: IMoveScaleAnimationOptions);
61
+ onBind(): void;
62
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
63
+ }
64
+ export interface IMoveRotateAnimationOptions {
65
+ slideDirection?: 'top' | 'bottom' | 'left' | 'right';
66
+ slideDistance?: number;
67
+ fromAngle?: number;
68
+ fromScale?: number;
69
+ slideRatio?: number;
70
+ fromOpacity?: number;
71
+ }
72
+ export declare class MoveRotateIn extends ACustomAnimate<any> {
73
+ valid: boolean;
74
+ private readonly slideInDuration;
75
+ private readonly spinInDuration;
76
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: IMoveRotateAnimationOptions);
77
+ onBind(): void;
78
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
79
+ }
80
+ export declare class SlideOut extends ACustomAnimate<Record<string, number>> {
81
+ valid: boolean;
82
+ propKeys: string[];
83
+ from: Record<string, number>;
84
+ to: Record<string, number>;
85
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: ISlideAnimationOptions & {
86
+ toOpacity?: number;
87
+ });
88
+ onFirstRun(): void;
89
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
90
+ }
91
+ export declare class GrowOut extends ACustomAnimate<Record<string, number>> {
92
+ valid: boolean;
93
+ propKeys: string[];
94
+ from: Record<string, number>;
95
+ to: Record<string, number>;
96
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: IGrowAnimationOptions & {
97
+ toOpacity?: number;
98
+ });
99
+ onFirstRun(): void;
100
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
101
+ }
102
+ export declare class SpinOut extends ACustomAnimate<Record<string, number>> {
103
+ valid: boolean;
104
+ propKeys: string[];
105
+ from: Record<string, number>;
106
+ to: Record<string, number>;
107
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: ISpinAnimationOptions & {
108
+ toOpacity?: number;
109
+ });
110
+ onFirstRun(): void;
111
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
112
+ }
113
+ export declare class MoveScaleOut extends ACustomAnimate<any> {
114
+ valid: boolean;
115
+ private readonly growOutDuration;
116
+ private readonly slideOutDuration;
117
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: IMoveScaleAnimationOptions);
118
+ onFirstRun(): void;
119
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
120
+ }
121
+ export declare class MoveRotateOut extends ACustomAnimate<any> {
122
+ valid: boolean;
123
+ private readonly spinOutDuration;
124
+ private readonly slideOutDuration;
125
+ constructor(from: null, to: null, duration: number, easing: EasingType, params?: IMoveRotateAnimationOptions);
126
+ onFirstRun(): void;
127
+ onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
128
+ }