@visactor/vrender 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.
package/dist/index.js CHANGED
@@ -40864,6 +40864,20 @@
40864
40864
  }
40865
40865
  }
40866
40866
 
40867
+ function commitUpdateAnimationTarget(graphic, targetAttrs, startAttrs) {
40868
+ var _a, _b, _c, _d;
40869
+ if (!graphic || !targetAttrs) return;
40870
+ const committedTargetAttrs = cloneDeep(targetAttrs),
40871
+ transientStartAttrs = cloneDeep(null != startAttrs ? startAttrs : graphic.attribute);
40872
+ graphic.setAttributes(committedTargetAttrs);
40873
+ const baseAttributes = graphic.baseAttributes;
40874
+ baseAttributes && "object" == typeof baseAttributes && Object.keys(committedTargetAttrs).forEach(key => {
40875
+ baseAttributes[key] = cloneDeep(committedTargetAttrs[key]);
40876
+ }), null === (_b = (_a = graphic).setFinalAttributes) || void 0 === _b || _b.call(_a, committedTargetAttrs), null === (_d = (_c = graphic).setAttributesAndPreventAnimate) || void 0 === _d || _d.call(_c, transientStartAttrs, !1, {
40877
+ type: exports.AttributeUpdateType.ANIMATE_BIND
40878
+ });
40879
+ }
40880
+
40867
40881
  const DefaultAxisAnimation = {
40868
40882
  type: "default",
40869
40883
  duration: 300,
@@ -41189,33 +41203,29 @@
41189
41203
  var _a;
41190
41204
  if ("group" !== el.type && el.id) {
41191
41205
  const oldEl = prevInnerView[el.id];
41192
- if (el.setFinalAttributes(el.attribute), oldEl) {
41206
+ if (oldEl) {
41193
41207
  oldEl.release();
41194
- const oldAttrs = oldEl.attribute,
41195
- finalAttrs = el.getFinalAttribute(),
41208
+ const oldAttrs = cloneDeep(oldEl.attribute),
41209
+ finalAttrs = cloneDeep(el.attribute),
41196
41210
  diffAttrs = diff(oldAttrs, finalAttrs);
41197
41211
  let hasDiff = Object.keys(diffAttrs).length > 0;
41198
- if ("opacity" in oldAttrs && finalAttrs.opacity !== oldAttrs.opacity && (diffAttrs.opacity = null !== (_a = finalAttrs.opacity) && void 0 !== _a ? _a : 1, hasDiff = !0), animationConfig.update && hasDiff) {
41199
- this._newElementAttrMap[el.id] = {
41200
- state: "update",
41201
- node: el,
41202
- attrs: el.attribute
41203
- };
41204
- const oldAttrs = oldEl.attribute;
41205
- el.setAttributes(oldAttrs), el.applyAnimationState(["update"], [{
41206
- name: "update",
41207
- animation: Object.assign(Object.assign({
41208
- selfOnly: !0
41209
- }, animationConfig.update), {
41210
- type: "axisUpdate",
41211
- customParameters: {
41212
- config: animationConfig.update,
41213
- diffAttrs: diffAttrs,
41214
- lastScale: lastScale
41215
- }
41216
- })
41217
- }]);
41218
- }
41212
+ "opacity" in oldAttrs && finalAttrs.opacity !== oldAttrs.opacity && (diffAttrs.opacity = null !== (_a = finalAttrs.opacity) && void 0 !== _a ? _a : 1, hasDiff = !0), animationConfig.update && hasDiff && (this._newElementAttrMap[el.id] = {
41213
+ state: "update",
41214
+ node: el,
41215
+ attrs: finalAttrs
41216
+ }, commitUpdateAnimationTarget(el, finalAttrs, oldAttrs), el.applyAnimationState(["update"], [{
41217
+ name: "update",
41218
+ animation: Object.assign(Object.assign({
41219
+ selfOnly: !0
41220
+ }, animationConfig.update), {
41221
+ type: "axisUpdate",
41222
+ customParameters: {
41223
+ config: animationConfig.update,
41224
+ diffAttrs: diffAttrs,
41225
+ lastScale: lastScale
41226
+ }
41227
+ })
41228
+ }]));
41219
41229
  } else animationConfig.enter && (this._newElementAttrMap[el.id] = {
41220
41230
  state: "enter",
41221
41231
  node: el,
@@ -41559,7 +41569,10 @@
41559
41569
  const point = getTickCoord(lastScale.scale(currData.rawValue)),
41560
41570
  newX = this.target.attribute.x,
41561
41571
  newY = this.target.attribute.y;
41562
- this.target.setAttributes({
41572
+ commitUpdateAnimationTarget(this.target, {
41573
+ x: newX,
41574
+ y: newY
41575
+ }, {
41563
41576
  x: point.x,
41564
41577
  y: point.y
41565
41578
  }), animator.animate(this.target, {
@@ -41587,10 +41600,9 @@
41587
41600
  const duration = this.duration,
41588
41601
  easing = this.easing,
41589
41602
  {
41590
- config: config,
41591
41603
  diffAttrs: diffAttrs
41592
41604
  } = this.params;
41593
- animator.animate(this.target, {
41605
+ commitUpdateAnimationTarget(this.target, Object.assign({}, diffAttrs)), animator.animate(this.target, {
41594
41606
  type: "to",
41595
41607
  to: Object.assign({}, diffAttrs),
41596
41608
  duration: duration,
@@ -42475,6 +42487,7 @@
42475
42487
  super(...arguments), this.mode = exports.AnimateMode.NORMAL;
42476
42488
  }
42477
42489
  onBind() {
42490
+ this._started = !1;
42478
42491
  const currentInnerView = this.target.getInnerView(),
42479
42492
  prevInnerView = this.target.getPrevInnerView();
42480
42493
  prevInnerView && (this._newElementAttrMap = {}, traverseGroup(currentInnerView, el => {
@@ -42492,7 +42505,7 @@
42492
42505
  fillOpacity: null !== (_b = newProps.fillOpacity) && void 0 !== _b ? _b : 1,
42493
42506
  strokeOpacity: null !== (_c = newProps.strokeOpacity) && void 0 !== _c ? _c : 1
42494
42507
  })
42495
- }, el.setAttributes(oldEl.attribute);
42508
+ }, commitUpdateAnimationTarget(el, this._newElementAttrMap[el.id].attrs, cloneDeep(oldEl.attribute));
42496
42509
  }
42497
42510
  } else {
42498
42511
  const finalOpacityAttrs = {
@@ -42504,7 +42517,7 @@
42504
42517
  state: "enter",
42505
42518
  node: el,
42506
42519
  attrs: finalOpacityAttrs
42507
- }, el.setAttributes({
42520
+ }, commitUpdateAnimationTarget(el, finalOpacityAttrs, {
42508
42521
  opacity: 0,
42509
42522
  fillOpacity: 0,
42510
42523
  strokeOpacity: 0
@@ -42514,6 +42527,8 @@
42514
42527
  }));
42515
42528
  }
42516
42529
  onStart() {
42530
+ if (this._started) return;
42531
+ this._started = !0;
42517
42532
  let duration = this.duration,
42518
42533
  easing = this.easing;
42519
42534
  this._newElementAttrMap && Object.keys(this._newElementAttrMap).forEach(id => {
@@ -44610,7 +44625,7 @@
44610
44625
  text: curText,
44611
44626
  labelLine: curLabelLine
44612
44627
  } = currentLabel;
44613
- prevText.applyAnimationState(["update"], [{
44628
+ commitUpdateAnimationTarget(prevText, null == curText ? void 0 : curText.attribute), commitUpdateAnimationTarget(prevLabelLine, null == curLabelLine ? void 0 : curLabelLine.attribute), prevText.applyAnimationState(["update"], [{
44614
44629
  name: "update",
44615
44630
  animation: {
44616
44631
  type: "labelUpdate",
@@ -44636,7 +44651,6 @@
44636
44651
  }
44637
44652
  _updateLabel(prevLabel, currentLabel) {
44638
44653
  const {
44639
- text: prevText,
44640
44654
  labelLine: prevLabelLine
44641
44655
  } = prevLabel,
44642
44656
  {
@@ -47205,7 +47219,10 @@
47205
47219
  null === (_a = null == graphic ? void 0 : graphic.animates) || void 0 === _a || _a.forEach(a => a.stop("end"));
47206
47220
  const fillOpacityConfig = null !== (_c = null === (_b = graphic.attribute) || void 0 === _b ? void 0 : _b.fillOpacity) && void 0 !== _c ? _c : 1,
47207
47221
  strokeOpacityConfig = null !== (_e = null === (_d = graphic.attribute) || void 0 === _d ? void 0 : _d.strokeOpacity) && void 0 !== _e ? _e : 1;
47208
- graphic.setAttributes({
47222
+ commitUpdateAnimationTarget(graphic, {
47223
+ fillOpacity: fillOpacityConfig,
47224
+ strokeOpacity: strokeOpacityConfig
47225
+ }, {
47209
47226
  fillOpacity: 0,
47210
47227
  strokeOpacity: 0
47211
47228
  }), graphic.animate().wait(delay).to({
@@ -47221,7 +47238,10 @@
47221
47238
  }
47222
47239
  function graphicFadeOut(graphic, delay, duration, easing) {
47223
47240
  var _a, _b, _c, _d;
47224
- graphic && (graphic.setAttributes({
47241
+ graphic && (commitUpdateAnimationTarget(graphic, {
47242
+ fillOpacity: 0,
47243
+ strokeOpacity: 0
47244
+ }, {
47225
47245
  fillOpacity: null !== (_b = null === (_a = graphic.attribute) || void 0 === _a ? void 0 : _a.fillOpacity) && void 0 !== _b ? _b : 1,
47226
47246
  strokeOpacity: null !== (_d = null === (_c = graphic.attribute) || void 0 === _c ? void 0 : _c.strokeOpacity) && void 0 !== _d ? _d : 1
47227
47247
  }), graphic.animate().wait(delay).to({
@@ -47241,7 +47261,11 @@
47241
47261
  lineDuration = .7 * duration,
47242
47262
  endSymbolDuration = .1 * duration,
47243
47263
  labelDuration = .1 * duration;
47244
- graphicFadeIn(line.startSymbol, delay, startSymbolDuration, easing), line.lines.forEach(line => line.setAttribute("clipRange", 0)), line.lines.forEach((l, index) => {
47264
+ graphicFadeIn(line.startSymbol, delay, startSymbolDuration, easing), line.lines.forEach(line => commitUpdateAnimationTarget(line, {
47265
+ clipRange: 1
47266
+ }, {
47267
+ clipRange: 0
47268
+ })), line.lines.forEach((l, index) => {
47245
47269
  const stepDuration = lineDuration / line.lines.length;
47246
47270
  l.animate().wait(delay + startSymbolDuration + index * stepDuration).to({
47247
47271
  clipRange: 1
@@ -47299,7 +47323,11 @@
47299
47323
  decorativeDuration = .05 * duration,
47300
47324
  endSymbolDuration = .1 * duration,
47301
47325
  labelDuration = .1 * duration;
47302
- graphicFadeIn(itemLine.startSymbol, delay, startSymbolDuration, easing), itemLine.lines.forEach(line => line.setAttribute("clipRange", 0)), itemLine.lines.forEach((l, index) => {
47326
+ graphicFadeIn(itemLine.startSymbol, delay, startSymbolDuration, easing), itemLine.lines.forEach(line => commitUpdateAnimationTarget(line, {
47327
+ clipRange: 1
47328
+ }, {
47329
+ clipRange: 0
47330
+ })), itemLine.lines.forEach((l, index) => {
47303
47331
  const stepDuration = lineDuration / itemLine.lines.length;
47304
47332
  l.animate().wait(delay + startSymbolDuration + index * stepDuration).to({
47305
47333
  clipRange: 1
@@ -49583,12 +49611,18 @@
49583
49611
  let containerSize;
49584
49612
  containerSize = this._itemContext.isHorizontal ? this._itemsContainer.AABBBounds.width() : this._itemsContainer.AABBBounds.height();
49585
49613
  const startOffset = containerSize * start;
49586
- this.updateScrollMask(), animation ? this._itemsContainer.animate().to({
49587
- [channel]: -startOffset
49588
- }, animationDuration, animationEasing) : this._itemsContainer.setAttribute(channel, -startOffset);
49589
- } else animation ? this._itemsContainer.animate().to({
49590
- [channel]: -(newPage - 1) * pageSize
49591
- }, animationDuration, animationEasing) : this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
49614
+ if (this.updateScrollMask(), animation) {
49615
+ const attrs = {
49616
+ [channel]: -startOffset
49617
+ };
49618
+ commitUpdateAnimationTarget(this._itemsContainer, attrs), this._itemsContainer.animate().to(attrs, animationDuration, animationEasing);
49619
+ } else this._itemsContainer.setAttribute(channel, -startOffset);
49620
+ } else if (animation) {
49621
+ const attrs = {
49622
+ [channel]: -(newPage - 1) * pageSize
49623
+ };
49624
+ commitUpdateAnimationTarget(this._itemsContainer, attrs), this._itemsContainer.animate().to(attrs, animationDuration, animationEasing);
49625
+ } else this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
49592
49626
  }
49593
49627
  };
49594
49628
  if (this._itemContext.isScrollbar) {
@@ -52612,6 +52646,7 @@
52612
52646
  setActive(labelGroup, activeLabelStyle), setActive(symbolGroup, activeSymbolStyle);
52613
52647
  }
52614
52648
  appearAnimate(animateConfig) {
52649
+ var _a;
52615
52650
  const {
52616
52651
  duration = 1e3,
52617
52652
  easing = "quadOut"
@@ -52627,26 +52662,39 @@
52627
52662
  perSymbolNormalDuration = 90 * percent,
52628
52663
  symbolDelay = 100 * percent,
52629
52664
  symbolNormalDelay = 600 * percent;
52630
- if (this._line && (this._line.setAttributes({
52665
+ if (this._line && (commitUpdateAnimationTarget(this._line, {
52666
+ clipRange: 1
52667
+ }, {
52631
52668
  clipRange: 0
52632
52669
  }), this._line.animate().to({
52633
52670
  clipRange: 1
52634
- }, lineDuration, easing)), this._activeLine && (this._activeLine.setAttributes({
52635
- opacity: 0
52636
- }), this._activeLine.animate().wait(500).to({
52637
- opacity: 1
52638
- }, activeLineDuration, easing)), this._symbolGroup) {
52671
+ }, lineDuration, easing)), this._activeLine) {
52672
+ const opacity = null !== (_a = this._activeLine.attribute.opacity) && void 0 !== _a ? _a : 1;
52673
+ commitUpdateAnimationTarget(this._activeLine, {
52674
+ opacity: opacity
52675
+ }, {
52676
+ opacity: 0
52677
+ }), this._activeLine.animate().wait(500).to({
52678
+ opacity: opacity
52679
+ }, activeLineDuration, easing);
52680
+ }
52681
+ if (this._symbolGroup) {
52639
52682
  const size = this._symbolGroup.count - 1,
52640
52683
  delay = percent * (1 === size ? 0 : 400 / (size - 1)),
52641
52684
  delayNormal = percent * (1 === size ? 0 : 240 / (size - 1));
52642
52685
  this._symbolGroup.forEachChildren((symbol, i) => {
52686
+ var _a;
52643
52687
  const originAttrs = {};
52644
52688
  Object.keys(activeSymbolStyle).forEach(k => {
52645
52689
  originAttrs[k] = symbol.attribute[k];
52646
- }), symbol.setAttributes({
52690
+ });
52691
+ const opacity = null !== (_a = symbol.attribute.opacity) && void 0 !== _a ? _a : 1;
52692
+ commitUpdateAnimationTarget(symbol, {
52693
+ opacity: opacity
52694
+ }, {
52647
52695
  opacity: 0
52648
52696
  }), symbol.animate().wait(symbolDelay + delay * i).to({
52649
- opacity: 1
52697
+ opacity: opacity
52650
52698
  }, perSymbolDuration, easing), symbol.animate().wait(symbolNormalDelay + delayNormal * i).to(Object.assign({}, activeSymbolStyle), perSymbolNormalDuration, easing).to(Object.assign({}, originAttrs), perSymbolNormalDuration, easing);
52651
52699
  });
52652
52700
  }
@@ -52655,13 +52703,18 @@
52655
52703
  delay = percent * (1 === size ? 0 : 400 / (size - 1)),
52656
52704
  delayNormal = percent * (1 === size ? 0 : 240 / (size - 1));
52657
52705
  this._labelGroup.forEachChildren((label, i) => {
52706
+ var _a;
52658
52707
  const originAttrs = {};
52659
52708
  Object.keys(activeLabelStyle).forEach(k => {
52660
52709
  originAttrs[k] = label.attribute[k];
52661
- }), label.setAttributes({
52710
+ });
52711
+ const opacity = null !== (_a = label.attribute.opacity) && void 0 !== _a ? _a : 1;
52712
+ commitUpdateAnimationTarget(label, {
52713
+ opacity: opacity
52714
+ }, {
52662
52715
  opacity: 0
52663
52716
  }), label.animate().wait(symbolDelay + delay * i).to({
52664
- opacity: 1
52717
+ opacity: opacity
52665
52718
  }, perSymbolDuration, easing), label.animate().wait(symbolNormalDelay + delayNormal * i).to(Object.assign({
52666
52719
  dy: 10
52667
52720
  }, activeLabelStyle), perSymbolNormalDuration, easing).to(Object.assign({
@@ -52695,7 +52748,11 @@
52695
52748
  duration = 1e3,
52696
52749
  easing = "quadOut"
52697
52750
  } = animateConfig;
52698
- this.animate().to({
52751
+ commitUpdateAnimationTarget(this, {
52752
+ clipRange: nextClipRange
52753
+ }, {
52754
+ clipRange: clipRange
52755
+ }), this.animate().to({
52699
52756
  clipRange: nextClipRange
52700
52757
  }, duration, easing);
52701
52758
  } else this.setAttributes({
@@ -54414,7 +54471,7 @@
54414
54471
  return resolveLegacyApp().createStage(params);
54415
54472
  }
54416
54473
 
54417
- const version = "1.1.0-alpha.7";
54474
+ const version = "1.1.0-alpha.8";
54418
54475
 
54419
54476
  exports.AComponentAnimate = AComponentAnimate;
54420
54477
  exports.ACustomAnimate = ACustomAnimate;