@visactor/vrender-components 1.1.0-alpha.7 → 1.1.0-alpha.8

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 (66) hide show
  1. package/cjs/animation/axis-animate.js +7 -3
  2. package/cjs/animation/axis-animate.js.map +1 -1
  3. package/cjs/animation/static-truth.d.ts +2 -0
  4. package/cjs/animation/static-truth.js +25 -0
  5. package/cjs/animation/static-truth.js.map +1 -0
  6. package/cjs/axis/animate/group-transition.d.ts +2 -2
  7. package/cjs/axis/animate/group-transition.js +7 -3
  8. package/cjs/axis/animate/group-transition.js.map +1 -1
  9. package/cjs/axis/base.js +21 -25
  10. package/cjs/axis/base.js.map +1 -1
  11. package/cjs/axis/index.js +1 -2
  12. package/cjs/checkbox/index.js +2 -1
  13. package/cjs/crosshair/polygon.js +1 -2
  14. package/cjs/crosshair/rect.js +2 -1
  15. package/cjs/data-zoom/index.js +1 -2
  16. package/cjs/index.d.ts +1 -1
  17. package/cjs/index.js +1 -1
  18. package/cjs/index.js.map +1 -1
  19. package/cjs/indicator/config.js +2 -1
  20. package/cjs/label/arc.js +1 -1
  21. package/cjs/label/base.js +4 -2
  22. package/cjs/label/base.js.map +1 -1
  23. package/cjs/legend/discrete/discrete.js +13 -7
  24. package/cjs/legend/discrete/discrete.js.map +1 -1
  25. package/cjs/marker/animate/call-in.js +6 -2
  26. package/cjs/marker/animate/call-in.js.map +1 -1
  27. package/cjs/marker/animate/clip-in.js +6 -2
  28. package/cjs/marker/animate/clip-in.js.map +1 -1
  29. package/cjs/marker/animate/common.js +14 -5
  30. package/cjs/marker/animate/common.js.map +1 -1
  31. package/cjs/timeline/timeline.js +35 -12
  32. package/cjs/timeline/timeline.js.map +1 -1
  33. package/dist/index.es.js +68 -27
  34. package/es/animation/axis-animate.js +8 -3
  35. package/es/animation/axis-animate.js.map +1 -1
  36. package/es/animation/static-truth.d.ts +2 -0
  37. package/es/animation/static-truth.js +18 -0
  38. package/es/animation/static-truth.js.map +1 -0
  39. package/es/axis/animate/group-transition.d.ts +2 -2
  40. package/es/axis/animate/group-transition.js +7 -2
  41. package/es/axis/animate/group-transition.js.map +1 -1
  42. package/es/axis/base.js +22 -24
  43. package/es/axis/base.js.map +1 -1
  44. package/es/axis/index.js +1 -2
  45. package/es/checkbox/index.js +2 -1
  46. package/es/crosshair/polygon.js +1 -2
  47. package/es/crosshair/rect.js +2 -1
  48. package/es/data-zoom/index.js +1 -2
  49. package/es/index.d.ts +1 -1
  50. package/es/index.js +1 -1
  51. package/es/index.js.map +1 -1
  52. package/es/indicator/config.js +2 -1
  53. package/es/label/arc.js +1 -1
  54. package/es/label/base.js +5 -1
  55. package/es/label/base.js.map +1 -1
  56. package/es/legend/discrete/discrete.js +14 -6
  57. package/es/legend/discrete/discrete.js.map +1 -1
  58. package/es/marker/animate/call-in.js +7 -2
  59. package/es/marker/animate/call-in.js.map +1 -1
  60. package/es/marker/animate/clip-in.js +7 -2
  61. package/es/marker/animate/clip-in.js.map +1 -1
  62. package/es/marker/animate/common.js +10 -2
  63. package/es/marker/animate/common.js.map +1 -1
  64. package/es/timeline/timeline.js +36 -11
  65. package/es/timeline/timeline.js.map +1 -1
  66. package/package.json +6 -6
@@ -1,11 +1,20 @@
1
1
  "use strict";
2
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.tagFadeOut = exports.segmentFadeOut = exports.graphicFadeOut = exports.tagFadeIn = exports.segmentFadeIn = exports.graphicFadeIn = void 0;
6
+
7
+ const static_truth_1 = require("../../animation/static-truth");
8
+
3
9
  function graphicFadeIn(graphic, delay, duration, easing) {
4
10
  var _a, _b, _c, _d, _e;
5
11
  if (!graphic) return;
6
12
  null === (_a = null == graphic ? void 0 : graphic.animates) || void 0 === _a || _a.forEach((a => a.stop("end")));
7
13
  const fillOpacityConfig = null !== (_c = null === (_b = graphic.attribute) || void 0 === _b ? void 0 : _b.fillOpacity) && void 0 !== _c ? _c : 1, strokeOpacityConfig = null !== (_e = null === (_d = graphic.attribute) || void 0 === _d ? void 0 : _d.strokeOpacity) && void 0 !== _e ? _e : 1;
8
- graphic.setAttributes({
14
+ (0, static_truth_1.commitUpdateAnimationTarget)(graphic, {
15
+ fillOpacity: fillOpacityConfig,
16
+ strokeOpacity: strokeOpacityConfig
17
+ }, {
9
18
  fillOpacity: 0,
10
19
  strokeOpacity: 0
11
20
  }), graphic.animate().wait(delay).to({
@@ -25,7 +34,10 @@ function tagFadeIn(tag, delay, duration, easing) {
25
34
 
26
35
  function graphicFadeOut(graphic, delay, duration, easing) {
27
36
  var _a, _b, _c, _d;
28
- graphic && (graphic.setAttributes({
37
+ graphic && ((0, static_truth_1.commitUpdateAnimationTarget)(graphic, {
38
+ fillOpacity: 0,
39
+ strokeOpacity: 0
40
+ }, {
29
41
  fillOpacity: null !== (_b = null === (_a = graphic.attribute) || void 0 === _a ? void 0 : _a.fillOpacity) && void 0 !== _b ? _b : 1,
30
42
  strokeOpacity: null !== (_d = null === (_c = graphic.attribute) || void 0 === _c ? void 0 : _c.strokeOpacity) && void 0 !== _d ? _d : 1
31
43
  }), graphic.animate().wait(delay).to({
@@ -43,9 +55,6 @@ function tagFadeOut(tag, delay, duration, easing) {
43
55
  tag && (graphicFadeOut(tag.getTextShape(), delay, duration, easing), graphicFadeOut(tag.getBgRect(), delay, duration, easing));
44
56
  }
45
57
 
46
- Object.defineProperty(exports, "__esModule", {
47
- value: !0
48
- }), exports.tagFadeOut = exports.segmentFadeOut = exports.graphicFadeOut = exports.tagFadeIn = exports.segmentFadeIn = exports.graphicFadeIn = void 0,
49
58
  exports.graphicFadeIn = graphicFadeIn, exports.segmentFadeIn = segmentFadeIn, exports.tagFadeIn = tagFadeIn,
50
59
  exports.graphicFadeOut = graphicFadeOut, exports.segmentFadeOut = segmentFadeOut,
51
60
  exports.tagFadeOut = tagFadeOut;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/marker/animate/common.ts"],"names":[],"mappings":";;;AAKA,SA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cAAc,CAAE,OAAsB,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAGtE,cAAc,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7D,CAAC;AAdD,wCAcC;AAED,SAAgB,UAAU,CAAC,GAAQ,EAAE,KAAa,EAAE,QAAgB,EAAE,MAAkB;IACtF,IAAI,CAAC,GAAG,EAAE;QACR,OAAO;KACR;IAGD,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAG5D,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC;AAVD,gCAUC","file":"common.js","sourcesContent":["import type { EasingType, IGraphic } from '@visactor/vrender-core';\nimport type { ArcSegment, Segment } from '../../segment';\nimport type { Tag } from '../../tag';\n\n/** fade-in */\nexport function graphicFadeIn(graphic: IGraphic, delay: number, duration: number, easing: EasingType) {\n if (!graphic) {\n return;\n }\n graphic?.animates?.forEach(a => a.stop('end'));\n const fillOpacityConfig = graphic.attribute?.fillOpacity ?? 1;\n const strokeOpacityConfig = graphic.attribute?.strokeOpacity ?? 1;\n\n graphic.setAttributes({\n fillOpacity: 0,\n strokeOpacity: 0\n });\n\n graphic.animate().wait(delay).to(\n {\n fillOpacity: fillOpacityConfig,\n strokeOpacity: strokeOpacityConfig\n },\n duration,\n easing\n );\n}\n\nexport function segmentFadeIn(segment: Segment, delay: number, duration: number, easing: EasingType) {\n if (!segment) {\n return;\n }\n\n // start symbol\n graphicFadeIn(segment.startSymbol, delay, duration, easing);\n\n // line\n segment.lines.forEach(line => graphicFadeIn(line, delay, duration, easing));\n graphicFadeIn((segment as ArcSegment).line, delay, duration, easing);\n\n // end symbol\n graphicFadeIn(segment.endSymbol, delay, duration, easing);\n}\n\nexport function tagFadeIn(tag: Tag, delay: number, duration: number, easing: EasingType) {\n if (!tag) {\n return;\n }\n\n // text\n graphicFadeIn(tag.getTextShape(), delay, duration, easing);\n\n // text background\n graphicFadeIn(tag.getBgRect(), delay, duration, easing);\n}\n\n/** fade-out */\nexport function graphicFadeOut(graphic: IGraphic, delay: number, duration: number, easing: EasingType) {\n if (!graphic) {\n return;\n }\n\n graphic.setAttributes({\n fillOpacity: graphic.attribute?.fillOpacity ?? 1,\n strokeOpacity: graphic.attribute?.strokeOpacity ?? 1\n });\n\n graphic.animate().wait(delay).to({ fillOpacity: 0, strokeOpacity: 0 }, duration, easing);\n}\n\nexport function segmentFadeOut(segment: Segment | ArcSegment, delay: number, duration: number, easing: EasingType) {\n if (!segment) {\n return;\n }\n\n // start symbol\n graphicFadeOut(segment.startSymbol, delay, duration, easing);\n\n // line\n segment.lines.forEach(line => graphicFadeOut(line, delay, duration, easing));\n graphicFadeOut((segment as ArcSegment).line, delay, duration, easing);\n\n // end symbol\n graphicFadeOut(segment.endSymbol, delay, duration, easing);\n}\n\nexport function tagFadeOut(tag: Tag, delay: number, duration: number, easing: EasingType) {\n if (!tag) {\n return;\n }\n\n // text\n graphicFadeOut(tag.getTextShape(), delay, duration, easing);\n\n // text background\n graphicFadeOut(tag.getBgRect(), delay, duration, easing);\n}\n"]}
1
+ {"version":3,"sources":["../src/marker/animate/common.ts"],"names":[],"mappings":";;;AAGA,+DAA2E;AAG3E,SAAgB,aAAa,CAAC,OAAiB,EAAE,KAAa,EAAE,QAAgB,EAAE,MAAkB;;IAClG,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO;KACR;IACD,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,0CAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,MAAM,iBAAiB,GAAG,MAAA,MAAA,OAAO,CAAC,SAAS,0CAAE,WAAW,mCAAI,CAAC,CA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,CAAC,GAAQ,EAAE,KAAa,EAAE,QAAgB,EAAE,MAAkB;IACtF,IAAI,CAAC,GAAG,EAAE;QACR,OAAO;KACR;IAGD,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAG5D,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC;AAVD,gCAUC","file":"common.js","sourcesContent":["import type { EasingType, IGraphic } from '@visactor/vrender-core';\nimport type { ArcSegment, Segment } from '../../segment';\nimport type { Tag } from '../../tag';\nimport { commitUpdateAnimationTarget } from '../../animation/static-truth';\n\n/** fade-in */\nexport function graphicFadeIn(graphic: IGraphic, delay: number, duration: number, easing: EasingType) {\n if (!graphic) {\n return;\n }\n graphic?.animates?.forEach(a => a.stop('end'));\n const fillOpacityConfig = graphic.attribute?.fillOpacity ?? 1;\n const strokeOpacityConfig = graphic.attribute?.strokeOpacity ?? 1;\n\n commitUpdateAnimationTarget(\n graphic,\n {\n fillOpacity: fillOpacityConfig,\n strokeOpacity: strokeOpacityConfig\n },\n {\n fillOpacity: 0,\n strokeOpacity: 0\n }\n );\n\n graphic.animate().wait(delay).to(\n {\n fillOpacity: fillOpacityConfig,\n strokeOpacity: strokeOpacityConfig\n },\n duration,\n easing\n );\n}\n\nexport function segmentFadeIn(segment: Segment, delay: number, duration: number, easing: EasingType) {\n if (!segment) {\n return;\n }\n\n // start symbol\n graphicFadeIn(segment.startSymbol, delay, duration, easing);\n\n // line\n segment.lines.forEach(line => graphicFadeIn(line, delay, duration, easing));\n graphicFadeIn((segment as ArcSegment).line, delay, duration, easing);\n\n // end symbol\n graphicFadeIn(segment.endSymbol, delay, duration, easing);\n}\n\nexport function tagFadeIn(tag: Tag, delay: number, duration: number, easing: EasingType) {\n if (!tag) {\n return;\n }\n\n // text\n graphicFadeIn(tag.getTextShape(), delay, duration, easing);\n\n // text background\n graphicFadeIn(tag.getBgRect(), delay, duration, easing);\n}\n\n/** fade-out */\nexport function graphicFadeOut(graphic: IGraphic, delay: number, duration: number, easing: EasingType) {\n if (!graphic) {\n return;\n }\n\n commitUpdateAnimationTarget(\n graphic,\n {\n fillOpacity: 0,\n strokeOpacity: 0\n },\n {\n fillOpacity: graphic.attribute?.fillOpacity ?? 1,\n strokeOpacity: graphic.attribute?.strokeOpacity ?? 1\n }\n );\n\n graphic.animate().wait(delay).to({ fillOpacity: 0, strokeOpacity: 0 }, duration, easing);\n}\n\nexport function segmentFadeOut(segment: Segment | ArcSegment, delay: number, duration: number, easing: EasingType) {\n if (!segment) {\n return;\n }\n\n // start symbol\n graphicFadeOut(segment.startSymbol, delay, duration, easing);\n\n // line\n segment.lines.forEach(line => graphicFadeOut(line, delay, duration, easing));\n graphicFadeOut((segment as ArcSegment).line, delay, duration, easing);\n\n // end symbol\n graphicFadeOut(segment.endSymbol, delay, duration, easing);\n}\n\nexport function tagFadeOut(tag: Tag, delay: number, duration: number, easing: EasingType) {\n if (!tag) {\n return;\n }\n\n // text\n graphicFadeOut(tag.getTextShape(), delay, duration, easing);\n\n // text background\n graphicFadeOut(tag.getBgRect(), delay, duration, easing);\n}\n"]}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.Timeline = void 0;
6
6
 
7
- const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), register_1 = require("./register");
7
+ const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), register_1 = require("./register"), static_truth_1 = require("../animation/static-truth");
8
8
 
9
9
  (0, register_1.loadTimelineComponent)();
10
10
 
@@ -65,38 +65,57 @@ class Timeline extends base_1.AbstractComponent {
65
65
  setActive(labelGroup, activeLabelStyle), setActive(symbolGroup, activeSymbolStyle);
66
66
  }
67
67
  appearAnimate(animateConfig) {
68
+ var _a;
68
69
  const {duration: duration = 1e3, easing: easing = "quadOut"} = animateConfig, {activeLabelStyle: activeLabelStyle, activeSymbolStyle: activeSymbolStyle} = this.attribute, percent = duration / 1e3, lineDuration = 500 * percent, activeLineDuration = 200 * percent, perSymbolDuration = 100 * percent, perSymbolNormalDuration = 90 * percent, symbolDelay = 100 * percent, symbolNormalDelay = 600 * percent;
69
- if (this._line && (this._line.setAttributes({
70
+ if (this._line && ((0, static_truth_1.commitUpdateAnimationTarget)(this._line, {
71
+ clipRange: 1
72
+ }, {
70
73
  clipRange: 0
71
74
  }), this._line.animate().to({
72
75
  clipRange: 1
73
- }, lineDuration, easing)), this._activeLine && (this._activeLine.setAttributes({
74
- opacity: 0
75
- }), this._activeLine.animate().wait(500).to({
76
- opacity: 1
77
- }, activeLineDuration, easing)), this._symbolGroup) {
76
+ }, lineDuration, easing)), this._activeLine) {
77
+ const opacity = null !== (_a = this._activeLine.attribute.opacity) && void 0 !== _a ? _a : 1;
78
+ (0, static_truth_1.commitUpdateAnimationTarget)(this._activeLine, {
79
+ opacity: opacity
80
+ }, {
81
+ opacity: 0
82
+ }), this._activeLine.animate().wait(500).to({
83
+ opacity: opacity
84
+ }, activeLineDuration, easing);
85
+ }
86
+ if (this._symbolGroup) {
78
87
  const size = this._symbolGroup.count - 1, delay = percent * (1 === size ? 0 : 400 / (size - 1)), delayNormal = percent * (1 === size ? 0 : 240 / (size - 1));
79
88
  this._symbolGroup.forEachChildren(((symbol, i) => {
89
+ var _a;
80
90
  const originAttrs = {};
81
91
  Object.keys(activeSymbolStyle).forEach((k => {
82
92
  originAttrs[k] = symbol.attribute[k];
83
- })), symbol.setAttributes({
93
+ }));
94
+ const opacity = null !== (_a = symbol.attribute.opacity) && void 0 !== _a ? _a : 1;
95
+ (0, static_truth_1.commitUpdateAnimationTarget)(symbol, {
96
+ opacity: opacity
97
+ }, {
84
98
  opacity: 0
85
99
  }), symbol.animate().wait(symbolDelay + delay * i).to({
86
- opacity: 1
100
+ opacity: opacity
87
101
  }, perSymbolDuration, easing), symbol.animate().wait(symbolNormalDelay + delayNormal * i).to(Object.assign({}, activeSymbolStyle), perSymbolNormalDuration, easing).to(Object.assign({}, originAttrs), perSymbolNormalDuration, easing);
88
102
  }));
89
103
  }
90
104
  if (this._labelGroup) {
91
105
  const size = this._labelGroup.count - 1, delay = percent * (1 === size ? 0 : 400 / (size - 1)), delayNormal = percent * (1 === size ? 0 : 240 / (size - 1));
92
106
  this._labelGroup.forEachChildren(((label, i) => {
107
+ var _a;
93
108
  const originAttrs = {};
94
109
  Object.keys(activeLabelStyle).forEach((k => {
95
110
  originAttrs[k] = label.attribute[k];
96
- })), label.setAttributes({
111
+ }));
112
+ const opacity = null !== (_a = label.attribute.opacity) && void 0 !== _a ? _a : 1;
113
+ (0, static_truth_1.commitUpdateAnimationTarget)(label, {
114
+ opacity: opacity
115
+ }, {
97
116
  opacity: 0
98
117
  }), label.animate().wait(symbolDelay + delay * i).to({
99
- opacity: 1
118
+ opacity: opacity
100
119
  }, perSymbolDuration, easing), label.animate().wait(symbolNormalDelay + delayNormal * i).to(Object.assign({
101
120
  dy: 10
102
121
  }, activeLabelStyle), perSymbolNormalDuration, easing).to(Object.assign({
@@ -123,7 +142,11 @@ class Timeline extends base_1.AbstractComponent {
123
142
  const nextClipRange = flag > 0 ? this._timesPercent[i] || 1 : this._timesPercent[i - 1] || 0;
124
143
  if (animation) {
125
144
  const {duration: duration = 1e3, easing: easing = "quadOut"} = animateConfig;
126
- this.animate().to({
145
+ (0, static_truth_1.commitUpdateAnimationTarget)(this, {
146
+ clipRange: nextClipRange
147
+ }, {
148
+ clipRange: clipRange
149
+ }), this.animate().to({
127
150
  clipRange: nextClipRange
128
151
  }, duration, easing);
129
152
  } else this.setAttributes({
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/timeline/timeline.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAClD,uCAAiD;AACjD,yCAAmD;AAMnD,IAAA,gCAAqB,GAAE,CAAC;AAExB,MAAa,QAAS,SAAQ,wBAA0C;IA6CtE,YAAY,UAAyB,EAAE,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,IAAI,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;SAClD;IACH,CAAC;IAED,OAAO,CAAC,aAAqD;QAC3D,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;IAC9B,CAAC;IAED,QAAQ,CAAC,aAAqD;QAC5D,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;IAC/B,CAAC;;AAxSH,4BAySC;AAhSQ,0BAAiB,GAA2B;IACjD,UAAU,EAAE,EAAE;IACd,eAAe,EAAE,cAAc;IAC/B,SAAS,EAAE,IAAI;IACf,WAAW,EAAE;QACX,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,EAAE;QACR,UAAU,EAAE,QAAQ;KACrB;IACD,iBAAiB,EAAE;QACjB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,EAAE;KACT;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,OAAO;QACf,SAAS,EAAE,CAAC;KACb;IACD,eAAe,EAAE;QACf,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,CAAC;KACb;IACD,UAAU,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,OAAO;QACb,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,KAAK;KACpB;IACD,gBAAgB,EAAE;QAChB,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,QAAQ;KACf;IACD,SAAS,EAAE,CAAC;CACb,CAAC","file":"timeline.js","sourcesContent":["import { isArray, merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { loadTimelineComponent } from './register';\nimport type { TimelineAttrs } from './type';\nimport type { ComponentOptions } from '../interface';\nimport { getTheme, type IGraphicAttribute, type IGroup, type ILine, type IText } from '@visactor/vrender-core';\nimport type { ISymbol } from '@visactor/vrender-core';\n\nloadTimelineComponent();\n\nexport class Timeline extends AbstractComponent<Required<TimelineAttrs>> {\n name = 'timeline';\n\n private _line?: ILine;\n private _activeLine?: ILine;\n private _symbolGroup?: IGroup;\n private _labelGroup?: IGroup;\n private _timesPercent?: number[];\n\n static defaultAttributes: Partial<TimelineAttrs> = {\n labelSpace: 10,\n pointLayoutMode: 'space-around',\n animation: true,\n symbolStyle: {\n fill: 'black',\n size: 12,\n symbolType: 'circle'\n },\n activeSymbolStyle: {\n fill: 'orange',\n size: 16\n },\n lineStyle: {\n lineDash: [2, 2],\n lineCap: 'butt',\n stroke: 'black',\n lineWidth: 2\n },\n activeLineStyle: {\n stroke: 'orange',\n lineWidth: 4\n },\n labelStyle: {\n fontSize: 12,\n fill: 'black',\n textAlign: 'center',\n textBaseline: 'top'\n },\n activeLabelStyle: {\n fontSize: 14,\n fill: 'orange'\n },\n clipRange: 0\n };\n\n constructor(attributes: TimelineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Timeline.defaultAttributes, attributes));\n }\n\n protected render(): void {\n const {\n width,\n lineStyle,\n activeLineStyle,\n symbolStyle,\n activeSymbolStyle,\n labelStyle,\n activeLabelStyle,\n times,\n pointLayoutMode,\n labelSpace,\n clipRange,\n animation\n } = this.attribute;\n\n if (!(times && times.length)) {\n return;\n }\n\n // 计算线段中心的y位置,考虑线宽和symbol宽度\n const symbolHeight = (isArray(symbolStyle.size) ? symbolStyle.size[1] : symbolStyle.size) || 0;\n const activeSymbolHeight =\n (isArray(activeSymbolStyle.size) ? activeSymbolStyle.size[1] : activeSymbolStyle.size) || 0;\n const lineSymbolHeight = Math.max(\n lineStyle.lineWidth || 0,\n activeLineStyle.lineWidth || 0,\n symbolHeight,\n activeSymbolHeight\n );\n const lineY = lineSymbolHeight / 2;\n const lineAttr = {\n y: lineY,\n points: [\n { x: 0, y: 0 },\n { x: width, y: 0 }\n ]\n };\n this._line = this.createOrUpdateChild(\n 'line-axes',\n {\n ...lineStyle,\n ...lineAttr\n },\n 'line'\n ) as ILine;\n this._activeLine = this.createOrUpdateChild(\n 'active-line-axes',\n {\n ...activeLineStyle,\n ...lineAttr,\n clipRange\n },\n 'line'\n ) as ILine;\n\n const activeWidth = width * clipRange;\n\n const symbolGroup = this.createOrUpdateChild(\n 'symbol-group',\n {\n y: lineY\n },\n 'group'\n ) as IGroup;\n const symbolSpace =\n times.length === 1\n ? width\n : pointLayoutMode === 'space-between'\n ? width / (times.length - 1)\n : width / times.length;\n const symbolStartX = pointLayoutMode === 'space-between' ? 0 : symbolSpace / 2;\n this._timesPercent = times.map((_, i) => (symbolStartX + symbolSpace * i) / width);\n\n times.forEach((item, i) => {\n const x = this._timesPercent[i] * width;\n symbolGroup.createOrUpdateChild(\n item.label,\n {\n ...symbolStyle,\n x\n },\n 'symbol'\n );\n });\n this._symbolGroup = symbolGroup;\n\n const labelY = lineSymbolHeight + labelSpace;\n const labelGroup = this.createOrUpdateChild(\n 'label-group',\n {\n y: labelY\n },\n 'group'\n ) as IGroup;\n\n times.forEach((item, i) => {\n const x = this._timesPercent[i] * width;\n labelGroup.createOrUpdateChild(\n item.label,\n {\n ...labelStyle,\n x,\n text: item.label\n },\n 'text'\n );\n });\n this._labelGroup = labelGroup;\n\n const setActive = (group: IGroup, activeStyle: Partial<IGraphicAttribute>) => {\n group.forEachChildren((label: IText) => {\n if (label.currentStates) {\n const currentStates = label.currentStates;\n label.clearStates();\n label.useStates(currentStates, false);\n }\n label.states = {\n active: activeStyle\n };\n if (label.attribute.x <= activeWidth) {\n label.useStates(['active'], animation);\n }\n });\n };\n\n setActive(labelGroup, activeLabelStyle);\n setActive(symbolGroup, activeSymbolStyle);\n }\n\n appearAnimate(animateConfig: { duration?: number; easing?: string }) {\n // 基准时间,line[0, 500], point[100, 600] 100 onebyone, pointNormal[600, 1000] 90+90 onebyone, activeLine[500, 700]\n // line和activeLine的clipRange\n const { duration = 1000, easing = 'quadOut' } = animateConfig;\n const { activeLabelStyle, activeSymbolStyle } = this.attribute;\n const percent = duration / 1000;\n const lineDuration = percent * 500;\n const activeLineDuration = percent * 200;\n const perSymbolDuration = percent * 100;\n const perSymbolNormalDuration = percent * 90;\n const symbolDelay = percent * 100;\n const symbolNormalDelay = percent * 600;\n if (this._line) {\n this._line.setAttributes({ clipRange: 0 });\n this._line.animate().to({ clipRange: 1 }, lineDuration, easing as any);\n }\n if (this._activeLine) {\n this._activeLine.setAttributes({ opacity: 0 });\n this._activeLine\n .animate()\n .wait(500)\n .to({ opacity: 1 }, activeLineDuration, easing as any);\n }\n if (this._symbolGroup) {\n const size = this._symbolGroup.count - 1;\n const delay = percent * (size === 1 ? 0 : (500 - 100) / (size - 1));\n const delayNormal = percent * (size === 1 ? 0 : (400 - 160) / (size - 1));\n this._symbolGroup.forEachChildren((symbol: ISymbol, i) => {\n const originAttrs: Record<string, any> = {};\n Object.keys(activeSymbolStyle).forEach(k => {\n originAttrs[k] = (symbol.attribute as any)[k];\n });\n\n symbol.setAttributes({ opacity: 0 });\n symbol\n .animate()\n .wait(symbolDelay + delay * i)\n .to({ opacity: 1 }, perSymbolDuration, easing as any);\n symbol\n .animate()\n .wait(symbolNormalDelay + delayNormal * i)\n .to({ ...activeSymbolStyle }, perSymbolNormalDuration, easing as any)\n .to({ ...originAttrs }, perSymbolNormalDuration, easing as any);\n });\n }\n if (this._labelGroup) {\n const size = this._labelGroup.count - 1;\n const delay = percent * (size === 1 ? 0 : (500 - 100) / (size - 1));\n const delayNormal = percent * (size === 1 ? 0 : (400 - 160) / (size - 1));\n this._labelGroup.forEachChildren((label: IText, i) => {\n const originAttrs: Record<string, any> = {};\n Object.keys(activeLabelStyle).forEach(k => {\n originAttrs[k] = (label.attribute as any)[k];\n });\n label.setAttributes({ opacity: 0 });\n label\n .animate()\n .wait(symbolDelay + delay * i)\n .to({ opacity: 1 }, perSymbolDuration, easing as any);\n label\n .animate()\n .wait(symbolNormalDelay + delayNormal * i)\n .to({ dy: 10, ...activeLabelStyle }, perSymbolNormalDuration, easing as any)\n .to({ dy: 0, ...originAttrs }, perSymbolNormalDuration, easing as any);\n });\n }\n }\n\n goto(flag: 1 | -1, animateConfig: { duration?: number; easing?: string }) {\n let { clipRange } = this.attribute;\n const { animation } = this.attribute;\n\n // 合法性判断\n if (flag > 0) {\n if (clipRange >= 1) {\n return;\n } else if (clipRange < 0) {\n clipRange = 0;\n }\n } else {\n if (clipRange <= 0) {\n return;\n } else if (clipRange > 1) {\n clipRange = 1;\n }\n }\n\n if (clipRange !== this.attribute.clipRange) {\n this.setAttributes({ clipRange });\n }\n\n // 判断区间\n let i = 0;\n for (; i < this._timesPercent.length; i++) {\n if (clipRange < this._timesPercent[i]) {\n break;\n }\n }\n\n const nextClipRange = flag > 0 ? this._timesPercent[i] || 1 : this._timesPercent[i - 1] || 0;\n if (animation) {\n const { duration = 1000, easing = 'quadOut' } = animateConfig;\n // const actDuration =\n // (Math.abs(nextClipRange - clipRange) / ((this._timesPercent[i] ?? 1) - (this._timesPercent[i - 1] ?? 0))) *\n // duration;\n this.animate().to({ clipRange: nextClipRange }, duration, easing as any);\n } else {\n this.setAttributes({ clipRange: nextClipRange });\n }\n }\n\n forward(animateConfig: { duration?: number; easing?: string }) {\n this.goto(1, animateConfig);\n }\n\n backward(animateConfig: { duration?: number; easing?: string }) {\n this.goto(-1, animateConfig);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/timeline/timeline.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAClD,uCAAiD;AACjD,yCAAmD;AAInD,4DAAwE;AAExE,IAAA,gCAAqB,GAAE,CAAC;AAExB,MAAa,QAAS,SAAQ,wBAA0C;IA6CtE,YAAY,UAAyB,EAAE,OAA0B;QAC/D,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;Q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ACf;IACD,SAAS,EAAE,CAAC;CACb,CAAC","file":"timeline.js","sourcesContent":["import { isArray, merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { loadTimelineComponent } from './register';\nimport type { TimelineAttrs } from './type';\nimport type { ComponentOptions } from '../interface';\nimport type { IGraphicAttribute, IGroup, ILine, ISymbol, IText } from '@visactor/vrender-core';\nimport { commitUpdateAnimationTarget } from '../animation/static-truth';\n\nloadTimelineComponent();\n\nexport class Timeline extends AbstractComponent<Required<TimelineAttrs>> {\n name = 'timeline';\n\n private _line?: ILine;\n private _activeLine?: ILine;\n private _symbolGroup?: IGroup;\n private _labelGroup?: IGroup;\n private _timesPercent?: number[];\n\n static defaultAttributes: Partial<TimelineAttrs> = {\n labelSpace: 10,\n pointLayoutMode: 'space-around',\n animation: true,\n symbolStyle: {\n fill: 'black',\n size: 12,\n symbolType: 'circle'\n },\n activeSymbolStyle: {\n fill: 'orange',\n size: 16\n },\n lineStyle: {\n lineDash: [2, 2],\n lineCap: 'butt',\n stroke: 'black',\n lineWidth: 2\n },\n activeLineStyle: {\n stroke: 'orange',\n lineWidth: 4\n },\n labelStyle: {\n fontSize: 12,\n fill: 'black',\n textAlign: 'center',\n textBaseline: 'top'\n },\n activeLabelStyle: {\n fontSize: 14,\n fill: 'orange'\n },\n clipRange: 0\n };\n\n constructor(attributes: TimelineAttrs, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Timeline.defaultAttributes, attributes));\n }\n\n protected render(): void {\n const {\n width,\n lineStyle,\n activeLineStyle,\n symbolStyle,\n activeSymbolStyle,\n labelStyle,\n activeLabelStyle,\n times,\n pointLayoutMode,\n labelSpace,\n clipRange,\n animation\n } = this.attribute;\n\n if (!(times && times.length)) {\n return;\n }\n\n // 计算线段中心的y位置,考虑线宽和symbol宽度\n const symbolHeight = (isArray(symbolStyle.size) ? symbolStyle.size[1] : symbolStyle.size) || 0;\n const activeSymbolHeight =\n (isArray(activeSymbolStyle.size) ? activeSymbolStyle.size[1] : activeSymbolStyle.size) || 0;\n const lineSymbolHeight = Math.max(\n lineStyle.lineWidth || 0,\n activeLineStyle.lineWidth || 0,\n symbolHeight,\n activeSymbolHeight\n );\n const lineY = lineSymbolHeight / 2;\n const lineAttr = {\n y: lineY,\n points: [\n { x: 0, y: 0 },\n { x: width, y: 0 }\n ]\n };\n this._line = this.createOrUpdateChild(\n 'line-axes',\n {\n ...lineStyle,\n ...lineAttr\n },\n 'line'\n ) as ILine;\n this._activeLine = this.createOrUpdateChild(\n 'active-line-axes',\n {\n ...activeLineStyle,\n ...lineAttr,\n clipRange\n },\n 'line'\n ) as ILine;\n\n const activeWidth = width * clipRange;\n\n const symbolGroup = this.createOrUpdateChild(\n 'symbol-group',\n {\n y: lineY\n },\n 'group'\n ) as IGroup;\n const symbolSpace =\n times.length === 1\n ? width\n : pointLayoutMode === 'space-between'\n ? width / (times.length - 1)\n : width / times.length;\n const symbolStartX = pointLayoutMode === 'space-between' ? 0 : symbolSpace / 2;\n this._timesPercent = times.map((_, i) => (symbolStartX + symbolSpace * i) / width);\n\n times.forEach((item, i) => {\n const x = this._timesPercent[i] * width;\n symbolGroup.createOrUpdateChild(\n item.label,\n {\n ...symbolStyle,\n x\n },\n 'symbol'\n );\n });\n this._symbolGroup = symbolGroup;\n\n const labelY = lineSymbolHeight + labelSpace;\n const labelGroup = this.createOrUpdateChild(\n 'label-group',\n {\n y: labelY\n },\n 'group'\n ) as IGroup;\n\n times.forEach((item, i) => {\n const x = this._timesPercent[i] * width;\n labelGroup.createOrUpdateChild(\n item.label,\n {\n ...labelStyle,\n x,\n text: item.label\n },\n 'text'\n );\n });\n this._labelGroup = labelGroup;\n\n const setActive = (group: IGroup, activeStyle: Partial<IGraphicAttribute>) => {\n group.forEachChildren((label: IText) => {\n if (label.currentStates) {\n const currentStates = label.currentStates;\n label.clearStates();\n label.useStates(currentStates, false);\n }\n label.states = {\n active: activeStyle\n };\n if (label.attribute.x <= activeWidth) {\n label.useStates(['active'], animation);\n }\n });\n };\n\n setActive(labelGroup, activeLabelStyle);\n setActive(symbolGroup, activeSymbolStyle);\n }\n\n appearAnimate(animateConfig: { duration?: number; easing?: string }) {\n // 基准时间,line[0, 500], point[100, 600] 100 onebyone, pointNormal[600, 1000] 90+90 onebyone, activeLine[500, 700]\n // line和activeLine的clipRange\n const { duration = 1000, easing = 'quadOut' } = animateConfig;\n const { activeLabelStyle, activeSymbolStyle } = this.attribute;\n const percent = duration / 1000;\n const lineDuration = percent * 500;\n const activeLineDuration = percent * 200;\n const perSymbolDuration = percent * 100;\n const perSymbolNormalDuration = percent * 90;\n const symbolDelay = percent * 100;\n const symbolNormalDelay = percent * 600;\n if (this._line) {\n commitUpdateAnimationTarget(this._line, { clipRange: 1 }, { clipRange: 0 });\n this._line.animate().to({ clipRange: 1 }, lineDuration, easing as any);\n }\n if (this._activeLine) {\n const opacity = this._activeLine.attribute.opacity ?? 1;\n commitUpdateAnimationTarget(this._activeLine, { opacity }, { opacity: 0 });\n this._activeLine\n .animate()\n .wait(500)\n .to({ opacity }, activeLineDuration, easing as any);\n }\n if (this._symbolGroup) {\n const size = this._symbolGroup.count - 1;\n const delay = percent * (size === 1 ? 0 : (500 - 100) / (size - 1));\n const delayNormal = percent * (size === 1 ? 0 : (400 - 160) / (size - 1));\n this._symbolGroup.forEachChildren((symbol: ISymbol, i) => {\n const originAttrs: Record<string, any> = {};\n Object.keys(activeSymbolStyle).forEach(k => {\n originAttrs[k] = (symbol.attribute as any)[k];\n });\n\n const opacity = symbol.attribute.opacity ?? 1;\n commitUpdateAnimationTarget(symbol, { opacity }, { opacity: 0 });\n symbol\n .animate()\n .wait(symbolDelay + delay * i)\n .to({ opacity }, perSymbolDuration, easing as any);\n symbol\n .animate()\n .wait(symbolNormalDelay + delayNormal * i)\n .to({ ...activeSymbolStyle }, perSymbolNormalDuration, easing as any)\n .to({ ...originAttrs }, perSymbolNormalDuration, easing as any);\n });\n }\n if (this._labelGroup) {\n const size = this._labelGroup.count - 1;\n const delay = percent * (size === 1 ? 0 : (500 - 100) / (size - 1));\n const delayNormal = percent * (size === 1 ? 0 : (400 - 160) / (size - 1));\n this._labelGroup.forEachChildren((label: IText, i) => {\n const originAttrs: Record<string, any> = {};\n Object.keys(activeLabelStyle).forEach(k => {\n originAttrs[k] = (label.attribute as any)[k];\n });\n const opacity = label.attribute.opacity ?? 1;\n commitUpdateAnimationTarget(label, { opacity }, { opacity: 0 });\n label\n .animate()\n .wait(symbolDelay + delay * i)\n .to({ opacity }, perSymbolDuration, easing as any);\n label\n .animate()\n .wait(symbolNormalDelay + delayNormal * i)\n .to({ dy: 10, ...activeLabelStyle }, perSymbolNormalDuration, easing as any)\n .to({ dy: 0, ...originAttrs }, perSymbolNormalDuration, easing as any);\n });\n }\n }\n\n goto(flag: 1 | -1, animateConfig: { duration?: number; easing?: string }) {\n let { clipRange } = this.attribute;\n const { animation } = this.attribute;\n\n // 合法性判断\n if (flag > 0) {\n if (clipRange >= 1) {\n return;\n } else if (clipRange < 0) {\n clipRange = 0;\n }\n } else {\n if (clipRange <= 0) {\n return;\n } else if (clipRange > 1) {\n clipRange = 1;\n }\n }\n\n if (clipRange !== this.attribute.clipRange) {\n this.setAttributes({ clipRange });\n }\n\n // 判断区间\n let i = 0;\n for (; i < this._timesPercent.length; i++) {\n if (clipRange < this._timesPercent[i]) {\n break;\n }\n }\n\n const nextClipRange = flag > 0 ? this._timesPercent[i] || 1 : this._timesPercent[i - 1] || 0;\n if (animation) {\n const { duration = 1000, easing = 'quadOut' } = animateConfig;\n // const actDuration =\n // (Math.abs(nextClipRange - clipRange) / ((this._timesPercent[i] ?? 1) - (this._timesPercent[i - 1] ?? 0))) *\n // duration;\n commitUpdateAnimationTarget(this as any, { clipRange: nextClipRange }, { clipRange });\n this.animate().to({ clipRange: nextClipRange }, duration, easing as any);\n } else {\n this.setAttributes({ clipRange: nextClipRange });\n }\n }\n\n forward(animateConfig: { duration?: number; easing?: string }) {\n this.goto(1, animateConfig);\n }\n\n backward(animateConfig: { duration?: number; easing?: string }) {\n this.goto(-1, animateConfig);\n }\n}\n"]}
package/dist/index.es.js CHANGED
@@ -18330,6 +18330,26 @@ class AnimateComponent extends AbstractComponent {
18330
18330
  }
18331
18331
  }
18332
18332
 
18333
+ function commitUpdateAnimationTarget(graphic, targetAttrs, startAttrs) {
18334
+ var _a, _b, _c, _d;
18335
+ if (!graphic || !targetAttrs) {
18336
+ return;
18337
+ }
18338
+ const committedTargetAttrs = cloneDeep(targetAttrs);
18339
+ const transientStartAttrs = cloneDeep(startAttrs !== null && startAttrs !== void 0 ? startAttrs : graphic.attribute);
18340
+ graphic.setAttributes(committedTargetAttrs);
18341
+ const baseAttributes = graphic.baseAttributes;
18342
+ if (baseAttributes && typeof baseAttributes === 'object') {
18343
+ Object.keys(committedTargetAttrs).forEach(key => {
18344
+ baseAttributes[key] = cloneDeep(committedTargetAttrs[key]);
18345
+ });
18346
+ }
18347
+ (_b = (_a = graphic).setFinalAttributes) === null || _b === void 0 ? void 0 : _b.call(_a, committedTargetAttrs);
18348
+ (_d = (_c = graphic).setAttributesAndPreventAnimate) === null || _d === void 0 ? void 0 : _d.call(_c, transientStartAttrs, false, {
18349
+ type: AttributeUpdateType.ANIMATE_BIND
18350
+ });
18351
+ }
18352
+
18333
18353
  const DefaultAxisAnimation = {
18334
18354
  type: 'default',
18335
18355
  duration: 300,
@@ -18731,11 +18751,10 @@ class AxisBase extends AnimateComponent {
18731
18751
  var _a;
18732
18752
  if (el.type !== 'group' && el.id) {
18733
18753
  const oldEl = prevInnerView[el.id];
18734
- el.setFinalAttributes(el.attribute);
18735
18754
  if (oldEl) {
18736
18755
  oldEl.release();
18737
- const oldAttrs = oldEl.attribute;
18738
- const finalAttrs = el.getFinalAttribute();
18756
+ const oldAttrs = cloneDeep(oldEl.attribute);
18757
+ const finalAttrs = cloneDeep(el.attribute);
18739
18758
  const diffAttrs = diff(oldAttrs, finalAttrs);
18740
18759
  let hasDiff = Object.keys(diffAttrs).length > 0;
18741
18760
  if ('opacity' in oldAttrs && finalAttrs.opacity !== oldAttrs.opacity) {
@@ -18746,10 +18765,9 @@ class AxisBase extends AnimateComponent {
18746
18765
  this._newElementAttrMap[el.id] = {
18747
18766
  state: 'update',
18748
18767
  node: el,
18749
- attrs: el.attribute
18768
+ attrs: finalAttrs
18750
18769
  };
18751
- const oldAttrs = oldEl.attribute;
18752
- el.setAttributes(oldAttrs);
18770
+ commitUpdateAnimationTarget(el, finalAttrs, oldAttrs);
18753
18771
  el.applyAnimationState(['update'], [
18754
18772
  {
18755
18773
  name: 'update',
@@ -20932,7 +20950,7 @@ class AxisEnter extends AComponentAnimate {
20932
20950
  const point = getTickCoord(oldValue);
20933
20951
  const newX = this.target.attribute.x;
20934
20952
  const newY = this.target.attribute.y;
20935
- this.target.setAttributes({ x: point.x, y: point.y });
20953
+ commitUpdateAnimationTarget(this.target, { x: newX, y: newY }, { x: point.x, y: point.y });
20936
20954
  animator.animate(this.target, {
20937
20955
  type: 'to',
20938
20956
  to: { x: newX, y: newY },
@@ -20955,7 +20973,8 @@ class AxisUpdate extends AComponentAnimate {
20955
20973
  this._animator = animator;
20956
20974
  const duration = this.duration;
20957
20975
  const easing = this.easing;
20958
- const { config, diffAttrs } = this.params;
20976
+ const { diffAttrs } = this.params;
20977
+ commitUpdateAnimationTarget(this.target, Object.assign({}, diffAttrs));
20959
20978
  animator.animate(this.target, {
20960
20979
  type: 'to',
20961
20980
  to: Object.assign({}, diffAttrs),
@@ -22002,6 +22021,7 @@ class GroupTransition extends ACustomAnimate {
22002
22021
  this.mode = AnimateMode.NORMAL;
22003
22022
  }
22004
22023
  onBind() {
22024
+ this._started = false;
22005
22025
  const currentInnerView = this.target.getInnerView();
22006
22026
  const prevInnerView = this.target.getPrevInnerView();
22007
22027
  if (!prevInnerView) {
@@ -22020,7 +22040,7 @@ class GroupTransition extends ACustomAnimate {
22020
22040
  node: el,
22021
22041
  attrs: Object.assign(Object.assign({}, newProps), { opacity: (_a = newProps.opacity) !== null && _a !== void 0 ? _a : 1, fillOpacity: (_b = newProps.fillOpacity) !== null && _b !== void 0 ? _b : 1, strokeOpacity: (_c = newProps.strokeOpacity) !== null && _c !== void 0 ? _c : 1 })
22022
22042
  };
22023
- el.setAttributes(oldEl.attribute);
22043
+ commitUpdateAnimationTarget(el, this._newElementAttrMap[el.id].attrs, cloneDeep(oldEl.attribute));
22024
22044
  }
22025
22045
  }
22026
22046
  else {
@@ -22034,7 +22054,7 @@ class GroupTransition extends ACustomAnimate {
22034
22054
  node: el,
22035
22055
  attrs: finalOpacityAttrs
22036
22056
  };
22037
- el.setAttributes({
22057
+ commitUpdateAnimationTarget(el, finalOpacityAttrs, {
22038
22058
  opacity: 0,
22039
22059
  fillOpacity: 0,
22040
22060
  strokeOpacity: 0
@@ -22044,6 +22064,10 @@ class GroupTransition extends ACustomAnimate {
22044
22064
  });
22045
22065
  }
22046
22066
  onStart() {
22067
+ if (this._started) {
22068
+ return;
22069
+ }
22070
+ this._started = true;
22047
22071
  let duration = this.duration;
22048
22072
  let easing = this.easing;
22049
22073
  this._newElementAttrMap &&
@@ -24159,6 +24183,8 @@ class LabelBase extends AnimateComponent {
24159
24183
  _runUpdateAnimation(prevLabel, currentLabel) {
24160
24184
  const { text: prevText, labelLine: prevLabelLine } = prevLabel;
24161
24185
  const { text: curText, labelLine: curLabelLine } = currentLabel;
24186
+ commitUpdateAnimationTarget(prevText, curText === null || curText === void 0 ? void 0 : curText.attribute);
24187
+ commitUpdateAnimationTarget(prevLabelLine, curLabelLine === null || curLabelLine === void 0 ? void 0 : curLabelLine.attribute);
24162
24188
  prevText.applyAnimationState(['update'], [
24163
24189
  {
24164
24190
  name: 'update',
@@ -24190,7 +24216,7 @@ class LabelBase extends AnimateComponent {
24190
24216
  this.runEnterAnimation(text, labelLine);
24191
24217
  }
24192
24218
  _updateLabel(prevLabel, currentLabel) {
24193
- const { text: prevText, labelLine: prevLabelLine } = prevLabel;
24219
+ const { labelLine: prevLabelLine } = prevLabel;
24194
24220
  const { text: curText, labelLine: curLabelLine } = currentLabel;
24195
24221
  if (this._enableAnimation === false || this._animationConfig.update === false) {
24196
24222
  prevLabel.text.setAttributes(curText.attribute);
@@ -27086,7 +27112,10 @@ function graphicFadeIn(graphic, delay, duration, easing) {
27086
27112
  (_a = graphic === null || graphic === void 0 ? void 0 : graphic.animates) === null || _a === void 0 ? void 0 : _a.forEach(a => a.stop('end'));
27087
27113
  const fillOpacityConfig = (_c = (_b = graphic.attribute) === null || _b === void 0 ? void 0 : _b.fillOpacity) !== null && _c !== void 0 ? _c : 1;
27088
27114
  const strokeOpacityConfig = (_e = (_d = graphic.attribute) === null || _d === void 0 ? void 0 : _d.strokeOpacity) !== null && _e !== void 0 ? _e : 1;
27089
- graphic.setAttributes({
27115
+ commitUpdateAnimationTarget(graphic, {
27116
+ fillOpacity: fillOpacityConfig,
27117
+ strokeOpacity: strokeOpacityConfig
27118
+ }, {
27090
27119
  fillOpacity: 0,
27091
27120
  strokeOpacity: 0
27092
27121
  });
@@ -27116,7 +27145,10 @@ function graphicFadeOut(graphic, delay, duration, easing) {
27116
27145
  if (!graphic) {
27117
27146
  return;
27118
27147
  }
27119
- graphic.setAttributes({
27148
+ commitUpdateAnimationTarget(graphic, {
27149
+ fillOpacity: 0,
27150
+ strokeOpacity: 0
27151
+ }, {
27120
27152
  fillOpacity: (_b = (_a = graphic.attribute) === null || _a === void 0 ? void 0 : _a.fillOpacity) !== null && _b !== void 0 ? _b : 1,
27121
27153
  strokeOpacity: (_d = (_c = graphic.attribute) === null || _c === void 0 ? void 0 : _c.strokeOpacity) !== null && _d !== void 0 ? _d : 1
27122
27154
  });
@@ -27145,7 +27177,7 @@ function commonLineClipIn(line, label, duration, delay, easing) {
27145
27177
  const endSymbolDuration = 0.1 * duration;
27146
27178
  const labelDuration = 0.1 * duration;
27147
27179
  graphicFadeIn(line.startSymbol, delay, startSymbolDuration, easing);
27148
- line.lines.forEach(line => line.setAttribute('clipRange', 0));
27180
+ line.lines.forEach(line => commitUpdateAnimationTarget(line, { clipRange: 1 }, { clipRange: 0 }));
27149
27181
  line.lines.forEach((l, index) => {
27150
27182
  const stepDuration = lineDuration / line.lines.length;
27151
27183
  l.animate()
@@ -27228,7 +27260,7 @@ function pointCallIn(itemLine, decorativeLine, item, duration, delay, easing) {
27228
27260
  const endSymbolDuration = 0.1 * duration;
27229
27261
  const labelDuration = 0.1 * duration;
27230
27262
  graphicFadeIn(itemLine.startSymbol, delay, startSymbolDuration, easing);
27231
- itemLine.lines.forEach(line => line.setAttribute('clipRange', 0));
27263
+ itemLine.lines.forEach(line => commitUpdateAnimationTarget(line, { clipRange: 1 }, { clipRange: 0 }));
27232
27264
  itemLine.lines.forEach((l, index) => {
27233
27265
  const stepDuration = lineDuration / itemLine.lines.length;
27234
27266
  l.animate()
@@ -29727,9 +29759,9 @@ class DiscreteLegend extends LegendBase {
29727
29759
  }
29728
29760
  if (!this._itemContext.isScrollbar) {
29729
29761
  if (animation) {
29730
- this._itemsContainer
29731
- .animate()
29732
- .to({ [channel]: -(newPage - 1) * pageSize }, animationDuration, animationEasing);
29762
+ const attrs = { [channel]: -(newPage - 1) * pageSize };
29763
+ commitUpdateAnimationTarget(this._itemsContainer, attrs);
29764
+ this._itemsContainer.animate().to(attrs, animationDuration, animationEasing);
29733
29765
  }
29734
29766
  else {
29735
29767
  this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
@@ -29747,7 +29779,9 @@ class DiscreteLegend extends LegendBase {
29747
29779
  const startOffset = containerSize * start;
29748
29780
  this.updateScrollMask();
29749
29781
  if (animation) {
29750
- this._itemsContainer.animate().to({ [channel]: -startOffset }, animationDuration, animationEasing);
29782
+ const attrs = { [channel]: -startOffset };
29783
+ commitUpdateAnimationTarget(this._itemsContainer, attrs);
29784
+ this._itemsContainer.animate().to(attrs, animationDuration, animationEasing);
29751
29785
  }
29752
29786
  else {
29753
29787
  this._itemsContainer.setAttribute(channel, -startOffset);
@@ -33700,6 +33734,7 @@ class Timeline extends AbstractComponent {
33700
33734
  setActive(symbolGroup, activeSymbolStyle);
33701
33735
  }
33702
33736
  appearAnimate(animateConfig) {
33737
+ var _a;
33703
33738
  const { duration = 1000, easing = 'quadOut' } = animateConfig;
33704
33739
  const { activeLabelStyle, activeSymbolStyle } = this.attribute;
33705
33740
  const percent = duration / 1000;
@@ -33710,30 +33745,33 @@ class Timeline extends AbstractComponent {
33710
33745
  const symbolDelay = percent * 100;
33711
33746
  const symbolNormalDelay = percent * 600;
33712
33747
  if (this._line) {
33713
- this._line.setAttributes({ clipRange: 0 });
33748
+ commitUpdateAnimationTarget(this._line, { clipRange: 1 }, { clipRange: 0 });
33714
33749
  this._line.animate().to({ clipRange: 1 }, lineDuration, easing);
33715
33750
  }
33716
33751
  if (this._activeLine) {
33717
- this._activeLine.setAttributes({ opacity: 0 });
33752
+ const opacity = (_a = this._activeLine.attribute.opacity) !== null && _a !== void 0 ? _a : 1;
33753
+ commitUpdateAnimationTarget(this._activeLine, { opacity }, { opacity: 0 });
33718
33754
  this._activeLine
33719
33755
  .animate()
33720
33756
  .wait(500)
33721
- .to({ opacity: 1 }, activeLineDuration, easing);
33757
+ .to({ opacity }, activeLineDuration, easing);
33722
33758
  }
33723
33759
  if (this._symbolGroup) {
33724
33760
  const size = this._symbolGroup.count - 1;
33725
33761
  const delay = percent * (size === 1 ? 0 : (500 - 100) / (size - 1));
33726
33762
  const delayNormal = percent * (size === 1 ? 0 : (400 - 160) / (size - 1));
33727
33763
  this._symbolGroup.forEachChildren((symbol, i) => {
33764
+ var _a;
33728
33765
  const originAttrs = {};
33729
33766
  Object.keys(activeSymbolStyle).forEach(k => {
33730
33767
  originAttrs[k] = symbol.attribute[k];
33731
33768
  });
33732
- symbol.setAttributes({ opacity: 0 });
33769
+ const opacity = (_a = symbol.attribute.opacity) !== null && _a !== void 0 ? _a : 1;
33770
+ commitUpdateAnimationTarget(symbol, { opacity }, { opacity: 0 });
33733
33771
  symbol
33734
33772
  .animate()
33735
33773
  .wait(symbolDelay + delay * i)
33736
- .to({ opacity: 1 }, perSymbolDuration, easing);
33774
+ .to({ opacity }, perSymbolDuration, easing);
33737
33775
  symbol
33738
33776
  .animate()
33739
33777
  .wait(symbolNormalDelay + delayNormal * i)
@@ -33746,15 +33784,17 @@ class Timeline extends AbstractComponent {
33746
33784
  const delay = percent * (size === 1 ? 0 : (500 - 100) / (size - 1));
33747
33785
  const delayNormal = percent * (size === 1 ? 0 : (400 - 160) / (size - 1));
33748
33786
  this._labelGroup.forEachChildren((label, i) => {
33787
+ var _a;
33749
33788
  const originAttrs = {};
33750
33789
  Object.keys(activeLabelStyle).forEach(k => {
33751
33790
  originAttrs[k] = label.attribute[k];
33752
33791
  });
33753
- label.setAttributes({ opacity: 0 });
33792
+ const opacity = (_a = label.attribute.opacity) !== null && _a !== void 0 ? _a : 1;
33793
+ commitUpdateAnimationTarget(label, { opacity }, { opacity: 0 });
33754
33794
  label
33755
33795
  .animate()
33756
33796
  .wait(symbolDelay + delay * i)
33757
- .to({ opacity: 1 }, perSymbolDuration, easing);
33797
+ .to({ opacity }, perSymbolDuration, easing);
33758
33798
  label
33759
33799
  .animate()
33760
33800
  .wait(symbolNormalDelay + delayNormal * i)
@@ -33794,6 +33834,7 @@ class Timeline extends AbstractComponent {
33794
33834
  const nextClipRange = flag > 0 ? this._timesPercent[i] || 1 : this._timesPercent[i - 1] || 0;
33795
33835
  if (animation) {
33796
33836
  const { duration = 1000, easing = 'quadOut' } = animateConfig;
33837
+ commitUpdateAnimationTarget(this, { clipRange: nextClipRange }, { clipRange });
33797
33838
  this.animate().to({ clipRange: nextClipRange }, duration, easing);
33798
33839
  }
33799
33840
  else {
@@ -35640,6 +35681,6 @@ TableSeriesNumber.defaultAttributes = {
35640
35681
  select: true
35641
35682
  };
35642
35683
 
35643
- const version = "1.1.0-alpha.7";
35684
+ const version = "1.1.0-alpha.8";
35644
35685
 
35645
35686
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IDataZoomEvent, IDataZoomInteractiveEvent, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PolygonSectorCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SeriesNumberCellStateValue, SeriesNumberEvent, SizeContinuousLegend, Slider, StoryLabelItem, Switch, SymbolLabel, TableSeriesNumber, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, WeatherBox, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, installPoptipToApp, installScrollbarToApp, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
@@ -1,5 +1,7 @@
1
1
  import { AComponentAnimate, AnimateExecutor, createComponentAnimator } from "@visactor/vrender-animate";
2
2
 
3
+ import { commitUpdateAnimationTarget } from "./static-truth";
4
+
3
5
  export class AxisEnter extends AComponentAnimate {
4
6
  onBind() {
5
7
  var _a;
@@ -11,7 +13,10 @@ export class AxisEnter extends AComponentAnimate {
11
13
  if (lastScale && getTickCoord && currData) {
12
14
  ratio = .7;
13
15
  const point = getTickCoord(lastScale.scale(currData.rawValue)), newX = this.target.attribute.x, newY = this.target.attribute.y;
14
- this.target.setAttributes({
16
+ commitUpdateAnimationTarget(this.target, {
17
+ x: newX,
18
+ y: newY
19
+ }, {
15
20
  x: point.x,
16
21
  y: point.y
17
22
  }), animator.animate(this.target, {
@@ -37,8 +42,8 @@ export class AxisUpdate extends AComponentAnimate {
37
42
  onBind() {
38
43
  const animator = createComponentAnimator(this.target);
39
44
  this._animator = animator;
40
- const duration = this.duration, easing = this.easing, {config: config, diffAttrs: diffAttrs} = this.params;
41
- animator.animate(this.target, {
45
+ const duration = this.duration, easing = this.easing, {diffAttrs: diffAttrs} = this.params;
46
+ commitUpdateAnimationTarget(this.target, Object.assign({}, diffAttrs)), animator.animate(this.target, {
42
47
  type: "to",
43
48
  to: Object.assign({}, diffAttrs),
44
49
  duration: duration,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/animation/axis-animate.ts"],"names":[],"mappings":"AAAA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ACnE,CAAC","file":"axis-animate.js","sourcesContent":["import { AComponentAnimate, AnimateExecutor, createComponentAnimator } from '@visactor/vrender-animate';\n\n/**\n * AxisEnter class handles the enter animation for Axis components\n */\nexport class AxisEnter extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n const { config, lastScale, getTickCoord } = this.params;\n\n let ratio = 1;\n const currData = this.target.data;\n if (lastScale && getTickCoord && currData) {\n ratio = 0.7;\n\n const oldValue = lastScale.scale(currData.rawValue);\n const point = getTickCoord(oldValue);\n const newX = this.target.attribute.x;\n const newY = this.target.attribute.y;\n\n this.target.setAttributes({ x: point.x, y: point.y });\n animator.animate(this.target, {\n type: 'to',\n to: { x: newX, y: newY },\n duration,\n easing\n });\n }\n\n // if (updateEls && updateEls.length > 1) {\n // ratio = 0.5;\n // const oldData1 = updateEls[0].oldEl.data;\n // const { rawValue: oldRawValue1, value: oldValue1 } = oldData1;\n // const oldData2 = updateEls[1].oldEl.data;\n // const { rawValue: oldRawValue2, value: oldValue2 } = oldData2;\n // const data = this.target.data;\n // const { rawValue: newRawValue } = data;\n // // rawValue 是原始值,value是映射出来的值,假设是线性映射,计算一下newRawValue在old阶段的value是什么值\n // const oldValue =\n // oldValue1 + ((oldValue2 - oldValue1) * (newRawValue - oldRawValue1)) / (oldRawValue2 - oldRawValue1);\n // // 将 x 和 y 做映射\n // const oldX1 = updateEls[0].oldEl.attribute.x;\n // const oldY1 = updateEls[0].oldEl.attribute.y;\n // const oldX2 = updateEls[1].oldEl.attribute.x;\n // const oldY2 = updateEls[1].oldEl.attribute.y;\n // const oldX = oldX1 + ((oldX2 - oldX1) * (oldValue - oldValue1)) / (oldValue2 - oldValue1);\n // const oldY = oldY1 + ((oldY2 - oldY1) * (oldValue - oldValue1)) / (oldValue2 - oldValue1);\n // const newX = this.target.attribute.x;\n // const newY = this.target.attribute.y;\n\n // this.target.setAttributes({ x: oldX, y: oldY });\n // animator.animate(this.target, {\n // type: 'to',\n // to: { x: newX, y: newY },\n // duration,\n // easing\n // });\n // }\n\n animator.animate(this.target, {\n type: config.type ?? 'fadeIn',\n to: config.to,\n duration: duration * ratio,\n easing\n });\n this.completeBind(animator);\n }\n}\n\n/**\n * AxisUpdate class handles the update animation for Axis components\n */\nexport class AxisUpdate extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n const { config, diffAttrs } = this.params;\n // this.target.applyAnimationState(\n // ['update'],\n // [\n // {\n // name: 'update',\n // animation: {\n // type: 'to',\n // to: { ...this.props },\n // duration,\n // easing,\n // customParameters: {\n // diffAttrs: { ...this.props }\n // }\n // }\n // }\n // ]\n // );\n // console.log('this.props', this.props, { ...this.target.attribute });\n animator.animate(this.target, {\n type: 'to',\n to: { ...diffAttrs },\n duration,\n easing,\n customParameters: {\n diffAttrs: { ...diffAttrs }\n }\n });\n this.completeBind(animator);\n }\n\n // 轴动画本身没有逻辑,具体通过animator中执行,所以当需要屏蔽自身属性时,需要通过animator中执行\n deleteSelfAttr(key: string): void {\n super.deleteSelfAttr(key);\n this._animator.deleteSelfAttr(key);\n }\n\n // 轴动画本身没有逻辑,具体通过animator中执行,所以本身不需要屏蔽冲突\n protected tryPreventConflict(): void {\n return;\n }\n}\n\nexport function registerAxisAnimate() {\n // Label update animation\n AnimateExecutor.registerBuiltInAnimate('axisEnter', AxisEnter);\n AnimateExecutor.registerBuiltInAnimate('axisUpdate', AxisUpdate);\n}\n"]}
1
+ {"version":3,"sources":["../src/animation/axis-animate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACxG,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAK7D,MAAM,OAAO,SAAU,SAAQ,iBAAsB;IACnD,MAAM;;QACJ,MAAM,QAAQ,GAAG,uBA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Animate, AnimateExecutor, createComponentAnimator } from '@visactor/vrender-animate';\nimport { commitUpdateAnimationTarget } from './static-truth';\n\n/**\n * AxisEnter class handles the enter animation for Axis components\n */\nexport class AxisEnter extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n const { config, lastScale, getTickCoord } = this.params;\n\n let ratio = 1;\n const currData = this.target.data;\n if (lastScale && getTickCoord && currData) {\n ratio = 0.7;\n\n const oldValue = lastScale.scale(currData.rawValue);\n const point = getTickCoord(oldValue);\n const newX = this.target.attribute.x;\n const newY = this.target.attribute.y;\n\n commitUpdateAnimationTarget(this.target, { x: newX, y: newY }, { x: point.x, y: point.y });\n animator.animate(this.target, {\n type: 'to',\n to: { x: newX, y: newY },\n duration,\n easing\n });\n }\n\n // if (updateEls && updateEls.length > 1) {\n // ratio = 0.5;\n // const oldData1 = updateEls[0].oldEl.data;\n // const { rawValue: oldRawValue1, value: oldValue1 } = oldData1;\n // const oldData2 = updateEls[1].oldEl.data;\n // const { rawValue: oldRawValue2, value: oldValue2 } = oldData2;\n // const data = this.target.data;\n // const { rawValue: newRawValue } = data;\n // // rawValue 是原始值,value是映射出来的值,假设是线性映射,计算一下newRawValue在old阶段的value是什么值\n // const oldValue =\n // oldValue1 + ((oldValue2 - oldValue1) * (newRawValue - oldRawValue1)) / (oldRawValue2 - oldRawValue1);\n // // 将 x 和 y 做映射\n // const oldX1 = updateEls[0].oldEl.attribute.x;\n // const oldY1 = updateEls[0].oldEl.attribute.y;\n // const oldX2 = updateEls[1].oldEl.attribute.x;\n // const oldY2 = updateEls[1].oldEl.attribute.y;\n // const oldX = oldX1 + ((oldX2 - oldX1) * (oldValue - oldValue1)) / (oldValue2 - oldValue1);\n // const oldY = oldY1 + ((oldY2 - oldY1) * (oldValue - oldValue1)) / (oldValue2 - oldValue1);\n // const newX = this.target.attribute.x;\n // const newY = this.target.attribute.y;\n\n // this.target.setAttributes({ x: oldX, y: oldY });\n // animator.animate(this.target, {\n // type: 'to',\n // to: { x: newX, y: newY },\n // duration,\n // easing\n // });\n // }\n\n animator.animate(this.target, {\n type: config.type ?? 'fadeIn',\n to: config.to,\n duration: duration * ratio,\n easing\n });\n this.completeBind(animator);\n }\n}\n\n/**\n * AxisUpdate class handles the update animation for Axis components\n */\nexport class AxisUpdate extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n const { diffAttrs } = this.params;\n // this.target.applyAnimationState(\n // ['update'],\n // [\n // {\n // name: 'update',\n // animation: {\n // type: 'to',\n // to: { ...this.props },\n // duration,\n // easing,\n // customParameters: {\n // diffAttrs: { ...this.props }\n // }\n // }\n // }\n // ]\n // );\n // console.log('this.props', this.props, { ...this.target.attribute });\n commitUpdateAnimationTarget(this.target, { ...diffAttrs });\n animator.animate(this.target, {\n type: 'to',\n to: { ...diffAttrs },\n duration,\n easing,\n customParameters: {\n diffAttrs: { ...diffAttrs }\n }\n });\n this.completeBind(animator);\n }\n\n // 轴动画本身没有逻辑,具体通过animator中执行,所以当需要屏蔽自身属性时,需要通过animator中执行\n deleteSelfAttr(key: string): void {\n super.deleteSelfAttr(key);\n this._animator.deleteSelfAttr(key);\n }\n\n // 轴动画本身没有逻辑,具体通过animator中执行,所以本身不需要屏蔽冲突\n protected tryPreventConflict(): void {\n return;\n }\n}\n\nexport function registerAxisAnimate() {\n // Label update animation\n AnimateExecutor.registerBuiltInAnimate('axisEnter', AxisEnter);\n AnimateExecutor.registerBuiltInAnimate('axisUpdate', AxisUpdate);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { type IGraphic } from '@visactor/vrender-core';
2
+ export declare function commitUpdateAnimationTarget(graphic?: IGraphic, targetAttrs?: Record<string, any>, startAttrs?: Record<string, any>): void;
@@ -0,0 +1,18 @@
1
+ import { AttributeUpdateType } from "@visactor/vrender-core";
2
+
3
+ import { cloneDeep } from "@visactor/vutils";
4
+
5
+ export function commitUpdateAnimationTarget(graphic, targetAttrs, startAttrs) {
6
+ var _a, _b, _c, _d;
7
+ if (!graphic || !targetAttrs) return;
8
+ const committedTargetAttrs = cloneDeep(targetAttrs), transientStartAttrs = cloneDeep(null != startAttrs ? startAttrs : graphic.attribute);
9
+ graphic.setAttributes(committedTargetAttrs);
10
+ const baseAttributes = graphic.baseAttributes;
11
+ baseAttributes && "object" == typeof baseAttributes && Object.keys(committedTargetAttrs).forEach((key => {
12
+ baseAttributes[key] = cloneDeep(committedTargetAttrs[key]);
13
+ })), null === (_b = (_a = graphic).setFinalAttributes) || void 0 === _b || _b.call(_a, committedTargetAttrs),
14
+ null === (_d = (_c = graphic).setAttributesAndPreventAnimate) || void 0 === _d || _d.call(_c, transientStartAttrs, !1, {
15
+ type: AttributeUpdateType.ANIMATE_BIND
16
+ });
17
+ }
18
+ //# sourceMappingURL=static-truth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/animation/static-truth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAiB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,UAAU,2BAA2B,CACzC,OAAkB,EAClB,WAAiC,EACjC,UAAgC;;IAEhC,IAAI,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE;QAC5B,OAAO;KACR;IAED,MAAM,oBAAoB,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,mBAAmB,GAAG,SAAS,CAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvE,OAAO,CAAC,aAAa,CAAC,oBAA2B,CAAC,CAAC;IACnD,MAAM,cAAc,GAAI,OAAe,CAAC,cAAc,CAAC;IACvD,IAAI,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;QACxD,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC9C,cAAc,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;KACJ;IACD,MAAA,MAAC,OAAe,EAAC,kBAAkB,mDAAG,oBAAoB,CAAC,CAAC;IAC5D,MAAA,MAAC,OAAe,EAAC,8BAA8B,mDAAG,mBAA0B,EAAE,KAAK,EAAE;QACnF,IAAI,EAAE,mBAAmB,CAAC,YAAY;KACvC,CAAC,CAAC;AACL,CAAC","file":"static-truth.js","sourcesContent":["import { AttributeUpdateType, type IGraphic } from '@visactor/vrender-core';\nimport { cloneDeep } from '@visactor/vutils';\n\nexport function commitUpdateAnimationTarget(\n graphic?: IGraphic,\n targetAttrs?: Record<string, any>,\n startAttrs?: Record<string, any>\n) {\n if (!graphic || !targetAttrs) {\n return;\n }\n\n const committedTargetAttrs = cloneDeep(targetAttrs);\n const transientStartAttrs = cloneDeep(startAttrs ?? graphic.attribute);\n\n graphic.setAttributes(committedTargetAttrs as any);\n const baseAttributes = (graphic as any).baseAttributes;\n if (baseAttributes && typeof baseAttributes === 'object') {\n Object.keys(committedTargetAttrs).forEach(key => {\n baseAttributes[key] = cloneDeep(committedTargetAttrs[key]);\n });\n }\n (graphic as any).setFinalAttributes?.(committedTargetAttrs);\n (graphic as any).setAttributesAndPreventAnimate?.(transientStartAttrs as any, false, {\n type: AttributeUpdateType.ANIMATE_BIND\n });\n}\n"]}