@visactor/vrender-animate 1.0.0-alpha.4 → 1.0.0-alpha.6
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/cjs/animate.js +2 -1
- package/cjs/animate.js.map +1 -1
- package/cjs/config/morphing.d.ts +2 -0
- package/cjs/config/morphing.js +9 -0
- package/cjs/config/morphing.js.map +1 -0
- package/cjs/custom/clip-graphic.js +1 -1
- package/cjs/custom/clip-graphic.js.map +1 -1
- package/cjs/custom/clip.d.ts +1 -0
- package/cjs/custom/clip.js +6 -0
- package/cjs/custom/clip.js.map +1 -1
- package/cjs/custom/fade.js +6 -3
- package/cjs/custom/fade.js.map +1 -1
- package/cjs/custom/fromTo.js +2 -1
- package/cjs/custom/groupFade.js +1 -2
- package/cjs/custom/growHeight.js +4 -4
- package/cjs/custom/growHeight.js.map +1 -1
- package/cjs/custom/morphing.d.ts +51 -0
- package/cjs/custom/morphing.js +298 -0
- package/cjs/custom/morphing.js.map +1 -0
- package/cjs/custom/move.d.ts +4 -0
- package/cjs/custom/move.js +8 -7
- package/cjs/custom/move.js.map +1 -1
- package/cjs/custom/register.d.ts +2 -2
- package/cjs/custom/register.js +19 -1
- package/cjs/custom/register.js.map +1 -1
- package/cjs/custom/richtext/input-richtext.d.ts +4 -2
- package/cjs/custom/richtext/input-richtext.js +18 -9
- package/cjs/custom/richtext/input-richtext.js.map +1 -1
- package/cjs/custom/richtext/slide-richtext.js +1 -1
- package/cjs/custom/scale.js +3 -2
- package/cjs/custom/scale.js.map +1 -1
- package/cjs/custom/story.d.ts +68 -0
- package/cjs/custom/story.js +147 -2
- package/cjs/custom/story.js.map +1 -1
- package/cjs/executor/animate-executor.js +19 -18
- package/cjs/executor/animate-executor.js.map +1 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +30 -1
- package/cjs/index.js.map +1 -1
- package/cjs/ticker/default-ticker.d.ts +3 -2
- package/cjs/ticker/default-ticker.js +9 -6
- package/cjs/ticker/default-ticker.js.map +1 -1
- package/cjs/ticker/manual-ticker.d.ts +2 -1
- package/cjs/ticker/manual-ticker.js +6 -4
- package/cjs/ticker/manual-ticker.js.map +1 -1
- package/cjs/timeline.d.ts +11 -3
- package/cjs/timeline.js +28 -15
- package/cjs/timeline.js.map +1 -1
- package/cjs/utils/easing-func.js +2 -1
- package/cjs/utils/transform.d.ts +2 -0
- package/cjs/utils/transform.js +10 -0
- package/cjs/utils/transform.js.map +1 -0
- package/dist/index.es.js +888 -85
- package/es/animate.js +2 -1
- package/es/animate.js.map +1 -1
- package/es/config/morphing.d.ts +2 -0
- package/es/config/morphing.js +5 -0
- package/es/config/morphing.js.map +1 -0
- package/es/custom/clip-graphic.js +1 -1
- package/es/custom/clip-graphic.js.map +1 -1
- package/es/custom/clip.d.ts +1 -0
- package/es/custom/clip.js +6 -0
- package/es/custom/clip.js.map +1 -1
- package/es/custom/fade.js +6 -3
- package/es/custom/fade.js.map +1 -1
- package/es/custom/fromTo.js +2 -1
- package/es/custom/groupFade.js +1 -2
- package/es/custom/growHeight.js +4 -4
- package/es/custom/growHeight.js.map +1 -1
- package/es/custom/morphing.d.ts +51 -0
- package/es/custom/morphing.js +289 -0
- package/es/custom/morphing.js.map +1 -0
- package/es/custom/move.d.ts +4 -0
- package/es/custom/move.js +7 -6
- package/es/custom/move.js.map +1 -1
- package/es/custom/register.d.ts +2 -2
- package/es/custom/register.js +7 -6
- package/es/custom/register.js.map +1 -1
- package/es/custom/richtext/input-richtext.d.ts +4 -2
- package/es/custom/richtext/input-richtext.js +18 -9
- package/es/custom/richtext/input-richtext.js.map +1 -1
- package/es/custom/richtext/slide-richtext.js +1 -1
- package/es/custom/scale.js +3 -2
- package/es/custom/scale.js.map +1 -1
- package/es/custom/story.d.ts +68 -0
- package/es/custom/story.js +140 -0
- package/es/custom/story.js.map +1 -1
- package/es/executor/animate-executor.js +20 -18
- package/es/executor/animate-executor.js.map +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/es/index.js.map +1 -1
- package/es/ticker/default-ticker.d.ts +3 -2
- package/es/ticker/default-ticker.js +9 -6
- package/es/ticker/default-ticker.js.map +1 -1
- package/es/ticker/manual-ticker.d.ts +2 -1
- package/es/ticker/manual-ticker.js +6 -4
- package/es/ticker/manual-ticker.js.map +1 -1
- package/es/timeline.d.ts +11 -3
- package/es/timeline.js +28 -15
- package/es/timeline.js.map +1 -1
- package/es/utils/easing-func.js +2 -1
- package/es/utils/transform.d.ts +2 -0
- package/es/utils/transform.js +4 -0
- package/es/utils/transform.js.map +1 -0
- package/package.json +4 -4
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,
|
|
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() {
|
|
@@ -567,32 +567,52 @@ class WaitStep extends Step {
|
|
|
567
567
|
|
|
568
568
|
class DefaultTimeline {
|
|
569
569
|
get animateCount() {
|
|
570
|
-
return this.
|
|
570
|
+
return this._animateCount;
|
|
571
571
|
}
|
|
572
572
|
constructor() {
|
|
573
|
-
this.
|
|
573
|
+
this.head = null;
|
|
574
|
+
this.tail = null;
|
|
575
|
+
this.animateMap = new Map();
|
|
576
|
+
this._animateCount = 0;
|
|
574
577
|
this._playSpeed = 1;
|
|
575
578
|
this._totalDuration = 0;
|
|
576
579
|
this._startTime = 0;
|
|
577
580
|
this._currentTime = 0;
|
|
578
|
-
this._endAnimatePtr = -1;
|
|
579
581
|
this.id = Generator.GenAutoIncrementId();
|
|
580
|
-
this.animates = [];
|
|
581
582
|
this.paused = false;
|
|
582
583
|
}
|
|
583
584
|
isRunning() {
|
|
584
|
-
return !this.paused && this.
|
|
585
|
+
return !this.paused && this._animateCount > 0;
|
|
585
586
|
}
|
|
586
587
|
forEachAccessAnimate(cb) {
|
|
587
|
-
|
|
588
|
-
|
|
588
|
+
let current = this.head;
|
|
589
|
+
let index = 0;
|
|
590
|
+
while (current) {
|
|
591
|
+
const next = current.next;
|
|
592
|
+
cb(current.animate, index);
|
|
593
|
+
index++;
|
|
594
|
+
current = next;
|
|
589
595
|
}
|
|
590
596
|
}
|
|
591
597
|
addAnimate(animate) {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
598
|
+
const newNode = {
|
|
599
|
+
animate,
|
|
600
|
+
next: null,
|
|
601
|
+
prev: null
|
|
602
|
+
};
|
|
603
|
+
if (!this.head) {
|
|
604
|
+
this.head = newNode;
|
|
605
|
+
this.tail = newNode;
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
if (this.tail) {
|
|
609
|
+
this.tail.next = newNode;
|
|
610
|
+
newNode.prev = this.tail;
|
|
611
|
+
this.tail = newNode;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
this.animateMap.set(animate, newNode);
|
|
615
|
+
this._animateCount++;
|
|
596
616
|
this._totalDuration = Math.max(this._totalDuration, animate.getStartTime() + animate.getDuration());
|
|
597
617
|
}
|
|
598
618
|
pause() {
|
|
@@ -609,7 +629,7 @@ class DefaultTimeline {
|
|
|
609
629
|
this._currentTime += scaledDelta;
|
|
610
630
|
this.forEachAccessAnimate((animate, i) => {
|
|
611
631
|
if (animate.status === AnimateStatus.END) {
|
|
612
|
-
this.removeAnimate(animate, true
|
|
632
|
+
this.removeAnimate(animate, true);
|
|
613
633
|
}
|
|
614
634
|
else if (animate.status === AnimateStatus.RUNNING || animate.status === AnimateStatus.INITIAL) {
|
|
615
635
|
animate.advance(scaledDelta);
|
|
@@ -620,25 +640,43 @@ class DefaultTimeline {
|
|
|
620
640
|
this.forEachAccessAnimate(animate => {
|
|
621
641
|
animate.release();
|
|
622
642
|
});
|
|
623
|
-
this.
|
|
643
|
+
this.head = null;
|
|
644
|
+
this.tail = null;
|
|
645
|
+
this.animateMap.clear();
|
|
646
|
+
this._animateCount = 0;
|
|
624
647
|
this._totalDuration = 0;
|
|
625
648
|
}
|
|
626
|
-
removeAnimate(animate, release = true
|
|
627
|
-
|
|
649
|
+
removeAnimate(animate, release = true) {
|
|
650
|
+
const node = this.animateMap.get(animate);
|
|
651
|
+
if (!node) {
|
|
628
652
|
return;
|
|
629
653
|
}
|
|
630
654
|
if (release) {
|
|
631
655
|
animate._onRemove && animate._onRemove.forEach(cb => cb());
|
|
632
656
|
animate.release();
|
|
633
657
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
658
|
+
if (node.prev) {
|
|
659
|
+
node.prev.next = node.next;
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
662
|
+
this.head = node.next;
|
|
663
|
+
}
|
|
664
|
+
if (node.next) {
|
|
665
|
+
node.next.prev = node.prev;
|
|
666
|
+
}
|
|
667
|
+
else {
|
|
668
|
+
this.tail = node.prev;
|
|
669
|
+
}
|
|
670
|
+
this.animateMap.delete(animate);
|
|
671
|
+
this._animateCount--;
|
|
672
|
+
if (animate.getStartTime() + animate.getDuration() >= this._totalDuration) {
|
|
673
|
+
this.recalculateTotalDuration();
|
|
674
|
+
}
|
|
637
675
|
return;
|
|
638
676
|
}
|
|
639
677
|
recalculateTotalDuration() {
|
|
640
678
|
this._totalDuration = 0;
|
|
641
|
-
this.
|
|
679
|
+
this.forEachAccessAnimate(animate => {
|
|
642
680
|
this._totalDuration = Math.max(this._totalDuration, animate.getStartTime() + animate.getDuration());
|
|
643
681
|
});
|
|
644
682
|
}
|
|
@@ -892,8 +930,10 @@ class Animate {
|
|
|
892
930
|
step.stop();
|
|
893
931
|
step = step.next;
|
|
894
932
|
}
|
|
933
|
+
if (this.status !== AnimateStatus.END) {
|
|
934
|
+
this.onEnd();
|
|
935
|
+
}
|
|
895
936
|
this.status = AnimateStatus.END;
|
|
896
|
-
this.onEnd();
|
|
897
937
|
if (!this.target) {
|
|
898
938
|
return;
|
|
899
939
|
}
|
|
@@ -1077,13 +1117,6 @@ class DefaultTicker extends EventEmitter {
|
|
|
1077
1117
|
super();
|
|
1078
1118
|
this.timelines = [];
|
|
1079
1119
|
this.frameTimeHistory = [];
|
|
1080
|
-
this.checkSkip = (delta) => {
|
|
1081
|
-
if (this.stage.params.optimize.tickRenderMode === 'performance') {
|
|
1082
|
-
return false;
|
|
1083
|
-
}
|
|
1084
|
-
const skip = delta < this.interval + (Math.random() - 0.5) * 2 * this._jitter;
|
|
1085
|
-
return skip;
|
|
1086
|
-
};
|
|
1087
1120
|
this.handleTick = (handler, params) => {
|
|
1088
1121
|
const { once = false } = params !== null && params !== void 0 ? params : {};
|
|
1089
1122
|
if (this.ifCanStop()) {
|
|
@@ -1126,6 +1159,9 @@ class DefaultTicker extends EventEmitter {
|
|
|
1126
1159
|
this.interval = 16;
|
|
1127
1160
|
this.computeTimeOffsetAndJitter();
|
|
1128
1161
|
}
|
|
1162
|
+
bindStage(stage) {
|
|
1163
|
+
this.stage = stage;
|
|
1164
|
+
}
|
|
1129
1165
|
computeTimeOffsetAndJitter() {
|
|
1130
1166
|
this.timeOffset = Math.floor(Math.random() * this.interval);
|
|
1131
1167
|
this._jitter = Math.min(Math.max(this.interval * 0.2, 6), this.interval * 0.7);
|
|
@@ -1251,19 +1287,25 @@ class DefaultTicker extends EventEmitter {
|
|
|
1251
1287
|
this.tickerHandler = null;
|
|
1252
1288
|
this.lastFrameTime = -1;
|
|
1253
1289
|
}
|
|
1290
|
+
checkSkip(delta) {
|
|
1291
|
+
if (this.stage.params.optimize.tickRenderMode === 'performance') {
|
|
1292
|
+
return false;
|
|
1293
|
+
}
|
|
1294
|
+
const skip = delta < this.interval + (Math.random() - 0.5) * 2 * this._jitter;
|
|
1295
|
+
return skip;
|
|
1296
|
+
}
|
|
1254
1297
|
}
|
|
1255
1298
|
|
|
1256
1299
|
class ManualTickHandler {
|
|
1257
1300
|
constructor() {
|
|
1258
1301
|
this.released = false;
|
|
1259
|
-
this.startTime = -1;
|
|
1260
1302
|
this.currentTime = -1;
|
|
1261
1303
|
}
|
|
1262
1304
|
tick(interval, cb) {
|
|
1263
|
-
if (this.
|
|
1264
|
-
this.
|
|
1305
|
+
if (this.currentTime < 0) {
|
|
1306
|
+
this.currentTime = 0;
|
|
1265
1307
|
}
|
|
1266
|
-
this.currentTime
|
|
1308
|
+
this.currentTime += interval;
|
|
1267
1309
|
cb(this);
|
|
1268
1310
|
}
|
|
1269
1311
|
release() {
|
|
@@ -1273,8 +1315,7 @@ class ManualTickHandler {
|
|
|
1273
1315
|
return this.currentTime;
|
|
1274
1316
|
}
|
|
1275
1317
|
tickTo(time, cb) {
|
|
1276
|
-
if (this.
|
|
1277
|
-
this.startTime = 0;
|
|
1318
|
+
if (this.currentTime < 0) {
|
|
1278
1319
|
this.currentTime = 0;
|
|
1279
1320
|
}
|
|
1280
1321
|
const interval = time - this.currentTime;
|
|
@@ -1295,6 +1336,9 @@ class ManualTicker extends DefaultTicker {
|
|
|
1295
1336
|
this.tickerHandler = handler;
|
|
1296
1337
|
return true;
|
|
1297
1338
|
}
|
|
1339
|
+
checkSkip(delta) {
|
|
1340
|
+
return false;
|
|
1341
|
+
}
|
|
1298
1342
|
getTime() {
|
|
1299
1343
|
return this.tickerHandler.getTime();
|
|
1300
1344
|
}
|
|
@@ -1507,7 +1551,7 @@ class AnimateExecutor {
|
|
|
1507
1551
|
var _a, _b;
|
|
1508
1552
|
const totalTime = this.resolveValue(params.totalTime, undefined, undefined);
|
|
1509
1553
|
const startTime = this.resolveValue(params.startTime, undefined, 0);
|
|
1510
|
-
const parsedParams =
|
|
1554
|
+
const parsedParams = Object.assign({}, params);
|
|
1511
1555
|
parsedParams.oneByOneDelay = 0;
|
|
1512
1556
|
parsedParams.startTime = startTime;
|
|
1513
1557
|
parsedParams.totalTime = totalTime;
|
|
@@ -1518,19 +1562,19 @@ class AnimateExecutor {
|
|
|
1518
1562
|
parsedParams.timeSlices = [timeSlices];
|
|
1519
1563
|
}
|
|
1520
1564
|
let sliceTime = 0;
|
|
1521
|
-
parsedParams.timeSlices.
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
sliceTime +=
|
|
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 });
|
|
1526
1573
|
});
|
|
1527
1574
|
let oneByOneDelay = 0;
|
|
1528
|
-
let oneByOneTime = 0;
|
|
1529
1575
|
if (oneByOne) {
|
|
1530
|
-
|
|
1531
|
-
oneByOneDelay = oneByOneTime;
|
|
1576
|
+
oneByOneDelay = typeof oneByOne === 'number' ? oneByOne : oneByOne ? sliceTime : 0;
|
|
1532
1577
|
}
|
|
1533
|
-
parsedParams.oneByOne = oneByOneTime;
|
|
1534
1578
|
parsedParams.oneByOneDelay = oneByOneDelay;
|
|
1535
1579
|
let scale = 1;
|
|
1536
1580
|
if (totalTime) {
|
|
@@ -1550,7 +1594,6 @@ class AnimateExecutor {
|
|
|
1550
1594
|
customType });
|
|
1551
1595
|
}) });
|
|
1552
1596
|
});
|
|
1553
|
-
parsedParams.oneByOne = oneByOneTime * scale;
|
|
1554
1597
|
parsedParams.oneByOneDelay = oneByOneDelay * scale;
|
|
1555
1598
|
parsedParams.startTime = startTime * scale;
|
|
1556
1599
|
}
|
|
@@ -1558,13 +1601,11 @@ class AnimateExecutor {
|
|
|
1558
1601
|
const delay = this.resolveValue(params.delay, child, 0);
|
|
1559
1602
|
const delayAfter = this.resolveValue(params.delayAfter, child, 0);
|
|
1560
1603
|
const duration = this.resolveValue(params.duration, child, 300);
|
|
1604
|
+
const loopTime = delay + delayAfter + duration;
|
|
1561
1605
|
let oneByOneDelay = 0;
|
|
1562
|
-
let oneByOneTime = 0;
|
|
1563
1606
|
if (oneByOne) {
|
|
1564
|
-
|
|
1565
|
-
oneByOneDelay = duration + oneByOneTime;
|
|
1607
|
+
oneByOneDelay = typeof oneByOne === 'number' ? oneByOne : oneByOne ? loopTime : 0;
|
|
1566
1608
|
}
|
|
1567
|
-
parsedParams.oneByOne = oneByOneTime;
|
|
1568
1609
|
parsedParams.oneByOneDelay = oneByOneDelay;
|
|
1569
1610
|
parsedParams.custom =
|
|
1570
1611
|
(_a = params.custom) !== null && _a !== void 0 ? _a : AnimateExecutor.builtInAnimateMap[(_b = params.type) !== null && _b !== void 0 ? _b : 'fromTo'];
|
|
@@ -1580,7 +1621,6 @@ class AnimateExecutor {
|
|
|
1580
1621
|
parsedParams.delay = delay * scale;
|
|
1581
1622
|
parsedParams.delayAfter = delayAfter * scale;
|
|
1582
1623
|
parsedParams.duration = duration * scale;
|
|
1583
|
-
parsedParams.oneByOne = oneByOneTime * scale;
|
|
1584
1624
|
parsedParams.oneByOneDelay = oneByOneDelay * scale;
|
|
1585
1625
|
parsedParams.startTime = startTime;
|
|
1586
1626
|
}
|
|
@@ -1732,14 +1772,14 @@ class AnimateExecutor {
|
|
|
1732
1772
|
}
|
|
1733
1773
|
const slices = Array.isArray(timeSlices) ? timeSlices : [timeSlices];
|
|
1734
1774
|
slices.forEach(slice => {
|
|
1735
|
-
this.applyTimeSliceToAnimate(slice, animate, graphic);
|
|
1775
|
+
this.applyTimeSliceToAnimate(slice, animate, graphic, controlOptions);
|
|
1736
1776
|
});
|
|
1737
1777
|
if (oneByOneDelay) {
|
|
1738
1778
|
animate.wait(oneByOneDelay * (count - index - 1));
|
|
1739
1779
|
}
|
|
1740
1780
|
return animate;
|
|
1741
1781
|
}
|
|
1742
|
-
applyTimeSliceToAnimate(slice, animate, graphic) {
|
|
1782
|
+
applyTimeSliceToAnimate(slice, animate, graphic, controlOptions) {
|
|
1743
1783
|
var _a, _b, _c, _d;
|
|
1744
1784
|
const { effects, duration = 300, delay = 0, delayAfter = 0 } = slice;
|
|
1745
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;
|
|
@@ -1768,7 +1808,7 @@ class AnimateExecutor {
|
|
|
1768
1808
|
}
|
|
1769
1809
|
const custom = (_a = effect.custom) !== null && _a !== void 0 ? _a : AnimateExecutor.builtInAnimateMap[type];
|
|
1770
1810
|
const customType = effect.customType;
|
|
1771
|
-
this._handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters,
|
|
1811
|
+
this._handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic);
|
|
1772
1812
|
});
|
|
1773
1813
|
if (delayAfterValue > 0) {
|
|
1774
1814
|
animate.wait(delayAfterValue);
|
|
@@ -2447,6 +2487,471 @@ class IncreaseCount extends ACustomAnimate {
|
|
|
2447
2487
|
}
|
|
2448
2488
|
}
|
|
2449
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
|
+
|
|
2450
2955
|
class InputText extends ACustomAnimate {
|
|
2451
2956
|
constructor(from, to, duration, easing, params) {
|
|
2452
2957
|
super(from, to, duration, easing, params);
|
|
@@ -2543,7 +3048,7 @@ class InputText extends ACustomAnimate {
|
|
|
2543
3048
|
|
|
2544
3049
|
class ClipGraphicAnimate extends ACustomAnimate {
|
|
2545
3050
|
constructor(from, to, duration, easing, params) {
|
|
2546
|
-
super(null,
|
|
3051
|
+
super(null, {}, duration, easing, params);
|
|
2547
3052
|
this.clipFromAttribute = from;
|
|
2548
3053
|
this.clipToAttribute = to;
|
|
2549
3054
|
this._group = params === null || params === void 0 ? void 0 : params.group;
|
|
@@ -2984,6 +3489,14 @@ class ClipIn extends CommonIn {
|
|
|
2984
3489
|
this.keys = ['clipRange'];
|
|
2985
3490
|
this.from = { clipRange: 0 };
|
|
2986
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
|
+
}
|
|
2987
3500
|
}
|
|
2988
3501
|
class ClipOut extends CommonOut {
|
|
2989
3502
|
constructor(from, to, duration, easing, params) {
|
|
@@ -2995,14 +3508,14 @@ class ClipOut extends CommonOut {
|
|
|
2995
3508
|
class FadeIn extends CommonIn {
|
|
2996
3509
|
constructor(from, to, duration, easing, params) {
|
|
2997
3510
|
super(from, to, duration, easing, params);
|
|
2998
|
-
this.keys = ['opacity'];
|
|
2999
|
-
this.from = { opacity: 0 };
|
|
3511
|
+
this.keys = ['opacity', 'fillOpacity', 'strokeOpacity'];
|
|
3512
|
+
this.from = { opacity: 0, fillOpacity: 0, strokeOpacity: 0 };
|
|
3000
3513
|
}
|
|
3001
3514
|
}
|
|
3002
3515
|
class FadeOut extends CommonOut {
|
|
3003
3516
|
constructor(from, to, duration, easing, params) {
|
|
3004
3517
|
super(from, to, duration, easing, params);
|
|
3005
|
-
this.keys = ['opacity'];
|
|
3518
|
+
this.keys = ['opacity', 'fillOpacity', 'strokeOpacity'];
|
|
3006
3519
|
}
|
|
3007
3520
|
}
|
|
3008
3521
|
|
|
@@ -3414,7 +3927,7 @@ function growHeightInIndividual(graphic, options, animationParameters) {
|
|
|
3414
3927
|
};
|
|
3415
3928
|
}
|
|
3416
3929
|
function growHeightInOverall(graphic, options, animationParameters) {
|
|
3417
|
-
var _a;
|
|
3930
|
+
var _a, _b, _c;
|
|
3418
3931
|
const attrs = graphic.getFinalAttribute();
|
|
3419
3932
|
const y = attrs.y;
|
|
3420
3933
|
const y1 = attrs.y1;
|
|
@@ -3425,7 +3938,8 @@ function growHeightInOverall(graphic, options, animationParameters) {
|
|
|
3425
3938
|
overallValue = options.overall;
|
|
3426
3939
|
}
|
|
3427
3940
|
else if (animationParameters.group) {
|
|
3428
|
-
overallValue =
|
|
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();
|
|
3429
3943
|
animationParameters.groupHeight = overallValue;
|
|
3430
3944
|
}
|
|
3431
3945
|
else {
|
|
@@ -3494,7 +4008,7 @@ function growHeightOutIndividual(graphic, options, animationParameters) {
|
|
|
3494
4008
|
};
|
|
3495
4009
|
}
|
|
3496
4010
|
function growHeightOutOverall(graphic, options, animationParameters) {
|
|
3497
|
-
var _a;
|
|
4011
|
+
var _a, _b, _c;
|
|
3498
4012
|
const attrs = graphic.getFinalAttribute();
|
|
3499
4013
|
const y1 = attrs.y1;
|
|
3500
4014
|
const height = attrs.height;
|
|
@@ -3504,7 +4018,8 @@ function growHeightOutOverall(graphic, options, animationParameters) {
|
|
|
3504
4018
|
overallValue = options.overall;
|
|
3505
4019
|
}
|
|
3506
4020
|
else if (animationParameters.group) {
|
|
3507
|
-
overallValue =
|
|
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();
|
|
3508
4023
|
animationParameters.groupHeight = overallValue;
|
|
3509
4024
|
}
|
|
3510
4025
|
else {
|
|
@@ -4340,10 +4855,10 @@ class InputRichText extends ACustomAnimate {
|
|
|
4340
4855
|
this.showCursor = false;
|
|
4341
4856
|
this.cursorChar = '|';
|
|
4342
4857
|
this.blinkCursor = true;
|
|
4343
|
-
this.beforeText = '';
|
|
4344
|
-
this.afterText = '';
|
|
4345
4858
|
this.fadeInChars = false;
|
|
4346
4859
|
this.fadeInDuration = 0.3;
|
|
4860
|
+
this.strokeFirst = false;
|
|
4861
|
+
this.strokeToFillRatio = 0.3;
|
|
4347
4862
|
if ((params === null || params === void 0 ? void 0 : params.showCursor) !== undefined) {
|
|
4348
4863
|
this.showCursor = params.showCursor;
|
|
4349
4864
|
}
|
|
@@ -4353,18 +4868,18 @@ class InputRichText extends ACustomAnimate {
|
|
|
4353
4868
|
if ((params === null || params === void 0 ? void 0 : params.blinkCursor) !== undefined) {
|
|
4354
4869
|
this.blinkCursor = params.blinkCursor;
|
|
4355
4870
|
}
|
|
4356
|
-
if ((params === null || params === void 0 ? void 0 : params.beforeText) !== undefined) {
|
|
4357
|
-
this.beforeText = params.beforeText;
|
|
4358
|
-
}
|
|
4359
|
-
if ((params === null || params === void 0 ? void 0 : params.afterText) !== undefined) {
|
|
4360
|
-
this.afterText = params.afterText;
|
|
4361
|
-
}
|
|
4362
4871
|
if ((params === null || params === void 0 ? void 0 : params.fadeInChars) !== undefined) {
|
|
4363
4872
|
this.fadeInChars = params.fadeInChars;
|
|
4364
4873
|
}
|
|
4365
4874
|
if ((params === null || params === void 0 ? void 0 : params.fadeInDuration) !== undefined) {
|
|
4366
4875
|
this.fadeInDuration = params.fadeInDuration;
|
|
4367
4876
|
}
|
|
4877
|
+
if ((params === null || params === void 0 ? void 0 : params.strokeFirst) !== undefined) {
|
|
4878
|
+
this.strokeFirst = params.strokeFirst;
|
|
4879
|
+
}
|
|
4880
|
+
if ((params === null || params === void 0 ? void 0 : params.strokeToFillRatio) !== undefined) {
|
|
4881
|
+
this.strokeToFillRatio = params.strokeToFillRatio;
|
|
4882
|
+
}
|
|
4368
4883
|
}
|
|
4369
4884
|
onFirstRun() {
|
|
4370
4885
|
const fromProps = this.getLastProps();
|
|
@@ -4413,11 +4928,30 @@ class InputRichText extends ACustomAnimate {
|
|
|
4413
4928
|
}
|
|
4414
4929
|
else {
|
|
4415
4930
|
currentTextConfig = this.toTextConfig.slice(0, currentLength).map((item, index) => {
|
|
4416
|
-
if (
|
|
4417
|
-
const
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4931
|
+
if ('text' in item) {
|
|
4932
|
+
const newItem = Object.assign({}, item);
|
|
4933
|
+
if (this.strokeFirst) {
|
|
4934
|
+
const appearTime = (index / totalItems) * maxTextShowRatio;
|
|
4935
|
+
const itemLifetime = Math.max(0, ratio - appearTime);
|
|
4936
|
+
const maxLifetime = 1 - appearTime;
|
|
4937
|
+
const fillProgress = Math.min(1, itemLifetime / (this.strokeToFillRatio * maxLifetime));
|
|
4938
|
+
if ('fill' in newItem && newItem.fill) {
|
|
4939
|
+
newItem.stroke = newItem.fill;
|
|
4940
|
+
if (fillProgress < 1) {
|
|
4941
|
+
newItem.fillOpacity = fillProgress;
|
|
4942
|
+
}
|
|
4943
|
+
}
|
|
4944
|
+
if (this.fadeInChars) {
|
|
4945
|
+
const fadeProgress = Math.min(1, itemLifetime / (this.fadeInDuration * maxLifetime));
|
|
4946
|
+
newItem.opacity = Math.max(0, Math.min(1, fadeProgress));
|
|
4947
|
+
}
|
|
4948
|
+
}
|
|
4949
|
+
else if (this.fadeInChars) {
|
|
4950
|
+
const appearTime = (index / totalItems) * maxTextShowRatio;
|
|
4951
|
+
const fadeProgress = (ratio - appearTime) / this.fadeInDuration;
|
|
4952
|
+
newItem.opacity = Math.max(0, Math.min(1, fadeProgress));
|
|
4953
|
+
}
|
|
4954
|
+
return newItem;
|
|
4421
4955
|
}
|
|
4422
4956
|
return item;
|
|
4423
4957
|
});
|
|
@@ -5100,6 +5634,7 @@ class ScaleIn extends ACustomAnimate {
|
|
|
5100
5634
|
if (this._updateFunction) {
|
|
5101
5635
|
this._updateFunction(ratio);
|
|
5102
5636
|
this.target.addUpdatePositionTag();
|
|
5637
|
+
this.target.addUpdateBoundTag();
|
|
5103
5638
|
}
|
|
5104
5639
|
}
|
|
5105
5640
|
}
|
|
@@ -5143,6 +5678,7 @@ class ScaleOut extends ACustomAnimate {
|
|
|
5143
5678
|
attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
|
|
5144
5679
|
});
|
|
5145
5680
|
this.target.addUpdatePositionTag();
|
|
5681
|
+
this.target.addUpdateBoundTag();
|
|
5146
5682
|
}
|
|
5147
5683
|
}
|
|
5148
5684
|
|
|
@@ -5297,6 +5833,155 @@ class SpinIn extends ACustomAnimate {
|
|
|
5297
5833
|
this.target.addUpdateShapeAndBoundsTag();
|
|
5298
5834
|
}
|
|
5299
5835
|
}
|
|
5836
|
+
class StrokeIn extends ACustomAnimate {
|
|
5837
|
+
constructor(from, to, duration, easing, params) {
|
|
5838
|
+
super(from, to, duration, easing, params);
|
|
5839
|
+
this.perimeter = 0;
|
|
5840
|
+
this.originalAttributes = {};
|
|
5841
|
+
}
|
|
5842
|
+
onBind() {
|
|
5843
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
5844
|
+
super.onBind();
|
|
5845
|
+
this.originalAttributes = Object.assign({}, this.target.getAttributes());
|
|
5846
|
+
if (this.target.type === 'rect') {
|
|
5847
|
+
const attr = this.target.attribute;
|
|
5848
|
+
const width = (_a = attr.width) !== null && _a !== void 0 ? _a : 100;
|
|
5849
|
+
const height = (_b = attr.height) !== null && _b !== void 0 ? _b : 100;
|
|
5850
|
+
this.perimeter = 2 * (width + height);
|
|
5851
|
+
}
|
|
5852
|
+
else if (this.target.type === 'circle') {
|
|
5853
|
+
const attr = this.target.attribute;
|
|
5854
|
+
const radius = (_c = attr.radius) !== null && _c !== void 0 ? _c : 50;
|
|
5855
|
+
this.perimeter = 2 * Math.PI * radius;
|
|
5856
|
+
}
|
|
5857
|
+
else if (this.target.type === 'ellipse') {
|
|
5858
|
+
const attr = this.target.attribute;
|
|
5859
|
+
const radiusX = (_d = attr.radiusX) !== null && _d !== void 0 ? _d : 50;
|
|
5860
|
+
const radiusY = (_e = attr.radiusY) !== null && _e !== void 0 ? _e : 50;
|
|
5861
|
+
this.perimeter = 2 * Math.PI * Math.sqrt((radiusX * radiusX + radiusY * radiusY) / 2);
|
|
5862
|
+
}
|
|
5863
|
+
else {
|
|
5864
|
+
this.perimeter = 1000;
|
|
5865
|
+
}
|
|
5866
|
+
const lineWidth = (_g = (_f = this.params) === null || _f === void 0 ? void 0 : _f.lineWidth) !== null && _g !== void 0 ? _g : 2;
|
|
5867
|
+
const strokeColor = (_j = (_h = this.params) === null || _h === void 0 ? void 0 : _h.strokeColor) !== null && _j !== void 0 ? _j : 'black';
|
|
5868
|
+
const fromOpacity = (_l = (_k = this.params) === null || _k === void 0 ? void 0 : _k.fromOpacity) !== null && _l !== void 0 ? _l : 1;
|
|
5869
|
+
const dashLength = (_o = (_m = this.params) === null || _m === void 0 ? void 0 : _m.dashLength) !== null && _o !== void 0 ? _o : this.perimeter;
|
|
5870
|
+
const showFill = (_q = (_p = this.params) === null || _p === void 0 ? void 0 : _p.showFill) !== null && _q !== void 0 ? _q : false;
|
|
5871
|
+
const fillOpacity = (_s = (_r = this.params) === null || _r === void 0 ? void 0 : _r.fillOpacity) !== null && _s !== void 0 ? _s : 0;
|
|
5872
|
+
this.from = {
|
|
5873
|
+
lineDash: [dashLength, dashLength],
|
|
5874
|
+
lineDashOffset: dashLength,
|
|
5875
|
+
lineWidth,
|
|
5876
|
+
stroke: strokeColor,
|
|
5877
|
+
strokeOpacity: fromOpacity
|
|
5878
|
+
};
|
|
5879
|
+
this.to = {
|
|
5880
|
+
lineDash: [dashLength, dashLength],
|
|
5881
|
+
lineDashOffset: 0,
|
|
5882
|
+
lineWidth,
|
|
5883
|
+
stroke: strokeColor,
|
|
5884
|
+
strokeOpacity: fromOpacity
|
|
5885
|
+
};
|
|
5886
|
+
if (showFill) {
|
|
5887
|
+
this.from.fillOpacity = fillOpacity;
|
|
5888
|
+
this.to.fillOpacity = (_t = this.originalAttributes.fillOpacity) !== null && _t !== void 0 ? _t : 1;
|
|
5889
|
+
}
|
|
5890
|
+
else {
|
|
5891
|
+
this.from.fillOpacity = 0;
|
|
5892
|
+
this.to.fillOpacity = 0;
|
|
5893
|
+
}
|
|
5894
|
+
this.propKeys = ['lineDash', 'lineDashOffset', 'lineWidth', 'stroke', 'strokeOpacity', 'fillOpacity'];
|
|
5895
|
+
this.props = this.to;
|
|
5896
|
+
this.target.setAttributes(this.from);
|
|
5897
|
+
}
|
|
5898
|
+
onUpdate(end, ratio, out) {
|
|
5899
|
+
var _a;
|
|
5900
|
+
const attribute = this.target.attribute;
|
|
5901
|
+
attribute.lineDashOffset = this.from.lineDashOffset + (this.to.lineDashOffset - this.from.lineDashOffset) * ratio;
|
|
5902
|
+
if ((_a = this.params) === null || _a === void 0 ? void 0 : _a.showFill) {
|
|
5903
|
+
attribute.fillOpacity = this.from.fillOpacity + (this.to.fillOpacity - this.from.fillOpacity) * ratio;
|
|
5904
|
+
}
|
|
5905
|
+
}
|
|
5906
|
+
onEnd() {
|
|
5907
|
+
var _a;
|
|
5908
|
+
super.onEnd();
|
|
5909
|
+
if (!((_a = this.params) === null || _a === void 0 ? void 0 : _a.showFill)) {
|
|
5910
|
+
const originalAttrs = Object.assign({}, this.originalAttributes);
|
|
5911
|
+
originalAttrs.fillOpacity = 0;
|
|
5912
|
+
this.target.setAttributes(originalAttrs);
|
|
5913
|
+
}
|
|
5914
|
+
}
|
|
5915
|
+
}
|
|
5916
|
+
class StrokeOut extends ACustomAnimate {
|
|
5917
|
+
constructor(from, to, duration, easing, params) {
|
|
5918
|
+
super(from, to, duration, easing, params);
|
|
5919
|
+
this.perimeter = 0;
|
|
5920
|
+
this.originalAttributes = {};
|
|
5921
|
+
}
|
|
5922
|
+
onFirstRun() {
|
|
5923
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
5924
|
+
this.originalAttributes = Object.assign({}, this.target.getAttributes());
|
|
5925
|
+
if (this.target.type === 'rect') {
|
|
5926
|
+
const attr = this.target.attribute;
|
|
5927
|
+
const width = (_a = attr.width) !== null && _a !== void 0 ? _a : 100;
|
|
5928
|
+
const height = (_b = attr.height) !== null && _b !== void 0 ? _b : 100;
|
|
5929
|
+
this.perimeter = 2 * (width + height);
|
|
5930
|
+
}
|
|
5931
|
+
else if (this.target.type === 'circle') {
|
|
5932
|
+
const attr = this.target.attribute;
|
|
5933
|
+
const radius = (_c = attr.radius) !== null && _c !== void 0 ? _c : 50;
|
|
5934
|
+
this.perimeter = 2 * Math.PI * radius;
|
|
5935
|
+
}
|
|
5936
|
+
else if (this.target.type === 'ellipse') {
|
|
5937
|
+
const attr = this.target.attribute;
|
|
5938
|
+
const radiusX = (_d = attr.radiusX) !== null && _d !== void 0 ? _d : 50;
|
|
5939
|
+
const radiusY = (_e = attr.radiusY) !== null && _e !== void 0 ? _e : 50;
|
|
5940
|
+
this.perimeter = 2 * Math.PI * Math.sqrt((radiusX * radiusX + radiusY * radiusY) / 2);
|
|
5941
|
+
}
|
|
5942
|
+
else {
|
|
5943
|
+
this.perimeter = 1000;
|
|
5944
|
+
}
|
|
5945
|
+
const lineWidth = (_g = (_f = this.params) === null || _f === void 0 ? void 0 : _f.lineWidth) !== null && _g !== void 0 ? _g : 2;
|
|
5946
|
+
const strokeColor = (_j = (_h = this.params) === null || _h === void 0 ? void 0 : _h.strokeColor) !== null && _j !== void 0 ? _j : 'black';
|
|
5947
|
+
const fromOpacity = (_l = (_k = this.params) === null || _k === void 0 ? void 0 : _k.fromOpacity) !== null && _l !== void 0 ? _l : 1;
|
|
5948
|
+
const dashLength = (_o = (_m = this.params) === null || _m === void 0 ? void 0 : _m.dashLength) !== null && _o !== void 0 ? _o : this.perimeter;
|
|
5949
|
+
const showFill = (_q = (_p = this.params) === null || _p === void 0 ? void 0 : _p.showFill) !== null && _q !== void 0 ? _q : false;
|
|
5950
|
+
this.from = {
|
|
5951
|
+
lineDash: [dashLength, dashLength],
|
|
5952
|
+
lineDashOffset: 0,
|
|
5953
|
+
lineWidth,
|
|
5954
|
+
stroke: strokeColor,
|
|
5955
|
+
strokeOpacity: fromOpacity
|
|
5956
|
+
};
|
|
5957
|
+
this.to = {
|
|
5958
|
+
lineDash: [dashLength, dashLength],
|
|
5959
|
+
lineDashOffset: -dashLength,
|
|
5960
|
+
lineWidth,
|
|
5961
|
+
stroke: strokeColor,
|
|
5962
|
+
strokeOpacity: fromOpacity
|
|
5963
|
+
};
|
|
5964
|
+
if (showFill) {
|
|
5965
|
+
this.from.fillOpacity = (_r = this.originalAttributes.fillOpacity) !== null && _r !== void 0 ? _r : 1;
|
|
5966
|
+
this.to.fillOpacity = 0;
|
|
5967
|
+
}
|
|
5968
|
+
else {
|
|
5969
|
+
this.from.fillOpacity = 0;
|
|
5970
|
+
this.to.fillOpacity = 0;
|
|
5971
|
+
}
|
|
5972
|
+
this.propKeys = ['lineDash', 'lineDashOffset', 'lineWidth', 'stroke', 'strokeOpacity', 'fillOpacity'];
|
|
5973
|
+
this.props = this.to;
|
|
5974
|
+
this.target.setAttributes(this.from);
|
|
5975
|
+
}
|
|
5976
|
+
onUpdate(end, ratio, out) {
|
|
5977
|
+
var _a;
|
|
5978
|
+
const attribute = this.target.attribute;
|
|
5979
|
+
attribute.lineDashOffset = this.from.lineDashOffset + (this.to.lineDashOffset - this.from.lineDashOffset) * ratio;
|
|
5980
|
+
if ((_a = this.params) === null || _a === void 0 ? void 0 : _a.showFill) {
|
|
5981
|
+
attribute.fillOpacity = this.from.fillOpacity + (this.to.fillOpacity - this.from.fillOpacity) * ratio;
|
|
5982
|
+
}
|
|
5983
|
+
}
|
|
5984
|
+
}
|
|
5300
5985
|
class MoveScaleIn extends ACustomAnimate {
|
|
5301
5986
|
constructor(from, to, duration, easing, params) {
|
|
5302
5987
|
var _a;
|
|
@@ -5575,6 +6260,121 @@ class MoveRotateOut extends ACustomAnimate {
|
|
|
5575
6260
|
onUpdate(end, ratio, out) {
|
|
5576
6261
|
}
|
|
5577
6262
|
}
|
|
6263
|
+
class PulseAnimate extends ACustomAnimate {
|
|
6264
|
+
constructor(from, to, duration, easing, params) {
|
|
6265
|
+
super(from, to, duration, easing, params);
|
|
6266
|
+
this.originalAttributes = {};
|
|
6267
|
+
this.pulseCount = 3;
|
|
6268
|
+
this.pulseOpacity = 0.3;
|
|
6269
|
+
this.pulseScale = 1.05;
|
|
6270
|
+
this.pulseColor = null;
|
|
6271
|
+
this.pulseColorIntensity = 0.2;
|
|
6272
|
+
this.strokeOnly = false;
|
|
6273
|
+
this.fillOnly = false;
|
|
6274
|
+
this.useScale = true;
|
|
6275
|
+
this.useOpacity = true;
|
|
6276
|
+
this.useStroke = true;
|
|
6277
|
+
this.useFill = true;
|
|
6278
|
+
this.useColor = false;
|
|
6279
|
+
this.originalFill = null;
|
|
6280
|
+
this.originalStroke = null;
|
|
6281
|
+
if ((params === null || params === void 0 ? void 0 : params.pulseCount) !== undefined) {
|
|
6282
|
+
this.pulseCount = params.pulseCount;
|
|
6283
|
+
}
|
|
6284
|
+
if ((params === null || params === void 0 ? void 0 : params.pulseScale) !== undefined) {
|
|
6285
|
+
this.pulseScale = params.pulseScale;
|
|
6286
|
+
}
|
|
6287
|
+
if ((params === null || params === void 0 ? void 0 : params.pulseColor) !== undefined) {
|
|
6288
|
+
this.pulseColor = params.pulseColor;
|
|
6289
|
+
}
|
|
6290
|
+
if ((params === null || params === void 0 ? void 0 : params.pulseColorIntensity) !== undefined) {
|
|
6291
|
+
this.pulseColorIntensity = params.pulseColorIntensity;
|
|
6292
|
+
}
|
|
6293
|
+
if ((params === null || params === void 0 ? void 0 : params.strokeOnly) !== undefined) {
|
|
6294
|
+
this.strokeOnly = params.strokeOnly;
|
|
6295
|
+
}
|
|
6296
|
+
if ((params === null || params === void 0 ? void 0 : params.fillOnly) !== undefined) {
|
|
6297
|
+
this.fillOnly = params.fillOnly;
|
|
6298
|
+
}
|
|
6299
|
+
if ((params === null || params === void 0 ? void 0 : params.useScale) !== undefined) {
|
|
6300
|
+
this.useScale = params.useScale;
|
|
6301
|
+
}
|
|
6302
|
+
if ((params === null || params === void 0 ? void 0 : params.useOpacity) !== undefined) {
|
|
6303
|
+
this.useOpacity = params.useOpacity;
|
|
6304
|
+
}
|
|
6305
|
+
if ((params === null || params === void 0 ? void 0 : params.useStroke) !== undefined) {
|
|
6306
|
+
this.useStroke = params.useStroke;
|
|
6307
|
+
}
|
|
6308
|
+
if ((params === null || params === void 0 ? void 0 : params.useFill) !== undefined) {
|
|
6309
|
+
this.useFill = params.useFill;
|
|
6310
|
+
}
|
|
6311
|
+
if ((params === null || params === void 0 ? void 0 : params.useColor) !== undefined) {
|
|
6312
|
+
this.useColor = params.useColor;
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6315
|
+
onBind() {
|
|
6316
|
+
super.onBind();
|
|
6317
|
+
this.originalAttributes = Object.assign({}, this.target.getAttributes());
|
|
6318
|
+
if (this.useColor) {
|
|
6319
|
+
this.originalFill = this.originalAttributes.fill || null;
|
|
6320
|
+
this.originalStroke = this.originalAttributes.stroke || null;
|
|
6321
|
+
if (!this.pulseColor) {
|
|
6322
|
+
if (this.fillOnly && this.originalFill) {
|
|
6323
|
+
this.pulseColor = this.originalFill;
|
|
6324
|
+
}
|
|
6325
|
+
else if (this.strokeOnly && this.originalStroke) {
|
|
6326
|
+
this.pulseColor = this.originalStroke;
|
|
6327
|
+
}
|
|
6328
|
+
else if (this.originalFill) {
|
|
6329
|
+
this.pulseColor = this.originalFill;
|
|
6330
|
+
}
|
|
6331
|
+
else if (this.originalStroke) {
|
|
6332
|
+
this.pulseColor = this.originalStroke;
|
|
6333
|
+
}
|
|
6334
|
+
else {
|
|
6335
|
+
this.pulseColor = '#FFFFFF';
|
|
6336
|
+
}
|
|
6337
|
+
}
|
|
6338
|
+
}
|
|
6339
|
+
}
|
|
6340
|
+
onUpdate(end, ratio, out) {
|
|
6341
|
+
const angle = ratio * Math.PI * this.pulseCount;
|
|
6342
|
+
const pulseValue = Math.abs(Math.sin(angle));
|
|
6343
|
+
const attribute = this.target.attribute;
|
|
6344
|
+
if (this.useOpacity) {
|
|
6345
|
+
const opacity = 1 + (this.pulseOpacity - 1) * pulseValue;
|
|
6346
|
+
if (this.useStroke) {
|
|
6347
|
+
attribute.strokeOpacity = (this.originalAttributes.strokeOpacity || 1) * opacity;
|
|
6348
|
+
}
|
|
6349
|
+
if (this.useFill) {
|
|
6350
|
+
attribute.fillOpacity = (this.originalAttributes.fillOpacity || 1) * opacity;
|
|
6351
|
+
}
|
|
6352
|
+
}
|
|
6353
|
+
if (this.useScale) {
|
|
6354
|
+
const scale = 1 + (this.pulseScale - 1) * pulseValue;
|
|
6355
|
+
attribute.scaleX = (this.originalAttributes.scaleX || 1) * scale;
|
|
6356
|
+
attribute.scaleY = (this.originalAttributes.scaleY || 1) * scale;
|
|
6357
|
+
}
|
|
6358
|
+
if (this.useColor && this.pulseColor) {
|
|
6359
|
+
this.applyColorPulse(attribute, pulseValue);
|
|
6360
|
+
}
|
|
6361
|
+
this.target.addUpdateShapeAndBoundsTag();
|
|
6362
|
+
this.target.addUpdatePositionTag();
|
|
6363
|
+
}
|
|
6364
|
+
applyColorPulse(attribute, pulseValue) {
|
|
6365
|
+
const colorRatio = this.pulseColorIntensity * pulseValue;
|
|
6366
|
+
if (this.useFill && this.originalFill && this.pulseColor) {
|
|
6367
|
+
attribute.fill = interpolateColor(this.originalFill, this.pulseColor, colorRatio, true);
|
|
6368
|
+
}
|
|
6369
|
+
if (this.useStroke && this.originalStroke && this.pulseColor) {
|
|
6370
|
+
attribute.stroke = interpolateColor(this.originalStroke, this.pulseColor, colorRatio, true);
|
|
6371
|
+
}
|
|
6372
|
+
}
|
|
6373
|
+
onEnd() {
|
|
6374
|
+
super.onEnd();
|
|
6375
|
+
this.target.setAttributes(this.originalAttributes);
|
|
6376
|
+
}
|
|
6377
|
+
}
|
|
5578
6378
|
|
|
5579
6379
|
class Update extends ACustomAnimate {
|
|
5580
6380
|
constructor(from, to, duration, easing, params) {
|
|
@@ -5615,18 +6415,18 @@ class Update extends ACustomAnimate {
|
|
|
5615
6415
|
}
|
|
5616
6416
|
|
|
5617
6417
|
const moveIn = (graphic, options, animationParameters) => {
|
|
5618
|
-
var _a, _b;
|
|
5619
|
-
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 : {};
|
|
5620
6420
|
let changedX = 0;
|
|
5621
6421
|
let changedY = 0;
|
|
5622
6422
|
if (orient === 'negative') {
|
|
5623
|
-
changedX = graphic.stage.viewWidth;
|
|
5624
|
-
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;
|
|
5625
6425
|
}
|
|
5626
6426
|
changedX += offset;
|
|
5627
6427
|
changedY += offset;
|
|
5628
6428
|
const point = isFunction(pointOpt)
|
|
5629
|
-
? pointOpt.call(null, (
|
|
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)
|
|
5630
6430
|
: pointOpt;
|
|
5631
6431
|
const fromX = point && isValidNumber(point.x) ? point.x : changedX;
|
|
5632
6432
|
const fromY = point && isValidNumber(point.y) ? point.y : changedY;
|
|
@@ -5656,14 +6456,14 @@ const moveIn = (graphic, options, animationParameters) => {
|
|
|
5656
6456
|
}
|
|
5657
6457
|
};
|
|
5658
6458
|
const moveOut = (graphic, options, animationParameters) => {
|
|
5659
|
-
var _a, _b;
|
|
6459
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5660
6460
|
const { offset = 0, orient, direction, point: pointOpt } = options !== null && options !== void 0 ? options : {};
|
|
5661
|
-
const groupWidth = graphic.stage.viewWidth;
|
|
5662
|
-
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;
|
|
5663
6463
|
const changedX = (orient === 'negative' ? groupWidth : 0) + offset;
|
|
5664
6464
|
const changedY = (orient === 'negative' ? groupHeight : 0) + offset;
|
|
5665
6465
|
const point = isFunction(pointOpt)
|
|
5666
|
-
? pointOpt.call(null, (
|
|
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)
|
|
5667
6467
|
: pointOpt;
|
|
5668
6468
|
const fromX = point && isValidNumber(point.x) ? point.x : changedX;
|
|
5669
6469
|
const fromY = point && isValidNumber(point.y) ? point.y : changedY;
|
|
@@ -6193,13 +6993,16 @@ const registerCustomAnimate = () => {
|
|
|
6193
6993
|
AnimateExecutor.registerBuiltInAnimate('spinIn', SpinIn);
|
|
6194
6994
|
AnimateExecutor.registerBuiltInAnimate('moveScaleIn', MoveScaleIn);
|
|
6195
6995
|
AnimateExecutor.registerBuiltInAnimate('moveRotateIn', MoveRotateIn);
|
|
6996
|
+
AnimateExecutor.registerBuiltInAnimate('strokeIn', StrokeIn);
|
|
6196
6997
|
AnimateExecutor.registerBuiltInAnimate('slideOut', SlideOut);
|
|
6197
6998
|
AnimateExecutor.registerBuiltInAnimate('growOut', GrowOut);
|
|
6198
6999
|
AnimateExecutor.registerBuiltInAnimate('spinOut', SpinOut);
|
|
6199
7000
|
AnimateExecutor.registerBuiltInAnimate('moveScaleOut', MoveScaleOut);
|
|
6200
7001
|
AnimateExecutor.registerBuiltInAnimate('moveRotateOut', MoveRotateOut);
|
|
7002
|
+
AnimateExecutor.registerBuiltInAnimate('strokeOut', StrokeOut);
|
|
7003
|
+
AnimateExecutor.registerBuiltInAnimate('pulse', PulseAnimate);
|
|
6201
7004
|
AnimateExecutor.registerBuiltInAnimate('MotionPath', MotionPath);
|
|
6202
7005
|
AnimateExecutor.registerBuiltInAnimate('streamLight', StreamLight);
|
|
6203
7006
|
};
|
|
6204
7007
|
|
|
6205
|
-
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, RotateBySphereAnimate, RotateIn, RotateOut, ScaleIn, ScaleOut, SlideIn, SlideOut, SlideOutRichText, SlideRichText, SpinIn, SpinOut, State, StreamLight, 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 };
|