@visactor/vrender 1.1.0-alpha.7 → 1.1.0-alpha.9

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
@@ -36892,10 +36892,23 @@
36892
36892
  delete diffAttrs[channel];
36893
36893
  }), this.props = diffAttrs;
36894
36894
  }
36895
+ getStaticCommitAttrs() {
36896
+ var _a;
36897
+ if (!this.props) return null;
36898
+ const target = this.target,
36899
+ contextFinalAttrs = null === (_a = target.context) || void 0 === _a ? void 0 : _a.finalAttrs,
36900
+ finalAttribute = "function" == typeof target.getFinalAttribute ? target.getFinalAttribute() : target.finalAttribute,
36901
+ commitAttrs = {};
36902
+ return Object.keys(this.props).forEach(key => {
36903
+ contextFinalAttrs && Object.prototype.hasOwnProperty.call(contextFinalAttrs, key) ? commitAttrs[key] = contextFinalAttrs[key] : finalAttribute && Object.prototype.hasOwnProperty.call(finalAttribute, key) ? commitAttrs[key] = finalAttribute[key] : this.animate.validAttr(key) && (commitAttrs[key] = this.props[key]);
36904
+ }), Object.keys(commitAttrs).length ? commitAttrs : null;
36905
+ }
36895
36906
  onEnd(cb) {
36896
- cb ? super.onEnd(cb) : (this.props && Object.keys(this.props).length && this.target.setAttributes(this.props, !1, {
36907
+ if (cb) return void super.onEnd(cb);
36908
+ const commitAttrs = this.getStaticCommitAttrs();
36909
+ commitAttrs && this.target.setAttributes(commitAttrs, !1, {
36897
36910
  type: exports.AttributeUpdateType.ANIMATE_END
36898
- }), super.onEnd());
36911
+ }), super.onEnd();
36899
36912
  }
36900
36913
  update(end, ratio, out) {
36901
36914
  if (this.onStart(), !this.props || !this.propKeys) return;
@@ -40864,6 +40877,20 @@
40864
40877
  }
40865
40878
  }
40866
40879
 
40880
+ function commitUpdateAnimationTarget(graphic, targetAttrs, startAttrs) {
40881
+ var _a, _b, _c, _d;
40882
+ if (!graphic || !targetAttrs) return;
40883
+ const committedTargetAttrs = cloneDeep(targetAttrs),
40884
+ transientStartAttrs = cloneDeep(null != startAttrs ? startAttrs : graphic.attribute);
40885
+ graphic.setAttributes(committedTargetAttrs);
40886
+ const baseAttributes = graphic.baseAttributes;
40887
+ baseAttributes && "object" == typeof baseAttributes && Object.keys(committedTargetAttrs).forEach(key => {
40888
+ baseAttributes[key] = cloneDeep(committedTargetAttrs[key]);
40889
+ }), 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, {
40890
+ type: exports.AttributeUpdateType.ANIMATE_BIND
40891
+ });
40892
+ }
40893
+
40867
40894
  const DefaultAxisAnimation = {
40868
40895
  type: "default",
40869
40896
  duration: 300,
@@ -41189,33 +41216,29 @@
41189
41216
  var _a;
41190
41217
  if ("group" !== el.type && el.id) {
41191
41218
  const oldEl = prevInnerView[el.id];
41192
- if (el.setFinalAttributes(el.attribute), oldEl) {
41219
+ if (oldEl) {
41193
41220
  oldEl.release();
41194
- const oldAttrs = oldEl.attribute,
41195
- finalAttrs = el.getFinalAttribute(),
41221
+ const oldAttrs = cloneDeep(oldEl.attribute),
41222
+ finalAttrs = cloneDeep(el.attribute),
41196
41223
  diffAttrs = diff(oldAttrs, finalAttrs);
41197
41224
  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
- }
41225
+ "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] = {
41226
+ state: "update",
41227
+ node: el,
41228
+ attrs: finalAttrs
41229
+ }, commitUpdateAnimationTarget(el, finalAttrs, oldAttrs), el.applyAnimationState(["update"], [{
41230
+ name: "update",
41231
+ animation: Object.assign(Object.assign({
41232
+ selfOnly: !0
41233
+ }, animationConfig.update), {
41234
+ type: "axisUpdate",
41235
+ customParameters: {
41236
+ config: animationConfig.update,
41237
+ diffAttrs: diffAttrs,
41238
+ lastScale: lastScale
41239
+ }
41240
+ })
41241
+ }]));
41219
41242
  } else animationConfig.enter && (this._newElementAttrMap[el.id] = {
41220
41243
  state: "enter",
41221
41244
  node: el,
@@ -41559,7 +41582,10 @@
41559
41582
  const point = getTickCoord(lastScale.scale(currData.rawValue)),
41560
41583
  newX = this.target.attribute.x,
41561
41584
  newY = this.target.attribute.y;
41562
- this.target.setAttributes({
41585
+ commitUpdateAnimationTarget(this.target, {
41586
+ x: newX,
41587
+ y: newY
41588
+ }, {
41563
41589
  x: point.x,
41564
41590
  y: point.y
41565
41591
  }), animator.animate(this.target, {
@@ -41587,10 +41613,9 @@
41587
41613
  const duration = this.duration,
41588
41614
  easing = this.easing,
41589
41615
  {
41590
- config: config,
41591
41616
  diffAttrs: diffAttrs
41592
41617
  } = this.params;
41593
- animator.animate(this.target, {
41618
+ commitUpdateAnimationTarget(this.target, Object.assign({}, diffAttrs)), animator.animate(this.target, {
41594
41619
  type: "to",
41595
41620
  to: Object.assign({}, diffAttrs),
41596
41621
  duration: duration,
@@ -42475,6 +42500,7 @@
42475
42500
  super(...arguments), this.mode = exports.AnimateMode.NORMAL;
42476
42501
  }
42477
42502
  onBind() {
42503
+ this._started = !1;
42478
42504
  const currentInnerView = this.target.getInnerView(),
42479
42505
  prevInnerView = this.target.getPrevInnerView();
42480
42506
  prevInnerView && (this._newElementAttrMap = {}, traverseGroup(currentInnerView, el => {
@@ -42492,7 +42518,7 @@
42492
42518
  fillOpacity: null !== (_b = newProps.fillOpacity) && void 0 !== _b ? _b : 1,
42493
42519
  strokeOpacity: null !== (_c = newProps.strokeOpacity) && void 0 !== _c ? _c : 1
42494
42520
  })
42495
- }, el.setAttributes(oldEl.attribute);
42521
+ }, commitUpdateAnimationTarget(el, this._newElementAttrMap[el.id].attrs, cloneDeep(oldEl.attribute));
42496
42522
  }
42497
42523
  } else {
42498
42524
  const finalOpacityAttrs = {
@@ -42504,7 +42530,7 @@
42504
42530
  state: "enter",
42505
42531
  node: el,
42506
42532
  attrs: finalOpacityAttrs
42507
- }, el.setAttributes({
42533
+ }, commitUpdateAnimationTarget(el, finalOpacityAttrs, {
42508
42534
  opacity: 0,
42509
42535
  fillOpacity: 0,
42510
42536
  strokeOpacity: 0
@@ -42514,6 +42540,8 @@
42514
42540
  }));
42515
42541
  }
42516
42542
  onStart() {
42543
+ if (this._started) return;
42544
+ this._started = !0;
42517
42545
  let duration = this.duration,
42518
42546
  easing = this.easing;
42519
42547
  this._newElementAttrMap && Object.keys(this._newElementAttrMap).forEach(id => {
@@ -44610,7 +44638,7 @@
44610
44638
  text: curText,
44611
44639
  labelLine: curLabelLine
44612
44640
  } = currentLabel;
44613
- prevText.applyAnimationState(["update"], [{
44641
+ commitUpdateAnimationTarget(prevText, null == curText ? void 0 : curText.attribute), commitUpdateAnimationTarget(prevLabelLine, null == curLabelLine ? void 0 : curLabelLine.attribute), prevText.applyAnimationState(["update"], [{
44614
44642
  name: "update",
44615
44643
  animation: {
44616
44644
  type: "labelUpdate",
@@ -44636,7 +44664,6 @@
44636
44664
  }
44637
44665
  _updateLabel(prevLabel, currentLabel) {
44638
44666
  const {
44639
- text: prevText,
44640
44667
  labelLine: prevLabelLine
44641
44668
  } = prevLabel,
44642
44669
  {
@@ -47205,7 +47232,10 @@
47205
47232
  null === (_a = null == graphic ? void 0 : graphic.animates) || void 0 === _a || _a.forEach(a => a.stop("end"));
47206
47233
  const fillOpacityConfig = null !== (_c = null === (_b = graphic.attribute) || void 0 === _b ? void 0 : _b.fillOpacity) && void 0 !== _c ? _c : 1,
47207
47234
  strokeOpacityConfig = null !== (_e = null === (_d = graphic.attribute) || void 0 === _d ? void 0 : _d.strokeOpacity) && void 0 !== _e ? _e : 1;
47208
- graphic.setAttributes({
47235
+ commitUpdateAnimationTarget(graphic, {
47236
+ fillOpacity: fillOpacityConfig,
47237
+ strokeOpacity: strokeOpacityConfig
47238
+ }, {
47209
47239
  fillOpacity: 0,
47210
47240
  strokeOpacity: 0
47211
47241
  }), graphic.animate().wait(delay).to({
@@ -47221,7 +47251,10 @@
47221
47251
  }
47222
47252
  function graphicFadeOut(graphic, delay, duration, easing) {
47223
47253
  var _a, _b, _c, _d;
47224
- graphic && (graphic.setAttributes({
47254
+ graphic && (commitUpdateAnimationTarget(graphic, {
47255
+ fillOpacity: 0,
47256
+ strokeOpacity: 0
47257
+ }, {
47225
47258
  fillOpacity: null !== (_b = null === (_a = graphic.attribute) || void 0 === _a ? void 0 : _a.fillOpacity) && void 0 !== _b ? _b : 1,
47226
47259
  strokeOpacity: null !== (_d = null === (_c = graphic.attribute) || void 0 === _c ? void 0 : _c.strokeOpacity) && void 0 !== _d ? _d : 1
47227
47260
  }), graphic.animate().wait(delay).to({
@@ -47241,7 +47274,11 @@
47241
47274
  lineDuration = .7 * duration,
47242
47275
  endSymbolDuration = .1 * duration,
47243
47276
  labelDuration = .1 * duration;
47244
- graphicFadeIn(line.startSymbol, delay, startSymbolDuration, easing), line.lines.forEach(line => line.setAttribute("clipRange", 0)), line.lines.forEach((l, index) => {
47277
+ graphicFadeIn(line.startSymbol, delay, startSymbolDuration, easing), line.lines.forEach(line => commitUpdateAnimationTarget(line, {
47278
+ clipRange: 1
47279
+ }, {
47280
+ clipRange: 0
47281
+ })), line.lines.forEach((l, index) => {
47245
47282
  const stepDuration = lineDuration / line.lines.length;
47246
47283
  l.animate().wait(delay + startSymbolDuration + index * stepDuration).to({
47247
47284
  clipRange: 1
@@ -47299,7 +47336,11 @@
47299
47336
  decorativeDuration = .05 * duration,
47300
47337
  endSymbolDuration = .1 * duration,
47301
47338
  labelDuration = .1 * duration;
47302
- graphicFadeIn(itemLine.startSymbol, delay, startSymbolDuration, easing), itemLine.lines.forEach(line => line.setAttribute("clipRange", 0)), itemLine.lines.forEach((l, index) => {
47339
+ graphicFadeIn(itemLine.startSymbol, delay, startSymbolDuration, easing), itemLine.lines.forEach(line => commitUpdateAnimationTarget(line, {
47340
+ clipRange: 1
47341
+ }, {
47342
+ clipRange: 0
47343
+ })), itemLine.lines.forEach((l, index) => {
47303
47344
  const stepDuration = lineDuration / itemLine.lines.length;
47304
47345
  l.animate().wait(delay + startSymbolDuration + index * stepDuration).to({
47305
47346
  clipRange: 1
@@ -49583,12 +49624,18 @@
49583
49624
  let containerSize;
49584
49625
  containerSize = this._itemContext.isHorizontal ? this._itemsContainer.AABBBounds.width() : this._itemsContainer.AABBBounds.height();
49585
49626
  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);
49627
+ if (this.updateScrollMask(), animation) {
49628
+ const attrs = {
49629
+ [channel]: -startOffset
49630
+ };
49631
+ commitUpdateAnimationTarget(this._itemsContainer, attrs), this._itemsContainer.animate().to(attrs, animationDuration, animationEasing);
49632
+ } else this._itemsContainer.setAttribute(channel, -startOffset);
49633
+ } else if (animation) {
49634
+ const attrs = {
49635
+ [channel]: -(newPage - 1) * pageSize
49636
+ };
49637
+ commitUpdateAnimationTarget(this._itemsContainer, attrs), this._itemsContainer.animate().to(attrs, animationDuration, animationEasing);
49638
+ } else this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
49592
49639
  }
49593
49640
  };
49594
49641
  if (this._itemContext.isScrollbar) {
@@ -52612,6 +52659,7 @@
52612
52659
  setActive(labelGroup, activeLabelStyle), setActive(symbolGroup, activeSymbolStyle);
52613
52660
  }
52614
52661
  appearAnimate(animateConfig) {
52662
+ var _a;
52615
52663
  const {
52616
52664
  duration = 1e3,
52617
52665
  easing = "quadOut"
@@ -52627,26 +52675,39 @@
52627
52675
  perSymbolNormalDuration = 90 * percent,
52628
52676
  symbolDelay = 100 * percent,
52629
52677
  symbolNormalDelay = 600 * percent;
52630
- if (this._line && (this._line.setAttributes({
52678
+ if (this._line && (commitUpdateAnimationTarget(this._line, {
52679
+ clipRange: 1
52680
+ }, {
52631
52681
  clipRange: 0
52632
52682
  }), this._line.animate().to({
52633
52683
  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) {
52684
+ }, lineDuration, easing)), this._activeLine) {
52685
+ const opacity = null !== (_a = this._activeLine.attribute.opacity) && void 0 !== _a ? _a : 1;
52686
+ commitUpdateAnimationTarget(this._activeLine, {
52687
+ opacity: opacity
52688
+ }, {
52689
+ opacity: 0
52690
+ }), this._activeLine.animate().wait(500).to({
52691
+ opacity: opacity
52692
+ }, activeLineDuration, easing);
52693
+ }
52694
+ if (this._symbolGroup) {
52639
52695
  const size = this._symbolGroup.count - 1,
52640
52696
  delay = percent * (1 === size ? 0 : 400 / (size - 1)),
52641
52697
  delayNormal = percent * (1 === size ? 0 : 240 / (size - 1));
52642
52698
  this._symbolGroup.forEachChildren((symbol, i) => {
52699
+ var _a;
52643
52700
  const originAttrs = {};
52644
52701
  Object.keys(activeSymbolStyle).forEach(k => {
52645
52702
  originAttrs[k] = symbol.attribute[k];
52646
- }), symbol.setAttributes({
52703
+ });
52704
+ const opacity = null !== (_a = symbol.attribute.opacity) && void 0 !== _a ? _a : 1;
52705
+ commitUpdateAnimationTarget(symbol, {
52706
+ opacity: opacity
52707
+ }, {
52647
52708
  opacity: 0
52648
52709
  }), symbol.animate().wait(symbolDelay + delay * i).to({
52649
- opacity: 1
52710
+ opacity: opacity
52650
52711
  }, perSymbolDuration, easing), symbol.animate().wait(symbolNormalDelay + delayNormal * i).to(Object.assign({}, activeSymbolStyle), perSymbolNormalDuration, easing).to(Object.assign({}, originAttrs), perSymbolNormalDuration, easing);
52651
52712
  });
52652
52713
  }
@@ -52655,13 +52716,18 @@
52655
52716
  delay = percent * (1 === size ? 0 : 400 / (size - 1)),
52656
52717
  delayNormal = percent * (1 === size ? 0 : 240 / (size - 1));
52657
52718
  this._labelGroup.forEachChildren((label, i) => {
52719
+ var _a;
52658
52720
  const originAttrs = {};
52659
52721
  Object.keys(activeLabelStyle).forEach(k => {
52660
52722
  originAttrs[k] = label.attribute[k];
52661
- }), label.setAttributes({
52723
+ });
52724
+ const opacity = null !== (_a = label.attribute.opacity) && void 0 !== _a ? _a : 1;
52725
+ commitUpdateAnimationTarget(label, {
52726
+ opacity: opacity
52727
+ }, {
52662
52728
  opacity: 0
52663
52729
  }), label.animate().wait(symbolDelay + delay * i).to({
52664
- opacity: 1
52730
+ opacity: opacity
52665
52731
  }, perSymbolDuration, easing), label.animate().wait(symbolNormalDelay + delayNormal * i).to(Object.assign({
52666
52732
  dy: 10
52667
52733
  }, activeLabelStyle), perSymbolNormalDuration, easing).to(Object.assign({
@@ -52695,7 +52761,11 @@
52695
52761
  duration = 1e3,
52696
52762
  easing = "quadOut"
52697
52763
  } = animateConfig;
52698
- this.animate().to({
52764
+ commitUpdateAnimationTarget(this, {
52765
+ clipRange: nextClipRange
52766
+ }, {
52767
+ clipRange: clipRange
52768
+ }), this.animate().to({
52699
52769
  clipRange: nextClipRange
52700
52770
  }, duration, easing);
52701
52771
  } else this.setAttributes({
@@ -54414,7 +54484,7 @@
54414
54484
  return resolveLegacyApp().createStage(params);
54415
54485
  }
54416
54486
 
54417
- const version = "1.1.0-alpha.7";
54487
+ const version = "1.1.0-alpha.9";
54418
54488
 
54419
54489
  exports.AComponentAnimate = AComponentAnimate;
54420
54490
  exports.ACustomAnimate = ACustomAnimate;