@visactor/vrender-animate 1.0.0-alpha.5 → 1.0.0-alpha.7

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 (74) hide show
  1. package/cjs/animate.js +2 -1
  2. package/cjs/animate.js.map +1 -1
  3. package/cjs/config/morphing.d.ts +2 -0
  4. package/cjs/config/morphing.js +9 -0
  5. package/cjs/config/morphing.js.map +1 -0
  6. package/cjs/custom/clip-graphic.js +1 -1
  7. package/cjs/custom/clip-graphic.js.map +1 -1
  8. package/cjs/custom/clip.d.ts +1 -0
  9. package/cjs/custom/clip.js +6 -0
  10. package/cjs/custom/clip.js.map +1 -1
  11. package/cjs/custom/fade.js +7 -5
  12. package/cjs/custom/fade.js.map +1 -1
  13. package/cjs/custom/growAngle.js +2 -1
  14. package/cjs/custom/growHeight.js +4 -4
  15. package/cjs/custom/growHeight.js.map +1 -1
  16. package/cjs/custom/morphing.d.ts +51 -0
  17. package/cjs/custom/morphing.js +298 -0
  18. package/cjs/custom/morphing.js.map +1 -0
  19. package/cjs/custom/move.d.ts +4 -0
  20. package/cjs/custom/move.js +8 -7
  21. package/cjs/custom/move.js.map +1 -1
  22. package/cjs/custom/register.js +1 -2
  23. package/cjs/custom/richtext/slide-richtext.js +1 -1
  24. package/cjs/custom/scale.js +3 -2
  25. package/cjs/custom/scale.js.map +1 -1
  26. package/cjs/custom/state.js +2 -1
  27. package/cjs/executor/animate-executor.js +19 -18
  28. package/cjs/executor/animate-executor.js.map +1 -1
  29. package/cjs/index.d.ts +1 -0
  30. package/cjs/index.js +30 -1
  31. package/cjs/index.js.map +1 -1
  32. package/cjs/ticker/default-ticker.js +1 -2
  33. package/cjs/utils/easing-func.js +2 -1
  34. package/cjs/utils/transform.d.ts +2 -0
  35. package/cjs/utils/transform.js +10 -0
  36. package/cjs/utils/transform.js.map +1 -0
  37. package/dist/index.es.js +515 -40
  38. package/es/animate.js +2 -1
  39. package/es/animate.js.map +1 -1
  40. package/es/config/morphing.d.ts +2 -0
  41. package/es/config/morphing.js +5 -0
  42. package/es/config/morphing.js.map +1 -0
  43. package/es/custom/clip-graphic.js +1 -1
  44. package/es/custom/clip-graphic.js.map +1 -1
  45. package/es/custom/clip.d.ts +1 -0
  46. package/es/custom/clip.js +6 -0
  47. package/es/custom/clip.js.map +1 -1
  48. package/es/custom/fade.js +7 -5
  49. package/es/custom/fade.js.map +1 -1
  50. package/es/custom/growAngle.js +2 -1
  51. package/es/custom/growHeight.js +4 -4
  52. package/es/custom/growHeight.js.map +1 -1
  53. package/es/custom/morphing.d.ts +51 -0
  54. package/es/custom/morphing.js +289 -0
  55. package/es/custom/morphing.js.map +1 -0
  56. package/es/custom/move.d.ts +4 -0
  57. package/es/custom/move.js +7 -6
  58. package/es/custom/move.js.map +1 -1
  59. package/es/custom/register.js +1 -2
  60. package/es/custom/richtext/slide-richtext.js +1 -1
  61. package/es/custom/scale.js +3 -2
  62. package/es/custom/scale.js.map +1 -1
  63. package/es/custom/state.js +2 -1
  64. package/es/executor/animate-executor.js +20 -18
  65. package/es/executor/animate-executor.js.map +1 -1
  66. package/es/index.d.ts +1 -0
  67. package/es/index.js +2 -0
  68. package/es/index.js.map +1 -1
  69. package/es/ticker/default-ticker.js +1 -2
  70. package/es/utils/easing-func.js +2 -1
  71. package/es/utils/transform.d.ts +2 -0
  72. package/es/utils/transform.js +4 -0
  73. package/es/utils/transform.js.map +1 -0
  74. package/package.json +5 -5
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { interpolateColor, interpolatePureColorArrayToStr, pointsInterpolation, Generator, ColorStore, ColorType, AnimateStatus, AnimateStepType, PerformanceRAF, STATUS, application, CustomPath2D, CurveContext, Graphic, AttributeUpdateType, pointInterpolation, RichText, divideCubic } from '@visactor/vrender-core';
2
- import { pi2, isString, EventEmitter, cloneDeep, isArray, isFunction, mixin, isValidNumber, clamp, Point, pi, isNumber, isValid, isNil, isNumberClose, PointService } from '@visactor/vutils';
1
+ import { interpolateColor, interpolatePureColorArrayToStr, pointsInterpolation, Generator, ColorStore, ColorType, AnimateStatus, AnimateStepType, PerformanceRAF, STATUS, application, CustomPath2D, CurveContext, Graphic, splitRect, splitArc, splitCircle, splitLine, splitPolygon, splitArea, splitPath, AttributeUpdateType, pathToBezierCurves, applyTransformOnBezierCurves, alignBezierCurves, findBestMorphingRotation, pointInterpolation, RichText, divideCubic } from '@visactor/vrender-core';
2
+ import { pi2, isString, EventEmitter, isArray, isFunction, mixin, isNil, isValidNumber, clamp, Point, pi, isNumber, isValid, isNumberClose, PointService } from '@visactor/vutils';
3
3
 
4
4
  class Easing {
5
5
  constructor() {
@@ -930,8 +930,10 @@ class Animate {
930
930
  step.stop();
931
931
  step = step.next;
932
932
  }
933
+ if (this.status !== AnimateStatus.END) {
934
+ this.onEnd();
935
+ }
933
936
  this.status = AnimateStatus.END;
934
- this.onEnd();
935
937
  if (!this.target) {
936
938
  return;
937
939
  }
@@ -1549,7 +1551,7 @@ class AnimateExecutor {
1549
1551
  var _a, _b;
1550
1552
  const totalTime = this.resolveValue(params.totalTime, undefined, undefined);
1551
1553
  const startTime = this.resolveValue(params.startTime, undefined, 0);
1552
- const parsedParams = cloneDeep(params);
1554
+ const parsedParams = Object.assign({}, params);
1553
1555
  parsedParams.oneByOneDelay = 0;
1554
1556
  parsedParams.startTime = startTime;
1555
1557
  parsedParams.totalTime = totalTime;
@@ -1560,19 +1562,19 @@ class AnimateExecutor {
1560
1562
  parsedParams.timeSlices = [timeSlices];
1561
1563
  }
1562
1564
  let sliceTime = 0;
1563
- parsedParams.timeSlices.forEach(slice => {
1564
- slice.delay = this.resolveValue(slice.delay, child, 0);
1565
- slice.delayAfter = this.resolveValue(slice.delayAfter, child, 0);
1566
- slice.duration = this.resolveValue(slice.duration, child, 300);
1567
- sliceTime += slice.delay + slice.duration + slice.delayAfter;
1565
+ parsedParams.timeSlices = parsedParams.timeSlices.map(slice => {
1566
+ const delay = this.resolveValue(slice.delay, child, 0);
1567
+ const delayAfter = this.resolveValue(slice.delayAfter, child, 0);
1568
+ const duration = this.resolveValue(slice.duration, child, 300);
1569
+ sliceTime += delay + duration + delayAfter;
1570
+ return Object.assign(Object.assign({}, slice), { delay,
1571
+ delayAfter,
1572
+ duration });
1568
1573
  });
1569
1574
  let oneByOneDelay = 0;
1570
- let oneByOneTime = 0;
1571
1575
  if (oneByOne) {
1572
- oneByOneTime = Number(oneByOne);
1573
- oneByOneDelay = oneByOneTime;
1576
+ oneByOneDelay = typeof oneByOne === 'number' ? oneByOne : oneByOne ? sliceTime : 0;
1574
1577
  }
1575
- parsedParams.oneByOne = oneByOneTime;
1576
1578
  parsedParams.oneByOneDelay = oneByOneDelay;
1577
1579
  let scale = 1;
1578
1580
  if (totalTime) {
@@ -1592,7 +1594,6 @@ class AnimateExecutor {
1592
1594
  customType });
1593
1595
  }) });
1594
1596
  });
1595
- parsedParams.oneByOne = oneByOneTime * scale;
1596
1597
  parsedParams.oneByOneDelay = oneByOneDelay * scale;
1597
1598
  parsedParams.startTime = startTime * scale;
1598
1599
  }
@@ -1600,13 +1601,11 @@ class AnimateExecutor {
1600
1601
  const delay = this.resolveValue(params.delay, child, 0);
1601
1602
  const delayAfter = this.resolveValue(params.delayAfter, child, 0);
1602
1603
  const duration = this.resolveValue(params.duration, child, 300);
1604
+ const loopTime = delay + delayAfter + duration;
1603
1605
  let oneByOneDelay = 0;
1604
- let oneByOneTime = 0;
1605
1606
  if (oneByOne) {
1606
- oneByOneTime = Number(oneByOne);
1607
- oneByOneDelay = duration + oneByOneTime;
1607
+ oneByOneDelay = typeof oneByOne === 'number' ? oneByOne : oneByOne ? loopTime : 0;
1608
1608
  }
1609
- parsedParams.oneByOne = oneByOneTime;
1610
1609
  parsedParams.oneByOneDelay = oneByOneDelay;
1611
1610
  parsedParams.custom =
1612
1611
  (_a = params.custom) !== null && _a !== void 0 ? _a : AnimateExecutor.builtInAnimateMap[(_b = params.type) !== null && _b !== void 0 ? _b : 'fromTo'];
@@ -1622,7 +1621,6 @@ class AnimateExecutor {
1622
1621
  parsedParams.delay = delay * scale;
1623
1622
  parsedParams.delayAfter = delayAfter * scale;
1624
1623
  parsedParams.duration = duration * scale;
1625
- parsedParams.oneByOne = oneByOneTime * scale;
1626
1624
  parsedParams.oneByOneDelay = oneByOneDelay * scale;
1627
1625
  parsedParams.startTime = startTime;
1628
1626
  }
@@ -1774,14 +1772,14 @@ class AnimateExecutor {
1774
1772
  }
1775
1773
  const slices = Array.isArray(timeSlices) ? timeSlices : [timeSlices];
1776
1774
  slices.forEach(slice => {
1777
- this.applyTimeSliceToAnimate(slice, animate, graphic);
1775
+ this.applyTimeSliceToAnimate(slice, animate, graphic, controlOptions);
1778
1776
  });
1779
1777
  if (oneByOneDelay) {
1780
1778
  animate.wait(oneByOneDelay * (count - index - 1));
1781
1779
  }
1782
1780
  return animate;
1783
1781
  }
1784
- applyTimeSliceToAnimate(slice, animate, graphic) {
1782
+ applyTimeSliceToAnimate(slice, animate, graphic, controlOptions) {
1785
1783
  var _a, _b, _c, _d;
1786
1784
  const { effects, duration = 300, delay = 0, delayAfter = 0 } = slice;
1787
1785
  const delayValue = isFunction(delay) ? delay((_b = (_a = graphic.context) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[0], graphic, {}) : delay;
@@ -1810,7 +1808,7 @@ class AnimateExecutor {
1810
1808
  }
1811
1809
  const custom = (_a = effect.custom) !== null && _a !== void 0 ? _a : AnimateExecutor.builtInAnimateMap[type];
1812
1810
  const customType = effect.customType;
1813
- this._handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, null, options, type, graphic);
1811
+ this._handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic);
1814
1812
  });
1815
1813
  if (delayAfterValue > 0) {
1816
1814
  animate.wait(delayAfterValue);
@@ -2489,6 +2487,471 @@ class IncreaseCount extends ACustomAnimate {
2489
2487
  }
2490
2488
  }
2491
2489
 
2490
+ const DefaultMorphingAnimateConfig = {
2491
+ duration: 1000,
2492
+ easing: 'quadInOut'
2493
+ };
2494
+
2495
+ const transformKeys = [
2496
+ 'x',
2497
+ 'y',
2498
+ 'dx',
2499
+ 'dy',
2500
+ 'scaleX',
2501
+ 'scaleY',
2502
+ 'angle',
2503
+ 'anchor',
2504
+ 'postMatrix',
2505
+ 'scrollX',
2506
+ 'scrollY'
2507
+ ];
2508
+ const isTransformKey = (key) => {
2509
+ return transformKeys.includes(key);
2510
+ };
2511
+
2512
+ const interpolateOtherAttrs = (attrs, out, ratio) => {
2513
+ attrs.forEach(entry => {
2514
+ if (Number.isFinite(entry.to)) {
2515
+ out[entry.key] = entry.from + (entry.to - entry.from) * ratio;
2516
+ }
2517
+ else if (entry.key === 'fill' || entry.key === 'stroke') {
2518
+ const color = interpolateColor(entry.from, entry.to, ratio, false);
2519
+ if (color) {
2520
+ out[entry.key] = color;
2521
+ }
2522
+ }
2523
+ });
2524
+ };
2525
+ const interpolateMorphingData = (morphingData, path, ratio) => {
2526
+ const tmpArr = [];
2527
+ const newCp = [];
2528
+ path.clear();
2529
+ for (let i = 0; i < morphingData.length; i++) {
2530
+ const item = morphingData[i];
2531
+ const from = item.from;
2532
+ const to = item.to;
2533
+ const angle = item.rotation * ratio;
2534
+ const fromCp = item.fromCp;
2535
+ const toCp = item.toCp;
2536
+ const sa = Math.sin(angle);
2537
+ const ca = Math.cos(angle);
2538
+ newCp[0] = fromCp[0] + (toCp[0] - fromCp[0]) * ratio;
2539
+ newCp[1] = fromCp[1] + (toCp[1] - fromCp[1]) * ratio;
2540
+ for (let m = 0; m < from.length; m += 2) {
2541
+ const x0 = from[m];
2542
+ const y0 = from[m + 1];
2543
+ const x1 = to[m];
2544
+ const y1 = to[m + 1];
2545
+ const x = x0 * (1 - ratio) + x1 * ratio;
2546
+ const y = y0 * (1 - ratio) + y1 * ratio;
2547
+ tmpArr[m] = x * ca - y * sa + newCp[0];
2548
+ tmpArr[m + 1] = x * sa + y * ca + newCp[1];
2549
+ }
2550
+ let x0 = tmpArr[0];
2551
+ let y0 = tmpArr[1];
2552
+ path.moveTo(x0, y0);
2553
+ for (let m = 2; m < from.length; m += 6) {
2554
+ const x1 = tmpArr[m];
2555
+ const y1 = tmpArr[m + 1];
2556
+ const x2 = tmpArr[m + 2];
2557
+ const y2 = tmpArr[m + 3];
2558
+ const x3 = tmpArr[m + 4];
2559
+ const y3 = tmpArr[m + 5];
2560
+ if (x0 === x1 && y0 === y1 && x2 === x3 && y2 === y3) {
2561
+ path.lineTo(x3, y3);
2562
+ }
2563
+ else {
2564
+ path.bezierCurveTo(x1, y1, x2, y2, x3, y3);
2565
+ }
2566
+ x0 = x3;
2567
+ y0 = y3;
2568
+ }
2569
+ }
2570
+ };
2571
+ const parseMorphingData = (fromPath, toPath, config) => {
2572
+ const fromBezier = fromPath ? pathToBezierCurves(fromPath) : [];
2573
+ const toBezier = pathToBezierCurves(toPath);
2574
+ if (config && fromBezier) {
2575
+ config.fromTransform && applyTransformOnBezierCurves(fromBezier, config.fromTransform.clone().getInverse());
2576
+ applyTransformOnBezierCurves(fromBezier, config.toTransfrom);
2577
+ }
2578
+ const [fromBezierCurves, toBezierCurves] = alignBezierCurves(fromBezier, toBezier);
2579
+ return fromPath
2580
+ ? findBestMorphingRotation(fromBezierCurves, toBezierCurves, 10, Math.PI)
2581
+ : toBezierCurves.map((to, index) => {
2582
+ return {
2583
+ from: fromBezierCurves[index],
2584
+ to,
2585
+ fromCp: [0, 0],
2586
+ toCp: [0, 0],
2587
+ rotation: 0
2588
+ };
2589
+ });
2590
+ };
2591
+ const validateOtherAttrs = [
2592
+ 'fill',
2593
+ 'fillOpacity',
2594
+ 'shadowBlur',
2595
+ 'shadowColor',
2596
+ 'shadowOffsetX',
2597
+ 'shadowOffsetY',
2598
+ 'stroke',
2599
+ 'strokeOpacity',
2600
+ 'lineDashOffset'
2601
+ ];
2602
+ const parseOtherAnimateAttrs = (fromAttrs, toAttrs) => {
2603
+ if (!fromAttrs || !toAttrs) {
2604
+ return null;
2605
+ }
2606
+ const res = [];
2607
+ let hasAttr = false;
2608
+ Object.keys(fromAttrs).forEach(fromKey => {
2609
+ if (!validateOtherAttrs.includes(fromKey)) {
2610
+ return;
2611
+ }
2612
+ const toValue = toAttrs[fromKey];
2613
+ if (!isNil(toValue) && !isNil(fromAttrs[fromKey]) && toValue !== fromAttrs[fromKey]) {
2614
+ if (fromKey === 'fill' || fromKey === 'stroke') {
2615
+ const parseColor = (color) => {
2616
+ return typeof color === 'string' ? ColorStore.Get(color, ColorType.Color255) : color;
2617
+ };
2618
+ res.push({
2619
+ from: isArray(fromAttrs[fromKey])
2620
+ ? fromAttrs[fromKey].map(parseColor)
2621
+ : parseColor(fromAttrs[fromKey]),
2622
+ to: isArray(toValue) ? toValue.map(parseColor) : parseColor(toValue),
2623
+ key: fromKey
2624
+ });
2625
+ }
2626
+ else {
2627
+ res.push({ from: fromAttrs[fromKey], to: toValue, key: fromKey });
2628
+ }
2629
+ hasAttr = true;
2630
+ }
2631
+ });
2632
+ return hasAttr ? res : null;
2633
+ };
2634
+ class MorphingPath extends ACustomAnimate {
2635
+ constructor(config, duration, easing) {
2636
+ super({}, {}, duration, easing);
2637
+ this.morphingData = config.morphingData;
2638
+ this.otherAttrs = config.otherAttrs;
2639
+ this.saveOnEnd = config.saveOnEnd;
2640
+ }
2641
+ getEndProps() {
2642
+ return {};
2643
+ }
2644
+ onBind() {
2645
+ this.target.createPathProxy();
2646
+ this.onUpdate(false, 0, this.target.attribute);
2647
+ }
2648
+ onEnd() {
2649
+ return;
2650
+ }
2651
+ onUpdate(end, ratio, out) {
2652
+ const target = this.target;
2653
+ const pathProxy = typeof target.pathProxy === 'function' ? target.pathProxy(target.attribute) : target.pathProxy;
2654
+ interpolateMorphingData(this.morphingData, pathProxy, ratio);
2655
+ if (this.otherAttrs && this.otherAttrs.length) {
2656
+ interpolateOtherAttrs(this.otherAttrs, out, ratio);
2657
+ }
2658
+ this.target.setAttributes(out);
2659
+ if (end && !this.saveOnEnd) {
2660
+ this.target.pathProxy = null;
2661
+ }
2662
+ }
2663
+ }
2664
+ const morphPath = (fromGraphic, toGraphic, animationConfig, fromGraphicTransform) => {
2665
+ var _a, _b, _c;
2666
+ if (fromGraphic && (!fromGraphic.valid || !fromGraphic.toCustomPath)) {
2667
+ if (__DEV__) {
2668
+ console.error(fromGraphic, ' is not validate');
2669
+ }
2670
+ return null;
2671
+ }
2672
+ if (!toGraphic.valid || !toGraphic.toCustomPath) {
2673
+ if (__DEV__) {
2674
+ console.error(toGraphic, ' is not validate');
2675
+ }
2676
+ return null;
2677
+ }
2678
+ let fromTransform = fromGraphic === null || fromGraphic === void 0 ? void 0 : fromGraphic.globalTransMatrix;
2679
+ if (fromGraphicTransform && fromTransform) {
2680
+ fromTransform = fromGraphicTransform
2681
+ .clone()
2682
+ .multiply(fromTransform.a, fromTransform.b, fromTransform.c, fromTransform.d, fromTransform.e, fromTransform.f);
2683
+ }
2684
+ const morphingData = parseMorphingData((_a = fromGraphic === null || fromGraphic === void 0 ? void 0 : fromGraphic.toCustomPath) === null || _a === void 0 ? void 0 : _a.call(fromGraphic), toGraphic.toCustomPath(), {
2685
+ fromTransform,
2686
+ toTransfrom: toGraphic.globalTransMatrix
2687
+ });
2688
+ const attrs = parseOtherAnimateAttrs(fromGraphic === null || fromGraphic === void 0 ? void 0 : fromGraphic.attribute, toGraphic.attribute);
2689
+ const animate = toGraphic.animate(animationConfig);
2690
+ if (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.delay) {
2691
+ animate.wait(animationConfig.delay);
2692
+ }
2693
+ const morphingPath = new MorphingPath({ morphingData, otherAttrs: attrs }, (_b = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.duration) !== null && _b !== void 0 ? _b : DefaultMorphingAnimateConfig.duration, (_c = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.easing) !== null && _c !== void 0 ? _c : DefaultMorphingAnimateConfig.easing);
2694
+ animate.play(morphingPath);
2695
+ return animate;
2696
+ };
2697
+ const oneToMultiMorph = (fromGraphic, toGraphics, animationConfig) => {
2698
+ var _a;
2699
+ const validateToGraphics = toGraphics.filter(graphic => graphic && graphic.toCustomPath && graphic.valid);
2700
+ if (!validateToGraphics.length) {
2701
+ if (__DEV__) {
2702
+ console.error(validateToGraphics, ' is not validate');
2703
+ }
2704
+ }
2705
+ if (!fromGraphic.valid || !fromGraphic.toCustomPath) {
2706
+ if (__DEV__) {
2707
+ console.error(fromGraphic, ' is not validate');
2708
+ }
2709
+ }
2710
+ const childGraphics = ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.splitPath) === 'clone' ? cloneGraphic : (_a = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.splitPath) !== null && _a !== void 0 ? _a : splitGraphic)(fromGraphic, validateToGraphics.length, false);
2711
+ const oldOnEnd = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.onEnd;
2712
+ let count = validateToGraphics.length;
2713
+ const onEachEnd = () => {
2714
+ count--;
2715
+ if (count === 0 && oldOnEnd) {
2716
+ oldOnEnd();
2717
+ }
2718
+ };
2719
+ validateToGraphics.forEach((toChild, index) => {
2720
+ var _a;
2721
+ const fromChild = childGraphics[index];
2722
+ const delay = ((_a = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.delay) !== null && _a !== void 0 ? _a : 0) +
2723
+ ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.individualDelay)
2724
+ ? animationConfig.individualDelay(index, validateToGraphics.length, fromChild, toChild)
2725
+ : 0);
2726
+ morphPath(fromChild, toChild, Object.assign({}, animationConfig, { onEnd: onEachEnd, delay }), fromGraphic.globalTransMatrix);
2727
+ });
2728
+ };
2729
+ class MultiToOneMorphingPath extends ACustomAnimate {
2730
+ constructor(config, duration, easing) {
2731
+ super({}, {}, duration, easing);
2732
+ this.morphingData = config.morphingData;
2733
+ this.otherAttrs = config.otherAttrs;
2734
+ }
2735
+ getEndProps() {
2736
+ return {};
2737
+ }
2738
+ onBind() {
2739
+ this.addPathProxy();
2740
+ }
2741
+ addPathProxy() {
2742
+ const shadowRoot = this.target.shadowRoot;
2743
+ shadowRoot.forEachChildren(child => {
2744
+ child.createPathProxy();
2745
+ });
2746
+ this.onUpdate(false, 0, this.target.attribute);
2747
+ }
2748
+ clearPathProxy() {
2749
+ const shadowRoot = this.target.shadowRoot;
2750
+ shadowRoot.forEachChildren(child => {
2751
+ child.pathProxy = null;
2752
+ });
2753
+ }
2754
+ onEnd() {
2755
+ return;
2756
+ }
2757
+ onUpdate(end, ratio, out) {
2758
+ const shadowRoot = this.target.shadowRoot;
2759
+ shadowRoot.forEachChildren((child, index) => {
2760
+ var _a;
2761
+ interpolateMorphingData(this.morphingData[index], typeof child.pathProxy === 'function' ? child.pathProxy(child.attribute) : child.pathProxy, ratio);
2762
+ if (((_a = this.otherAttrs) === null || _a === void 0 ? void 0 : _a[index]) && this.otherAttrs[index].length) {
2763
+ interpolateOtherAttrs(this.otherAttrs[index], child.attribute, ratio);
2764
+ }
2765
+ });
2766
+ if (end) {
2767
+ this.clearPathProxy();
2768
+ this.morphingData = null;
2769
+ }
2770
+ }
2771
+ }
2772
+ const parseShadowChildAttrs = (graphicAttrs) => {
2773
+ const attrs = {};
2774
+ Object.keys(graphicAttrs).forEach(key => {
2775
+ if (!isTransformKey(key)) {
2776
+ attrs[key] = graphicAttrs[key];
2777
+ }
2778
+ });
2779
+ return attrs;
2780
+ };
2781
+ const appendShadowChildrenToGraphic = (graphic, children, count) => {
2782
+ const childAttrs = parseShadowChildAttrs(graphic.attribute);
2783
+ const shadowRoot = graphic.attachShadow();
2784
+ if (children.length) {
2785
+ shadowRoot.setTheme({
2786
+ [children[0].type]: childAttrs
2787
+ });
2788
+ children.forEach(element => {
2789
+ element.setAttributes({ pickable: false });
2790
+ shadowRoot.appendChild(element);
2791
+ });
2792
+ }
2793
+ else {
2794
+ const box = graphic.AABBBounds;
2795
+ const width = box.width();
2796
+ const height = box.height();
2797
+ shadowRoot.setTheme({
2798
+ rect: childAttrs
2799
+ });
2800
+ new Array(count).fill(0).forEach(el => {
2801
+ const child = application.graphicService.creator.rect({
2802
+ x: 0,
2803
+ y: 0,
2804
+ width,
2805
+ height: height,
2806
+ pickable: false
2807
+ });
2808
+ shadowRoot.appendChild(child);
2809
+ children.push(child);
2810
+ });
2811
+ }
2812
+ };
2813
+ const cloneGraphic = (graphic, count, needAppend) => {
2814
+ const children = [];
2815
+ const childAttrs = needAppend ? null : parseShadowChildAttrs(graphic.attribute);
2816
+ const path = graphic.toCustomPath();
2817
+ for (let i = 0; i < count; i++) {
2818
+ const element = {
2819
+ path: new CustomPath2D().fromCustomPath2D(path)
2820
+ };
2821
+ children.push(application.graphicService.creator.path(needAppend ? element : Object.assign({}, childAttrs, element)));
2822
+ }
2823
+ if (needAppend) {
2824
+ appendShadowChildrenToGraphic(graphic, children, count);
2825
+ }
2826
+ return children;
2827
+ };
2828
+ const splitGraphic = (graphic, count, needAppend) => {
2829
+ const children = [];
2830
+ const childAttrs = needAppend ? null : parseShadowChildAttrs(graphic.attribute);
2831
+ if (graphic.type === 'rect') {
2832
+ const childrenAttrs = splitRect(graphic, count);
2833
+ childrenAttrs.forEach(element => {
2834
+ children.push(application.graphicService.creator.rect(needAppend ? element : Object.assign({}, childAttrs, element)));
2835
+ });
2836
+ }
2837
+ else if (graphic.type === 'arc') {
2838
+ const childrenAttrs = splitArc(graphic, count);
2839
+ childrenAttrs.forEach(element => {
2840
+ children.push(application.graphicService.creator.arc(needAppend ? element : Object.assign({}, childAttrs, element)));
2841
+ });
2842
+ }
2843
+ else if (graphic.type === 'circle') {
2844
+ const childrenAttrs = splitCircle(graphic, count);
2845
+ childrenAttrs.forEach(element => {
2846
+ children.push(application.graphicService.creator.arc(needAppend ? element : Object.assign({}, childAttrs, element)));
2847
+ });
2848
+ }
2849
+ else if (graphic.type === 'line') {
2850
+ const childrenAttrs = splitLine(graphic, count);
2851
+ const defaultSymbol = { size: 10, symbolType: 'circle' };
2852
+ childrenAttrs.forEach(element => {
2853
+ children.push(application.graphicService.creator.symbol(needAppend ? Object.assign({}, element, defaultSymbol) : Object.assign({}, childAttrs, element, defaultSymbol)));
2854
+ });
2855
+ }
2856
+ else if (graphic.type === 'polygon') {
2857
+ const childrenAttrs = splitPolygon(graphic, count);
2858
+ childrenAttrs.forEach(element => {
2859
+ children.push(application.graphicService.creator.polygon(needAppend ? element : Object.assign({}, childAttrs, element)));
2860
+ });
2861
+ }
2862
+ else if (graphic.type === 'area') {
2863
+ const childrenAttrs = splitArea(graphic, count);
2864
+ childrenAttrs.forEach(element => {
2865
+ children.push(application.graphicService.creator.polygon(needAppend ? element : Object.assign({}, childAttrs, element)));
2866
+ });
2867
+ }
2868
+ else if (graphic.type === 'path') {
2869
+ const childrenAttrs = splitPath(graphic, count);
2870
+ childrenAttrs.forEach(element => {
2871
+ if ('path' in element) {
2872
+ children.push(application.graphicService.creator.path(needAppend ? element : Object.assign({}, childAttrs, element)));
2873
+ }
2874
+ else {
2875
+ children.push(application.graphicService.creator.polygon(needAppend ? element : Object.assign({}, childAttrs, element)));
2876
+ }
2877
+ });
2878
+ }
2879
+ if (needAppend) {
2880
+ appendShadowChildrenToGraphic(graphic, children, count);
2881
+ }
2882
+ return children;
2883
+ };
2884
+ const multiToOneMorph = (fromGraphics, toGraphic, animationConfig) => {
2885
+ var _a, _b, _c;
2886
+ const validateFromGraphics = fromGraphics.filter(graphic => graphic.toCustomPath && graphic.valid);
2887
+ if (!validateFromGraphics.length) {
2888
+ if (__DEV__) {
2889
+ console.error(fromGraphics, ' is not validate');
2890
+ }
2891
+ }
2892
+ if (!toGraphic.valid || !toGraphic.toCustomPath) {
2893
+ if (__DEV__) {
2894
+ console.error(toGraphic, ' is not validate');
2895
+ }
2896
+ }
2897
+ const childGraphics = ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.splitPath) === 'clone' ? cloneGraphic : (_a = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.splitPath) !== null && _a !== void 0 ? _a : splitGraphic)(toGraphic, validateFromGraphics.length, true);
2898
+ const toAttrs = toGraphic.attribute;
2899
+ toGraphic.setAttribute('visible', false);
2900
+ const morphingData = validateFromGraphics.map((graphic, index) => {
2901
+ return parseMorphingData(graphic.toCustomPath(), childGraphics[index].toCustomPath(), {
2902
+ fromTransform: graphic.globalTransMatrix,
2903
+ toTransfrom: childGraphics[index].globalTransMatrix
2904
+ });
2905
+ });
2906
+ const otherAttrs = validateFromGraphics.map((graphic, index) => {
2907
+ return parseOtherAnimateAttrs(graphic.attribute, toAttrs);
2908
+ });
2909
+ if (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.individualDelay) {
2910
+ const oldOnEnd = animationConfig.onEnd;
2911
+ let count = validateFromGraphics.length;
2912
+ const onEachEnd = () => {
2913
+ count--;
2914
+ if (count === 0) {
2915
+ toGraphic.setAttributes({ visible: true, ratio: null }, false, {
2916
+ type: AttributeUpdateType.ANIMATE_END
2917
+ });
2918
+ toGraphic.detachShadow();
2919
+ if (oldOnEnd) {
2920
+ oldOnEnd();
2921
+ }
2922
+ }
2923
+ };
2924
+ childGraphics.forEach((to, index) => {
2925
+ var _a, _b, _c;
2926
+ const delay = ((_a = animationConfig.delay) !== null && _a !== void 0 ? _a : 0) +
2927
+ animationConfig.individualDelay(index, validateFromGraphics.length, fromGraphics[index], to);
2928
+ const animate = to.animate(Object.assign({}, animationConfig, { onEnd: onEachEnd }));
2929
+ animate.wait(delay);
2930
+ animate.play(new MorphingPath({
2931
+ morphingData: morphingData[index],
2932
+ saveOnEnd: true,
2933
+ otherAttrs: otherAttrs[index]
2934
+ }, (_b = animationConfig.duration) !== null && _b !== void 0 ? _b : DefaultMorphingAnimateConfig.duration, (_c = animationConfig.easing) !== null && _c !== void 0 ? _c : DefaultMorphingAnimateConfig.easing));
2935
+ });
2936
+ }
2937
+ else {
2938
+ const oldOnEnd = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.onEnd;
2939
+ const config = animationConfig ? Object.assign({}, animationConfig) : {};
2940
+ config.onEnd = () => {
2941
+ toGraphic.setAttribute('visible', true, false, { type: AttributeUpdateType.ANIMATE_END });
2942
+ toGraphic.detachShadow();
2943
+ if (oldOnEnd) {
2944
+ oldOnEnd();
2945
+ }
2946
+ };
2947
+ const animate = toGraphic.animate(config);
2948
+ if (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.delay) {
2949
+ animate.wait(animationConfig.delay);
2950
+ }
2951
+ animate.play(new MultiToOneMorphingPath({ morphingData, otherAttrs }, (_b = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.duration) !== null && _b !== void 0 ? _b : DefaultMorphingAnimateConfig.duration, (_c = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.easing) !== null && _c !== void 0 ? _c : DefaultMorphingAnimateConfig.easing));
2952
+ }
2953
+ };
2954
+
2492
2955
  class InputText extends ACustomAnimate {
2493
2956
  constructor(from, to, duration, easing, params) {
2494
2957
  super(from, to, duration, easing, params);
@@ -2585,7 +3048,7 @@ class InputText extends ACustomAnimate {
2585
3048
 
2586
3049
  class ClipGraphicAnimate extends ACustomAnimate {
2587
3050
  constructor(from, to, duration, easing, params) {
2588
- super(null, null, duration, easing, params);
3051
+ super(null, {}, duration, easing, params);
2589
3052
  this.clipFromAttribute = from;
2590
3053
  this.clipToAttribute = to;
2591
3054
  this._group = params === null || params === void 0 ? void 0 : params.group;
@@ -3026,6 +3489,14 @@ class ClipIn extends CommonIn {
3026
3489
  this.keys = ['clipRange'];
3027
3490
  this.from = { clipRange: 0 };
3028
3491
  }
3492
+ onFirstRun() {
3493
+ var _a;
3494
+ super.onFirstRun();
3495
+ const { clipDimension } = ((_a = this.params) === null || _a === void 0 ? void 0 : _a.options) || {};
3496
+ if (clipDimension) {
3497
+ this.target.attribute.clipRangeByDimension = clipDimension;
3498
+ }
3499
+ }
3029
3500
  }
3030
3501
  class ClipOut extends CommonOut {
3031
3502
  constructor(from, to, duration, easing, params) {
@@ -3037,14 +3508,14 @@ class ClipOut extends CommonOut {
3037
3508
  class FadeIn extends CommonIn {
3038
3509
  constructor(from, to, duration, easing, params) {
3039
3510
  super(from, to, duration, easing, params);
3040
- this.keys = ['opacity'];
3041
- this.from = { opacity: 0 };
3511
+ this.keys = ['opacity', 'fillOpacity', 'strokeOpacity'];
3512
+ this.from = { opacity: 0, fillOpacity: 0, strokeOpacity: 0 };
3042
3513
  }
3043
3514
  }
3044
3515
  class FadeOut extends CommonOut {
3045
3516
  constructor(from, to, duration, easing, params) {
3046
3517
  super(from, to, duration, easing, params);
3047
- this.keys = ['opacity'];
3518
+ this.keys = ['opacity', 'fillOpacity', 'strokeOpacity'];
3048
3519
  }
3049
3520
  }
3050
3521
 
@@ -3456,7 +3927,7 @@ function growHeightInIndividual(graphic, options, animationParameters) {
3456
3927
  };
3457
3928
  }
3458
3929
  function growHeightInOverall(graphic, options, animationParameters) {
3459
- var _a;
3930
+ var _a, _b, _c;
3460
3931
  const attrs = graphic.getFinalAttribute();
3461
3932
  const y = attrs.y;
3462
3933
  const y1 = attrs.y1;
@@ -3467,7 +3938,8 @@ function growHeightInOverall(graphic, options, animationParameters) {
3467
3938
  overallValue = options.overall;
3468
3939
  }
3469
3940
  else if (animationParameters.group) {
3470
- overallValue = (_a = animationParameters.groupHeight) !== null && _a !== void 0 ? _a : animationParameters.group.getBounds().height();
3941
+ overallValue =
3942
+ (_c = (_a = animationParameters.groupHeight) !== null && _a !== void 0 ? _a : (_b = options.layoutRect) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : animationParameters.group.getBounds().height();
3471
3943
  animationParameters.groupHeight = overallValue;
3472
3944
  }
3473
3945
  else {
@@ -3536,7 +4008,7 @@ function growHeightOutIndividual(graphic, options, animationParameters) {
3536
4008
  };
3537
4009
  }
3538
4010
  function growHeightOutOverall(graphic, options, animationParameters) {
3539
- var _a;
4011
+ var _a, _b, _c;
3540
4012
  const attrs = graphic.getFinalAttribute();
3541
4013
  const y1 = attrs.y1;
3542
4014
  const height = attrs.height;
@@ -3546,7 +4018,8 @@ function growHeightOutOverall(graphic, options, animationParameters) {
3546
4018
  overallValue = options.overall;
3547
4019
  }
3548
4020
  else if (animationParameters.group) {
3549
- overallValue = (_a = animationParameters.groupHeight) !== null && _a !== void 0 ? _a : animationParameters.group.getBounds().height();
4021
+ overallValue =
4022
+ (_c = (_a = animationParameters.groupHeight) !== null && _a !== void 0 ? _a : (_b = options.layoutRect) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : animationParameters.group.getBounds().height();
3550
4023
  animationParameters.groupHeight = overallValue;
3551
4024
  }
3552
4025
  else {
@@ -5161,6 +5634,7 @@ class ScaleIn extends ACustomAnimate {
5161
5634
  if (this._updateFunction) {
5162
5635
  this._updateFunction(ratio);
5163
5636
  this.target.addUpdatePositionTag();
5637
+ this.target.addUpdateBoundTag();
5164
5638
  }
5165
5639
  }
5166
5640
  }
@@ -5204,6 +5678,7 @@ class ScaleOut extends ACustomAnimate {
5204
5678
  attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
5205
5679
  });
5206
5680
  this.target.addUpdatePositionTag();
5681
+ this.target.addUpdateBoundTag();
5207
5682
  }
5208
5683
  }
5209
5684
 
@@ -5940,18 +6415,18 @@ class Update extends ACustomAnimate {
5940
6415
  }
5941
6416
 
5942
6417
  const moveIn = (graphic, options, animationParameters) => {
5943
- var _a, _b;
5944
- const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [] } = options !== null && options !== void 0 ? options : {};
6418
+ var _a, _b, _c, _d;
6419
+ const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [], layoutRect = {} } = options !== null && options !== void 0 ? options : {};
5945
6420
  let changedX = 0;
5946
6421
  let changedY = 0;
5947
6422
  if (orient === 'negative') {
5948
- changedX = graphic.stage.viewWidth;
5949
- changedY = graphic.stage.viewHeight;
6423
+ changedX = (_a = layoutRect.width) !== null && _a !== void 0 ? _a : graphic.stage.viewWidth;
6424
+ changedY = (_b = layoutRect.height) !== null && _b !== void 0 ? _b : graphic.stage.viewHeight;
5950
6425
  }
5951
6426
  changedX += offset;
5952
6427
  changedY += offset;
5953
6428
  const point = isFunction(pointOpt)
5954
- ? pointOpt.call(null, (_b = (_a = graphic.context) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[0], graphic, animationParameters)
6429
+ ? pointOpt.call(null, (_d = (_c = graphic.context) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d[0], graphic, animationParameters)
5955
6430
  : pointOpt;
5956
6431
  const fromX = point && isValidNumber(point.x) ? point.x : changedX;
5957
6432
  const fromY = point && isValidNumber(point.y) ? point.y : changedY;
@@ -5981,14 +6456,14 @@ const moveIn = (graphic, options, animationParameters) => {
5981
6456
  }
5982
6457
  };
5983
6458
  const moveOut = (graphic, options, animationParameters) => {
5984
- var _a, _b;
6459
+ var _a, _b, _c, _d, _e, _f;
5985
6460
  const { offset = 0, orient, direction, point: pointOpt } = options !== null && options !== void 0 ? options : {};
5986
- const groupWidth = graphic.stage.viewWidth;
5987
- const groupHeight = graphic.stage.viewHeight;
6461
+ const groupWidth = (_b = (_a = options.layoutRect) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : graphic.stage.viewWidth;
6462
+ const groupHeight = (_d = (_c = options.layoutRect) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : graphic.stage.viewHeight;
5988
6463
  const changedX = (orient === 'negative' ? groupWidth : 0) + offset;
5989
6464
  const changedY = (orient === 'negative' ? groupHeight : 0) + offset;
5990
6465
  const point = isFunction(pointOpt)
5991
- ? pointOpt.call(null, (_b = (_a = graphic.context) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[0], graphic, animationParameters)
6466
+ ? pointOpt.call(null, (_f = (_e = graphic.context) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f[0], graphic, animationParameters)
5992
6467
  : pointOpt;
5993
6468
  const fromX = point && isValidNumber(point.x) ? point.x : changedX;
5994
6469
  const fromY = point && isValidNumber(point.y) ? point.y : changedY;
@@ -6530,4 +7005,4 @@ const registerCustomAnimate = () => {
6530
7005
  AnimateExecutor.registerBuiltInAnimate('streamLight', StreamLight);
6531
7006
  };
6532
7007
 
6533
- export { AComponentAnimate, ACustomAnimate, Animate, AnimateExecutor, Step as AnimateStep, AnimationStateManager, AnimationStateStore, AnimationStates, AnimationTransitionRegistry, ClipAngleAnimate, ClipDirectionAnimate, ClipGraphicAnimate, ClipIn, ClipOut, ClipRadiusAnimate, ComponentAnimator, DefaultTicker, DefaultTimeline, FadeIn, FadeOut, FromTo, GraphicStateExtension, GroupFadeIn, GroupFadeOut, GrowAngleIn, GrowAngleOut, GrowCenterIn, GrowCenterOut, GrowHeightIn, GrowHeightOut, GrowIn, GrowOut, GrowPointsIn, GrowPointsOut, GrowPointsXIn, GrowPointsXOut, GrowPointsYIn, GrowPointsYOut, GrowRadiusIn, GrowRadiusOut, GrowWidthIn, GrowWidthOut, IncreaseCount, InputRichText, InputText, LabelItemAppear, LabelItemDisappear, ManualTicker, MotionPath, MoveIn, MoveOut, MoveRotateIn, MoveRotateOut, MoveScaleIn, MoveScaleOut, OutputRichText, PoptipAppear, PoptipDisappear, PulseAnimate, RotateBySphereAnimate, RotateIn, RotateOut, ScaleIn, ScaleOut, SlideIn, SlideOut, SlideOutRichText, SlideRichText, SpinIn, SpinOut, State, StreamLight, StrokeIn, StrokeOut, TagPointsUpdate, Update, createComponentAnimator, generatorPathEasingFunc, registerAnimate, registerCustomAnimate, transitionRegistry };
7008
+ export { AComponentAnimate, ACustomAnimate, Animate, AnimateExecutor, Step as AnimateStep, AnimationStateManager, AnimationStateStore, AnimationStates, AnimationTransitionRegistry, ClipAngleAnimate, ClipDirectionAnimate, ClipGraphicAnimate, ClipIn, ClipOut, ClipRadiusAnimate, ComponentAnimator, DefaultTicker, DefaultTimeline, FadeIn, FadeOut, FromTo, GraphicStateExtension, GroupFadeIn, GroupFadeOut, GrowAngleIn, GrowAngleOut, GrowCenterIn, GrowCenterOut, GrowHeightIn, GrowHeightOut, GrowIn, GrowOut, GrowPointsIn, GrowPointsOut, GrowPointsXIn, GrowPointsXOut, GrowPointsYIn, GrowPointsYOut, GrowRadiusIn, GrowRadiusOut, GrowWidthIn, GrowWidthOut, IncreaseCount, InputRichText, InputText, LabelItemAppear, LabelItemDisappear, ManualTicker, MorphingPath, MotionPath, MoveIn, MoveOut, MoveRotateIn, MoveRotateOut, MoveScaleIn, MoveScaleOut, MultiToOneMorphingPath, OutputRichText, PoptipAppear, PoptipDisappear, PulseAnimate, RotateBySphereAnimate, RotateIn, RotateOut, ScaleIn, ScaleOut, SlideIn, SlideOut, SlideOutRichText, SlideRichText, SpinIn, SpinOut, State, StreamLight, StrokeIn, StrokeOut, TagPointsUpdate, Update, createComponentAnimator, generatorPathEasingFunc, morphPath, multiToOneMorph, oneToMultiMorph, registerAnimate, registerCustomAnimate, transitionRegistry };