@visactor/react-vchart 2.1.0-alpha.0 → 2.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -39677,9 +39677,17 @@
39677
39677
  }
39678
39678
  }
39679
39679
 
39680
+ const clipPathGeometryAttrs = {
39681
+ x: !0,
39682
+ y: !0,
39683
+ x1: !0,
39684
+ y1: !0,
39685
+ width: !0,
39686
+ height: !0
39687
+ };
39680
39688
  class Update extends ACustomAnimate {
39681
39689
  constructor(from, to, duration, easing, params) {
39682
- super(from, to, duration, easing, params);
39690
+ super(from, to, duration, easing, params), this.clipPathSyncKeys = null, this.clipPathSyncParent = null, this.clipPathSyncChildIndex = -1, this.clipPathSyncDisabled = !1;
39683
39691
  }
39684
39692
  onBind() {
39685
39693
  var _a, _b;
@@ -39692,12 +39700,25 @@
39692
39700
  } = this.params;
39693
39701
  diffAttrs = Object.assign({}, diffAttrs), (null === (_b = null == options ? void 0 : options.excludeChannels) || void 0 === _b ? void 0 : _b.length) && options.excludeChannels.forEach(channel => {
39694
39702
  delete diffAttrs[channel];
39695
- }), this.props = diffAttrs;
39703
+ }), this.props = diffAttrs, this.clipPathSyncKeys = Object.keys(diffAttrs).filter(key => clipPathGeometryAttrs[key]), this.clipPathSyncDisabled = !this.clipPathSyncKeys.length, this.syncParentClipPathToTarget();
39704
+ }
39705
+ getStaticCommitAttrs() {
39706
+ var _a;
39707
+ if (!this.props) return null;
39708
+ const target = this.target,
39709
+ contextFinalAttrs = null === (_a = target.context) || void 0 === _a ? void 0 : _a.finalAttrs,
39710
+ finalAttribute = "function" == typeof target.getFinalAttribute ? target.getFinalAttribute() : target.finalAttribute,
39711
+ commitAttrs = {};
39712
+ return Object.keys(this.props).forEach(key => {
39713
+ 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]);
39714
+ }), Object.keys(commitAttrs).length ? commitAttrs : null;
39696
39715
  }
39697
39716
  onEnd(cb) {
39698
- cb ? super.onEnd(cb) : (this.props && Object.keys(this.props).length && this.target.setAttributes(this.props, !1, {
39717
+ if (cb) return void super.onEnd(cb);
39718
+ const commitAttrs = this.getStaticCommitAttrs();
39719
+ commitAttrs && this.target.setAttributes(commitAttrs, !1, {
39699
39720
  type: AttributeUpdateType.ANIMATE_END
39700
- }), super.onEnd());
39721
+ }), this.syncParentClipPathToTarget(), super.onEnd();
39701
39722
  }
39702
39723
  update(end, ratio, out) {
39703
39724
  if (this.onStart(), !this.props || !this.propKeys) return;
@@ -39706,7 +39727,58 @@
39706
39727
  if (!this.animate.validAttr(this.propKeys[index])) return;
39707
39728
  const key = this.propKeys[index];
39708
39729
  func(key, this.fromProps[key], this.props[key], easedRatio, this, this.target);
39709
- }), this.onUpdate(end, easedRatio, out);
39730
+ }), this.syncParentClipPathToTarget(), this.onUpdate(end, easedRatio, out);
39731
+ }
39732
+ syncParentClipPathToTarget() {
39733
+ var _a, _b;
39734
+ if (this.clipPathSyncDisabled) return;
39735
+ const target = this.target,
39736
+ parent = target.parent,
39737
+ path = null === (_a = null == parent ? void 0 : parent.attribute) || void 0 === _a ? void 0 : _a.path;
39738
+ if (!(null === (_b = null == parent ? void 0 : parent.attribute) || void 0 === _b ? void 0 : _b.clip) || !Array.isArray(path) || !path.length) return;
39739
+ const childIndex = this.getClipPathSyncChildIndex(parent);
39740
+ if (childIndex < 0 || childIndex >= path.length) return;
39741
+ const clipGraphic = path[childIndex];
39742
+ if (!(null == clipGraphic ? void 0 : clipGraphic.attribute) || clipGraphic.type !== target.type || !this.isClipPathStaticTarget(clipGraphic)) return;
39743
+ const syncAttrs = this.buildClipPathTransientAttrs(clipGraphic);
39744
+ syncAttrs && applyAnimationTransientAttributes(clipGraphic, syncAttrs, AttributeUpdateType.ANIMATE_UPDATE);
39745
+ }
39746
+ getClipPathSyncChildIndex(parent) {
39747
+ var _a;
39748
+ if (this.clipPathSyncParent === parent && this.clipPathSyncChildIndex >= 0) return this.clipPathSyncChildIndex;
39749
+ const target = this.target;
39750
+ let childIndex = -1;
39751
+ return null === (_a = parent.forEachChildren) || void 0 === _a || _a.call(parent, (child, index) => child === target && (childIndex = index, !0)), this.clipPathSyncParent = parent, this.clipPathSyncChildIndex = childIndex, childIndex;
39752
+ }
39753
+ isClipPathStaticTarget(clipGraphic) {
39754
+ var _a, _b;
39755
+ const target = this.target,
39756
+ targetFinalAttrs = this.getTargetFinalAttrs(),
39757
+ clipGraphicFinalAttrs = "function" == typeof clipGraphic.getFinalAttribute ? clipGraphic.getFinalAttribute() : clipGraphic.finalAttribute,
39758
+ clipFinalAttrs = null !== (_a = null != clipGraphicFinalAttrs ? clipGraphicFinalAttrs : clipGraphic.baseAttributes) && void 0 !== _a ? _a : clipGraphic.attribute,
39759
+ keys = null !== (_b = this.clipPathSyncKeys) && void 0 !== _b ? _b : [];
39760
+ return !!(keys.length && targetFinalAttrs && clipFinalAttrs) && keys.every(key => {
39761
+ var _a, _b;
39762
+ return this.isSameClipPathValue(clipFinalAttrs[key], null !== (_a = targetFinalAttrs[key]) && void 0 !== _a ? _a : null === (_b = target.attribute) || void 0 === _b ? void 0 : _b[key]);
39763
+ });
39764
+ }
39765
+ getTargetFinalAttrs() {
39766
+ var _a, _b, _c;
39767
+ const target = this.target;
39768
+ return null !== (_c = null !== (_b = null === (_a = target.context) || void 0 === _a ? void 0 : _a.finalAttrs) && void 0 !== _b ? _b : "function" == typeof target.getFinalAttribute ? target.getFinalAttribute() : target.finalAttribute) && void 0 !== _c ? _c : null;
39769
+ }
39770
+ isSameClipPathValue(a, b) {
39771
+ return "number" == typeof a && "number" == typeof b ? Math.abs(a - b) < 1e-8 : a === b;
39772
+ }
39773
+ buildClipPathTransientAttrs(clipGraphic) {
39774
+ var _a;
39775
+ const target = this.target,
39776
+ attrs = {};
39777
+ return (null !== (_a = this.clipPathSyncKeys) && void 0 !== _a ? _a : []).forEach(key => {
39778
+ var _a;
39779
+ const nextValue = null === (_a = target.attribute) || void 0 === _a ? void 0 : _a[key];
39780
+ Object.prototype.hasOwnProperty.call(clipGraphic.attribute, key) && void 0 !== nextValue && !this.isSameClipPathValue(clipGraphic.attribute[key], nextValue) && (attrs[key] = nextValue);
39781
+ }), Object.keys(attrs).length ? attrs : null;
39710
39782
  }
39711
39783
  }
39712
39784