@visactor/vrender-animate 1.0.0-alpha.3 → 1.0.0-alpha.4
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-extension.d.ts +1 -0
- package/cjs/animate-extension.js +3 -0
- package/cjs/animate-extension.js.map +1 -1
- package/cjs/animate.d.ts +1 -0
- package/cjs/animate.js +6 -4
- package/cjs/animate.js.map +1 -1
- package/cjs/custom/clip.js +3 -1
- package/cjs/custom/clip.js.map +1 -1
- package/cjs/custom/common.d.ts +0 -1
- package/cjs/custom/common.js +5 -8
- package/cjs/custom/common.js.map +1 -1
- package/cjs/custom/fade.js +3 -1
- package/cjs/custom/fade.js.map +1 -1
- package/cjs/custom/fromTo.js +3 -1
- package/cjs/custom/fromTo.js.map +1 -1
- package/cjs/custom/groupFade.js +3 -1
- package/cjs/custom/groupFade.js.map +1 -1
- package/cjs/custom/growPoints.js +22 -21
- package/cjs/custom/growPoints.js.map +1 -1
- package/cjs/custom/move.js +7 -8
- package/cjs/custom/move.js.map +1 -1
- package/cjs/custom/rotate.js +2 -1
- package/cjs/custom/rotate.js.map +1 -1
- package/cjs/custom/scale.js +2 -2
- package/cjs/custom/scale.js.map +1 -1
- package/cjs/executor/animate-executor.d.ts +1 -1
- package/cjs/executor/animate-executor.js +56 -52
- package/cjs/executor/animate-executor.js.map +1 -1
- package/cjs/step.d.ts +2 -0
- package/cjs/step.js +8 -1
- package/cjs/step.js.map +1 -1
- package/cjs/ticker/manual-ticker.d.ts +5 -1
- package/cjs/ticker/manual-ticker.js +21 -1
- package/cjs/ticker/manual-ticker.js.map +1 -1
- package/cjs/timeline.d.ts +0 -1
- package/cjs/timeline.js.map +1 -1
- package/dist/index.es.js +172 -93
- package/es/animate-extension.d.ts +1 -0
- package/es/animate-extension.js +3 -0
- package/es/animate-extension.js.map +1 -1
- package/es/animate.d.ts +1 -0
- package/es/animate.js +6 -4
- package/es/animate.js.map +1 -1
- package/es/custom/clip.js +3 -1
- package/es/custom/clip.js.map +1 -1
- package/es/custom/common.d.ts +0 -1
- package/es/custom/common.js +5 -8
- package/es/custom/common.js.map +1 -1
- package/es/custom/fade.js +3 -1
- package/es/custom/fade.js.map +1 -1
- package/es/custom/fromTo.js +3 -1
- package/es/custom/fromTo.js.map +1 -1
- package/es/custom/groupFade.js +3 -1
- package/es/custom/groupFade.js.map +1 -1
- package/es/custom/growPoints.js +22 -21
- package/es/custom/growPoints.js.map +1 -1
- package/es/custom/move.js +6 -7
- package/es/custom/move.js.map +1 -1
- package/es/custom/rotate.js +2 -1
- package/es/custom/rotate.js.map +1 -1
- package/es/custom/scale.js +2 -2
- package/es/custom/scale.js.map +1 -1
- package/es/executor/animate-executor.d.ts +1 -1
- package/es/executor/animate-executor.js +55 -51
- package/es/executor/animate-executor.js.map +1 -1
- package/es/step.d.ts +2 -0
- package/es/step.js +8 -1
- package/es/step.js.map +1 -1
- package/es/ticker/manual-ticker.d.ts +5 -1
- package/es/ticker/manual-ticker.js +22 -0
- package/es/ticker/manual-ticker.js.map +1 -1
- package/es/timeline.d.ts +0 -1
- package/es/timeline.js.map +1 -1
- package/package.json +4 -4
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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, isArray, isFunction, mixin, isValidNumber, clamp, Point, pi, isNumber, isValid, isNil, isNumberClose, PointService } from '@visactor/vutils';
|
|
2
|
+
import { pi2, isString, EventEmitter, cloneDeep, isArray, isFunction, mixin, isValidNumber, clamp, Point, pi, isNumber, isValid, isNil, isNumberClose, PointService } from '@visactor/vutils';
|
|
3
3
|
|
|
4
4
|
class Easing {
|
|
5
5
|
constructor() {
|
|
@@ -477,7 +477,7 @@ class Step {
|
|
|
477
477
|
const animate = this.animate;
|
|
478
478
|
const target = this.target;
|
|
479
479
|
target.animates.forEach((a) => {
|
|
480
|
-
if (a === animate || a.priority > animate.priority) {
|
|
480
|
+
if (a === animate || a.priority > animate.priority || a.priority === Infinity) {
|
|
481
481
|
return;
|
|
482
482
|
}
|
|
483
483
|
const fromProps = a.getStartProps();
|
|
@@ -550,6 +550,13 @@ class WaitStep extends Step {
|
|
|
550
550
|
constructor(type, props, duration, easing) {
|
|
551
551
|
super(type, props, duration, easing);
|
|
552
552
|
}
|
|
553
|
+
onStart() {
|
|
554
|
+
super.onStart();
|
|
555
|
+
}
|
|
556
|
+
onFirstRun() {
|
|
557
|
+
const fromProps = this.getFromProps();
|
|
558
|
+
this.target.setAttributes(fromProps);
|
|
559
|
+
}
|
|
553
560
|
update(end, ratio, out) {
|
|
554
561
|
this.onStart();
|
|
555
562
|
}
|
|
@@ -957,7 +964,7 @@ class Animate {
|
|
|
957
964
|
return this;
|
|
958
965
|
}
|
|
959
966
|
advance(delta) {
|
|
960
|
-
var _a;
|
|
967
|
+
var _a, _b, _c;
|
|
961
968
|
if (this.status === AnimateStatus.END) {
|
|
962
969
|
console.warn('aaa 动画已经结束,不能推进');
|
|
963
970
|
return;
|
|
@@ -968,7 +975,8 @@ class Animate {
|
|
|
968
975
|
return;
|
|
969
976
|
}
|
|
970
977
|
if (nextTime >= this._startTime + this._totalDuration) {
|
|
971
|
-
(_a = this._lastStep) === null || _a === void 0 ? void 0 : _a.
|
|
978
|
+
(_a = this._lastStep) === null || _a === void 0 ? void 0 : _a.onUpdate(true, 1, {});
|
|
979
|
+
(_b = this._lastStep) === null || _b === void 0 ? void 0 : _b.onEnd();
|
|
972
980
|
this.onEnd();
|
|
973
981
|
this.status = AnimateStatus.END;
|
|
974
982
|
return;
|
|
@@ -1014,6 +1022,10 @@ class Animate {
|
|
|
1014
1022
|
if (!targetStep) {
|
|
1015
1023
|
return;
|
|
1016
1024
|
}
|
|
1025
|
+
if (targetStep !== this.lastRunStep) {
|
|
1026
|
+
(_c = this.lastRunStep) === null || _c === void 0 ? void 0 : _c.onEnd();
|
|
1027
|
+
}
|
|
1028
|
+
this.lastRunStep = targetStep;
|
|
1017
1029
|
const stepStartTime = targetStep.getStartTime();
|
|
1018
1030
|
const stepDuration = targetStep.getDuration();
|
|
1019
1031
|
const ratio = (cycleTime - stepStartTime) / stepDuration;
|
|
@@ -1021,6 +1033,7 @@ class Animate {
|
|
|
1021
1033
|
targetStep.update(isEnd, ratio, {});
|
|
1022
1034
|
if (isEnd) {
|
|
1023
1035
|
targetStep.onEnd();
|
|
1036
|
+
this.lastRunStep = null;
|
|
1024
1037
|
}
|
|
1025
1038
|
}
|
|
1026
1039
|
updateDuration() {
|
|
@@ -1259,8 +1272,21 @@ class ManualTickHandler {
|
|
|
1259
1272
|
getTime() {
|
|
1260
1273
|
return this.currentTime;
|
|
1261
1274
|
}
|
|
1275
|
+
tickTo(time, cb) {
|
|
1276
|
+
if (this.startTime < 0) {
|
|
1277
|
+
this.startTime = 0;
|
|
1278
|
+
this.currentTime = 0;
|
|
1279
|
+
}
|
|
1280
|
+
const interval = time - this.currentTime;
|
|
1281
|
+
this.tick(interval, cb);
|
|
1282
|
+
}
|
|
1262
1283
|
}
|
|
1263
1284
|
class ManualTicker extends DefaultTicker {
|
|
1285
|
+
constructor(stage) {
|
|
1286
|
+
super(stage);
|
|
1287
|
+
this.lastFrameTime = 0;
|
|
1288
|
+
this.status = STATUS.RUNNING;
|
|
1289
|
+
}
|
|
1264
1290
|
setupTickHandler() {
|
|
1265
1291
|
const handler = new ManualTickHandler();
|
|
1266
1292
|
if (this.tickerHandler) {
|
|
@@ -1272,6 +1298,27 @@ class ManualTicker extends DefaultTicker {
|
|
|
1272
1298
|
getTime() {
|
|
1273
1299
|
return this.tickerHandler.getTime();
|
|
1274
1300
|
}
|
|
1301
|
+
tickAt(time) {
|
|
1302
|
+
this.tickTo(time);
|
|
1303
|
+
}
|
|
1304
|
+
start(force = false) {
|
|
1305
|
+
if (this.status === STATUS.RUNNING) {
|
|
1306
|
+
return false;
|
|
1307
|
+
}
|
|
1308
|
+
if (!this.tickerHandler) {
|
|
1309
|
+
return false;
|
|
1310
|
+
}
|
|
1311
|
+
if (!force) {
|
|
1312
|
+
if (this.status === STATUS.PAUSE) {
|
|
1313
|
+
return false;
|
|
1314
|
+
}
|
|
1315
|
+
if (this.ifCanStop()) {
|
|
1316
|
+
return false;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
this.status = STATUS.RUNNING;
|
|
1320
|
+
return true;
|
|
1321
|
+
}
|
|
1275
1322
|
}
|
|
1276
1323
|
|
|
1277
1324
|
function generatorPathEasingFunc(path) {
|
|
@@ -1456,15 +1503,15 @@ class AnimateExecutor {
|
|
|
1456
1503
|
}
|
|
1457
1504
|
});
|
|
1458
1505
|
}
|
|
1459
|
-
parseParams(params, isTimeline) {
|
|
1506
|
+
parseParams(params, isTimeline, child) {
|
|
1460
1507
|
var _a, _b;
|
|
1461
1508
|
const totalTime = this.resolveValue(params.totalTime, undefined, undefined);
|
|
1462
1509
|
const startTime = this.resolveValue(params.startTime, undefined, 0);
|
|
1463
|
-
const parsedParams =
|
|
1510
|
+
const parsedParams = cloneDeep(params);
|
|
1464
1511
|
parsedParams.oneByOneDelay = 0;
|
|
1465
1512
|
parsedParams.startTime = startTime;
|
|
1466
1513
|
parsedParams.totalTime = totalTime;
|
|
1467
|
-
const oneByOne = this.resolveValue(params.oneByOne,
|
|
1514
|
+
const oneByOne = this.resolveValue(params.oneByOne, child, false);
|
|
1468
1515
|
if (isTimeline) {
|
|
1469
1516
|
const timeSlices = parsedParams.timeSlices;
|
|
1470
1517
|
if (!isArray(timeSlices)) {
|
|
@@ -1472,9 +1519,9 @@ class AnimateExecutor {
|
|
|
1472
1519
|
}
|
|
1473
1520
|
let sliceTime = 0;
|
|
1474
1521
|
parsedParams.timeSlices.forEach(slice => {
|
|
1475
|
-
slice.delay = this.resolveValue(slice.delay,
|
|
1476
|
-
slice.delayAfter = this.resolveValue(slice.delayAfter,
|
|
1477
|
-
slice.duration = this.resolveValue(slice.duration,
|
|
1522
|
+
slice.delay = this.resolveValue(slice.delay, child, 0);
|
|
1523
|
+
slice.delayAfter = this.resolveValue(slice.delayAfter, child, 0);
|
|
1524
|
+
slice.duration = this.resolveValue(slice.duration, child, 300);
|
|
1478
1525
|
sliceTime += slice.delay + slice.duration + slice.delayAfter;
|
|
1479
1526
|
});
|
|
1480
1527
|
let oneByOneDelay = 0;
|
|
@@ -1485,31 +1532,32 @@ class AnimateExecutor {
|
|
|
1485
1532
|
}
|
|
1486
1533
|
parsedParams.oneByOne = oneByOneTime;
|
|
1487
1534
|
parsedParams.oneByOneDelay = oneByOneDelay;
|
|
1535
|
+
let scale = 1;
|
|
1488
1536
|
if (totalTime) {
|
|
1489
1537
|
const _totalTime = sliceTime + oneByOneDelay * (this._target.count - 2);
|
|
1490
|
-
|
|
1491
|
-
parsedParams.timeSlices = parsedParams.timeSlices.map(slice => {
|
|
1492
|
-
let effects = slice.effects;
|
|
1493
|
-
if (!Array.isArray(effects)) {
|
|
1494
|
-
effects = [effects];
|
|
1495
|
-
}
|
|
1496
|
-
return Object.assign(Object.assign({}, slice), { delay: slice.delay * scale, delayAfter: slice.delayAfter * scale, duration: slice.duration * scale, effects: effects.map(effect => {
|
|
1497
|
-
var _a, _b;
|
|
1498
|
-
const custom = (_a = effect.custom) !== null && _a !== void 0 ? _a : AnimateExecutor.builtInAnimateMap[(_b = effect.type) !== null && _b !== void 0 ? _b : 'fromTo'];
|
|
1499
|
-
const customType = custom && isFunction(custom) ? (/^class\s/.test(Function.prototype.toString.call(custom)) ? 1 : 2) : 0;
|
|
1500
|
-
return Object.assign(Object.assign({}, effect), { custom,
|
|
1501
|
-
customType });
|
|
1502
|
-
}) });
|
|
1503
|
-
});
|
|
1504
|
-
parsedParams.oneByOne = oneByOneTime * scale;
|
|
1505
|
-
parsedParams.oneByOneDelay = oneByOneDelay * scale;
|
|
1506
|
-
parsedParams.startTime = startTime * scale;
|
|
1538
|
+
scale = totalTime ? totalTime / _totalTime : 1;
|
|
1507
1539
|
}
|
|
1540
|
+
parsedParams.timeSlices = parsedParams.timeSlices.map(slice => {
|
|
1541
|
+
let effects = slice.effects;
|
|
1542
|
+
if (!Array.isArray(effects)) {
|
|
1543
|
+
effects = [effects];
|
|
1544
|
+
}
|
|
1545
|
+
return Object.assign(Object.assign({}, slice), { delay: slice.delay * scale, delayAfter: slice.delayAfter * scale, duration: slice.duration * scale, effects: effects.map(effect => {
|
|
1546
|
+
var _a, _b;
|
|
1547
|
+
const custom = (_a = effect.custom) !== null && _a !== void 0 ? _a : AnimateExecutor.builtInAnimateMap[(_b = effect.type) !== null && _b !== void 0 ? _b : 'fromTo'];
|
|
1548
|
+
const customType = custom && isFunction(custom) ? (/^class\s/.test(Function.prototype.toString.call(custom)) ? 1 : 2) : 0;
|
|
1549
|
+
return Object.assign(Object.assign({}, effect), { custom,
|
|
1550
|
+
customType });
|
|
1551
|
+
}) });
|
|
1552
|
+
});
|
|
1553
|
+
parsedParams.oneByOne = oneByOneTime * scale;
|
|
1554
|
+
parsedParams.oneByOneDelay = oneByOneDelay * scale;
|
|
1555
|
+
parsedParams.startTime = startTime * scale;
|
|
1508
1556
|
}
|
|
1509
1557
|
else {
|
|
1510
|
-
const delay = this.resolveValue(params.delay,
|
|
1511
|
-
const delayAfter = this.resolveValue(params.delayAfter,
|
|
1512
|
-
const duration = this.resolveValue(params.duration,
|
|
1558
|
+
const delay = this.resolveValue(params.delay, child, 0);
|
|
1559
|
+
const delayAfter = this.resolveValue(params.delayAfter, child, 0);
|
|
1560
|
+
const duration = this.resolveValue(params.duration, child, 300);
|
|
1513
1561
|
let oneByOneDelay = 0;
|
|
1514
1562
|
let oneByOneTime = 0;
|
|
1515
1563
|
if (oneByOne) {
|
|
@@ -1555,26 +1603,27 @@ class AnimateExecutor {
|
|
|
1555
1603
|
let filteredChildren;
|
|
1556
1604
|
if (isTimeline && params.partitioner) {
|
|
1557
1605
|
filteredChildren = (filteredChildren !== null && filteredChildren !== void 0 ? filteredChildren : this._target.getChildren()).filter(child => {
|
|
1558
|
-
var _a;
|
|
1559
|
-
return params.partitioner((_a = child.context) === null || _a === void 0 ? void 0 : _a.data, child, {});
|
|
1606
|
+
var _a, _b;
|
|
1607
|
+
return params.partitioner((_b = (_a = child.context) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[0], child, {});
|
|
1560
1608
|
});
|
|
1561
1609
|
}
|
|
1562
1610
|
if (isTimeline && params.sort) {
|
|
1563
1611
|
filteredChildren = filteredChildren !== null && filteredChildren !== void 0 ? filteredChildren : this._target.getChildren();
|
|
1564
1612
|
filteredChildren.sort((a, b) => {
|
|
1565
|
-
var _a, _b;
|
|
1566
|
-
return params.sort((_a = a.context) === null || _a === void 0 ? void 0 : _a.data, (
|
|
1613
|
+
var _a, _b, _c, _d;
|
|
1614
|
+
return params.sort((_b = (_a = a.context) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[0], (_d = (_c = b.context) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d[0], a, b, {});
|
|
1567
1615
|
});
|
|
1568
1616
|
}
|
|
1569
|
-
const parsedParams = this.parseParams(params, isTimeline);
|
|
1570
1617
|
const cb = isTimeline
|
|
1571
1618
|
? (child, index, count) => {
|
|
1619
|
+
const parsedParams = this.parseParams(params, isTimeline, child);
|
|
1572
1620
|
const animate = this.executeTimelineItem(parsedParams, child, index, count);
|
|
1573
1621
|
if (animate) {
|
|
1574
1622
|
this._trackAnimation(animate);
|
|
1575
1623
|
}
|
|
1576
1624
|
}
|
|
1577
1625
|
: (child, index, count) => {
|
|
1626
|
+
const parsedParams = this.parseParams(params, isTimeline, child);
|
|
1578
1627
|
const animate = this.executeTypeConfigItem(parsedParams, child, index, count);
|
|
1579
1628
|
if (animate) {
|
|
1580
1629
|
this._trackAnimation(animate);
|
|
@@ -1602,8 +1651,8 @@ class AnimateExecutor {
|
|
|
1602
1651
|
if (datum && indexKey) {
|
|
1603
1652
|
index = (_f = datum[indexKey]) !== null && _f !== void 0 ? _f : index;
|
|
1604
1653
|
}
|
|
1605
|
-
animate.startAt(startTime
|
|
1606
|
-
const wait = index * oneByOneDelay;
|
|
1654
|
+
animate.startAt(startTime);
|
|
1655
|
+
const wait = index * oneByOneDelay + delayValue;
|
|
1607
1656
|
wait > 0 && animate.wait(wait);
|
|
1608
1657
|
let parsedFromProps = null;
|
|
1609
1658
|
let props = params.to;
|
|
@@ -1620,13 +1669,17 @@ class AnimateExecutor {
|
|
|
1620
1669
|
}
|
|
1621
1670
|
from = parsedFromProps.from;
|
|
1622
1671
|
}
|
|
1623
|
-
this._handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, options, type, graphic);
|
|
1672
|
+
this._handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic);
|
|
1673
|
+
let totalDelay = 0;
|
|
1624
1674
|
if (oneByOneDelay) {
|
|
1625
|
-
|
|
1675
|
+
totalDelay = oneByOneDelay * (count - index - 1);
|
|
1626
1676
|
}
|
|
1627
1677
|
const delayAfterValue = isFunction(delayAfter) ? delayAfter((_h = (_g = graphic.context) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h[0], graphic, {}) : delayAfter;
|
|
1628
1678
|
if (delayAfterValue > 0) {
|
|
1629
|
-
|
|
1679
|
+
totalDelay += delayAfterValue;
|
|
1680
|
+
}
|
|
1681
|
+
if (totalDelay > 0) {
|
|
1682
|
+
animate.wait(totalDelay);
|
|
1630
1683
|
}
|
|
1631
1684
|
if (loop && loop > 0) {
|
|
1632
1685
|
animate.loop(loop);
|
|
@@ -1636,7 +1689,7 @@ class AnimateExecutor {
|
|
|
1636
1689
|
}
|
|
1637
1690
|
return animate;
|
|
1638
1691
|
}
|
|
1639
|
-
_handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, options, type, graphic) {
|
|
1692
|
+
_handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic) {
|
|
1640
1693
|
var _a, _b, _c, _d;
|
|
1641
1694
|
if (custom && customType) {
|
|
1642
1695
|
const customParams = this.resolveValue(customParameters, graphic, {});
|
|
@@ -1644,6 +1697,7 @@ class AnimateExecutor {
|
|
|
1644
1697
|
? options.call(null, (_b = (customParams && ((_a = customParams.data) === null || _a === void 0 ? void 0 : _a[0]))) !== null && _b !== void 0 ? _b : (_d = (_c = graphic.context) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d[0], graphic, customParams)
|
|
1645
1698
|
: options;
|
|
1646
1699
|
customParams.options = objOptions;
|
|
1700
|
+
customParams.controlOptions = controlOptions;
|
|
1647
1701
|
if (customType === 1) {
|
|
1648
1702
|
this.createCustomAnimation(animate, custom, from, props, duration, easing, customParams);
|
|
1649
1703
|
}
|
|
@@ -1695,7 +1749,7 @@ class AnimateExecutor {
|
|
|
1695
1749
|
}
|
|
1696
1750
|
const effectsArray = Array.isArray(effects) ? effects : [effects];
|
|
1697
1751
|
effectsArray.forEach(effect => {
|
|
1698
|
-
var _a
|
|
1752
|
+
var _a;
|
|
1699
1753
|
const { type = 'fromTo', channel, customParameters, easing = 'linear', options } = effect;
|
|
1700
1754
|
let parsedFromProps = null;
|
|
1701
1755
|
let props = effect.to;
|
|
@@ -1713,8 +1767,8 @@ class AnimateExecutor {
|
|
|
1713
1767
|
from = parsedFromProps.from;
|
|
1714
1768
|
}
|
|
1715
1769
|
const custom = (_a = effect.custom) !== null && _a !== void 0 ? _a : AnimateExecutor.builtInAnimateMap[type];
|
|
1716
|
-
const customType =
|
|
1717
|
-
this._handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, options, type, graphic);
|
|
1770
|
+
const customType = effect.customType;
|
|
1771
|
+
this._handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, null, options, type, graphic);
|
|
1718
1772
|
});
|
|
1719
1773
|
if (delayAfterValue > 0) {
|
|
1720
1774
|
animate.wait(delayAfterValue);
|
|
@@ -1746,11 +1800,11 @@ class AnimateExecutor {
|
|
|
1746
1800
|
}
|
|
1747
1801
|
if (!Array.isArray(channel)) {
|
|
1748
1802
|
Object.keys(channel).forEach(key => {
|
|
1749
|
-
var _a, _b;
|
|
1803
|
+
var _a, _b, _c, _d;
|
|
1750
1804
|
const config = channel[key];
|
|
1751
1805
|
if (config.to !== undefined) {
|
|
1752
1806
|
if (typeof config.to === 'function') {
|
|
1753
|
-
props[key] = config.to((_a = graphic.context) === null || _a === void 0 ? void 0 : _a.data, graphic, {});
|
|
1807
|
+
props[key] = config.to((_b = (_a = graphic.context) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[0], graphic, {});
|
|
1754
1808
|
}
|
|
1755
1809
|
else {
|
|
1756
1810
|
props[key] = config.to;
|
|
@@ -1761,7 +1815,7 @@ class AnimateExecutor {
|
|
|
1761
1815
|
from = {};
|
|
1762
1816
|
}
|
|
1763
1817
|
if (typeof config.from === 'function') {
|
|
1764
|
-
from[key] = config.from((
|
|
1818
|
+
from[key] = config.from((_d = (_c = graphic.context) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d[0], graphic, {});
|
|
1765
1819
|
}
|
|
1766
1820
|
else {
|
|
1767
1821
|
from[key] = config.from;
|
|
@@ -1784,12 +1838,12 @@ class AnimateExecutor {
|
|
|
1784
1838
|
};
|
|
1785
1839
|
}
|
|
1786
1840
|
resolveValue(value, graphic, defaultValue) {
|
|
1787
|
-
var _a;
|
|
1841
|
+
var _a, _b;
|
|
1788
1842
|
if (value === undefined) {
|
|
1789
1843
|
return defaultValue;
|
|
1790
1844
|
}
|
|
1791
1845
|
if (typeof value === 'function' && graphic) {
|
|
1792
|
-
return value((_a = graphic.context) === null || _a === void 0 ? void 0 : _a.data, graphic, {});
|
|
1846
|
+
return value((_b = (_a = graphic.context) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[0], graphic, {});
|
|
1793
1847
|
}
|
|
1794
1848
|
return value;
|
|
1795
1849
|
}
|
|
@@ -2087,6 +2141,12 @@ class AnimateExtension {
|
|
|
2087
2141
|
getFinalAttribute() {
|
|
2088
2142
|
return this.finalAttribute;
|
|
2089
2143
|
}
|
|
2144
|
+
getGraphicAttribute(key, prev = false) {
|
|
2145
|
+
if (!prev && this.finalAttribute) {
|
|
2146
|
+
return this.finalAttribute[key];
|
|
2147
|
+
}
|
|
2148
|
+
return this.attribute[key];
|
|
2149
|
+
}
|
|
2090
2150
|
}
|
|
2091
2151
|
|
|
2092
2152
|
function registerAnimate() {
|
|
@@ -2792,16 +2852,16 @@ class CommonIn extends ACustomAnimate {
|
|
|
2792
2852
|
super(from, to, duration, easing, params);
|
|
2793
2853
|
}
|
|
2794
2854
|
onBind() {
|
|
2795
|
-
var _a;
|
|
2855
|
+
var _a, _b, _c;
|
|
2796
2856
|
super.onBind();
|
|
2797
2857
|
const attrs = this.target.getFinalAttribute();
|
|
2798
2858
|
const fromAttrs = (_a = this.target.attribute) !== null && _a !== void 0 ? _a : {};
|
|
2799
2859
|
const to = {};
|
|
2800
|
-
const from = {};
|
|
2860
|
+
const from = (_b = this.from) !== null && _b !== void 0 ? _b : {};
|
|
2801
2861
|
this.keys.forEach(key => {
|
|
2802
|
-
var _a, _b;
|
|
2862
|
+
var _a, _b, _c;
|
|
2803
2863
|
to[key] = (_a = attrs === null || attrs === void 0 ? void 0 : attrs[key]) !== null && _a !== void 0 ? _a : 1;
|
|
2804
|
-
from[key] = (_b =
|
|
2864
|
+
from[key] = (_c = (_b = from[key]) !== null && _b !== void 0 ? _b : fromAttrs[key]) !== null && _c !== void 0 ? _c : 0;
|
|
2805
2865
|
});
|
|
2806
2866
|
const finalAttribute = this.target.getFinalAttribute();
|
|
2807
2867
|
if (finalAttribute) {
|
|
@@ -2811,10 +2871,9 @@ class CommonIn extends ACustomAnimate {
|
|
|
2811
2871
|
this.propKeys = this.keys;
|
|
2812
2872
|
this.from = from;
|
|
2813
2873
|
this.to = to;
|
|
2814
|
-
this.
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
super.onEnd(cb);
|
|
2874
|
+
if (((_c = this.params.controlOptions) === null || _c === void 0 ? void 0 : _c.immediatelyApply) !== false) {
|
|
2875
|
+
this.target.setAttributes(from);
|
|
2876
|
+
}
|
|
2818
2877
|
}
|
|
2819
2878
|
onUpdate(end, ratio, out) {
|
|
2820
2879
|
const attribute = this.target.attribute;
|
|
@@ -2864,6 +2923,7 @@ class GroupFadeIn extends CommonIn {
|
|
|
2864
2923
|
constructor(from, to, duration, easing, params) {
|
|
2865
2924
|
super(from, to, duration, easing, params);
|
|
2866
2925
|
this.keys = ['baseOpacity'];
|
|
2926
|
+
this.from = { baseOpacity: 0 };
|
|
2867
2927
|
}
|
|
2868
2928
|
}
|
|
2869
2929
|
class GroupFadeOut extends CommonOut {
|
|
@@ -2922,6 +2982,7 @@ class ClipIn extends CommonIn {
|
|
|
2922
2982
|
constructor(from, to, duration, easing, params) {
|
|
2923
2983
|
super(from, to, duration, easing, params);
|
|
2924
2984
|
this.keys = ['clipRange'];
|
|
2985
|
+
this.from = { clipRange: 0 };
|
|
2925
2986
|
}
|
|
2926
2987
|
}
|
|
2927
2988
|
class ClipOut extends CommonOut {
|
|
@@ -2935,6 +2996,7 @@ class FadeIn extends CommonIn {
|
|
|
2935
2996
|
constructor(from, to, duration, easing, params) {
|
|
2936
2997
|
super(from, to, duration, easing, params);
|
|
2937
2998
|
this.keys = ['opacity'];
|
|
2999
|
+
this.from = { opacity: 0 };
|
|
2938
3000
|
}
|
|
2939
3001
|
}
|
|
2940
3002
|
class FadeOut extends CommonOut {
|
|
@@ -3546,6 +3608,7 @@ class GworPointsBase extends ACustomAnimate {
|
|
|
3546
3608
|
}
|
|
3547
3609
|
class GrowPointsIn extends GworPointsBase {
|
|
3548
3610
|
onBind() {
|
|
3611
|
+
var _a;
|
|
3549
3612
|
super.onBind();
|
|
3550
3613
|
if (['area', 'line', 'polygon'].includes(this.target.type)) {
|
|
3551
3614
|
const { from, to } = growPointsIn(this.target, this.params.options, this.params);
|
|
@@ -3557,7 +3620,9 @@ class GrowPointsIn extends GworPointsBase {
|
|
|
3557
3620
|
if (finalAttribute) {
|
|
3558
3621
|
Object.assign(this.target.attribute, finalAttribute);
|
|
3559
3622
|
}
|
|
3560
|
-
this.
|
|
3623
|
+
if (((_a = this.params.controlOptions) === null || _a === void 0 ? void 0 : _a.immediatelyApply) !== false) {
|
|
3624
|
+
this.target.setAttributes(from);
|
|
3625
|
+
}
|
|
3561
3626
|
}
|
|
3562
3627
|
else {
|
|
3563
3628
|
this.valid = false;
|
|
@@ -3584,12 +3649,10 @@ const changePointsX = (graphic, options, animationParameters) => {
|
|
|
3584
3649
|
const attrs = graphic.getFinalAttribute();
|
|
3585
3650
|
const points = attrs.points;
|
|
3586
3651
|
return points.map((point) => {
|
|
3587
|
-
var _a;
|
|
3588
3652
|
if (options && options.orient === 'negative') {
|
|
3589
|
-
let groupRight =
|
|
3590
|
-
if (
|
|
3591
|
-
groupRight =
|
|
3592
|
-
animationParameters.groupWidth = groupRight;
|
|
3653
|
+
let groupRight = graphic.stage.viewWidth;
|
|
3654
|
+
if (graphic.parent.parent.parent) {
|
|
3655
|
+
groupRight = graphic.parent.parent.parent.AABBBounds.width();
|
|
3593
3656
|
}
|
|
3594
3657
|
return Object.assign(Object.assign({}, point), { x: groupRight, y: point.y, x1: groupRight, y1: point.y1, defined: point.defined !== false });
|
|
3595
3658
|
}
|
|
@@ -3599,7 +3662,7 @@ const changePointsX = (graphic, options, animationParameters) => {
|
|
|
3599
3662
|
const growPointsXIn = (graphic, options, animationParameters) => {
|
|
3600
3663
|
const attrs = graphic.getFinalAttribute();
|
|
3601
3664
|
return {
|
|
3602
|
-
from: { points: changePointsX(graphic, options
|
|
3665
|
+
from: { points: changePointsX(graphic, options) },
|
|
3603
3666
|
to: { points: attrs.points }
|
|
3604
3667
|
};
|
|
3605
3668
|
};
|
|
@@ -3607,11 +3670,12 @@ const growPointsXOut = (graphic, options, animationParameters) => {
|
|
|
3607
3670
|
const attrs = graphic.getFinalAttribute();
|
|
3608
3671
|
return {
|
|
3609
3672
|
from: { points: attrs.points },
|
|
3610
|
-
to: { points: changePointsX(graphic, options
|
|
3673
|
+
to: { points: changePointsX(graphic, options) }
|
|
3611
3674
|
};
|
|
3612
3675
|
};
|
|
3613
3676
|
class GrowPointsXIn extends GworPointsBase {
|
|
3614
3677
|
onBind() {
|
|
3678
|
+
var _a;
|
|
3615
3679
|
super.onBind();
|
|
3616
3680
|
if (['area', 'line', 'polygon'].includes(this.target.type)) {
|
|
3617
3681
|
const { from, to } = growPointsXIn(this.target, this.params.options, this.params);
|
|
@@ -3623,7 +3687,9 @@ class GrowPointsXIn extends GworPointsBase {
|
|
|
3623
3687
|
if (finalAttribute) {
|
|
3624
3688
|
Object.assign(this.target.attribute, finalAttribute);
|
|
3625
3689
|
}
|
|
3626
|
-
this.
|
|
3690
|
+
if (((_a = this.params.controlOptions) === null || _a === void 0 ? void 0 : _a.immediatelyApply) !== false) {
|
|
3691
|
+
this.target.setAttributes(from);
|
|
3692
|
+
}
|
|
3627
3693
|
}
|
|
3628
3694
|
else {
|
|
3629
3695
|
this.valid = false;
|
|
@@ -3650,12 +3716,10 @@ const changePointsY = (graphic, options, animationParameters) => {
|
|
|
3650
3716
|
const attrs = graphic.getFinalAttribute();
|
|
3651
3717
|
const points = attrs.points;
|
|
3652
3718
|
return points.map((point) => {
|
|
3653
|
-
var _a;
|
|
3654
3719
|
if (options && options.orient === 'negative') {
|
|
3655
|
-
let groupBottom =
|
|
3656
|
-
if (
|
|
3657
|
-
groupBottom =
|
|
3658
|
-
animationParameters.groupHeight = groupBottom;
|
|
3720
|
+
let groupBottom = graphic.stage.viewHeight;
|
|
3721
|
+
if (graphic.parent.parent.parent) {
|
|
3722
|
+
groupBottom = graphic.parent.parent.parent.AABBBounds.height();
|
|
3659
3723
|
}
|
|
3660
3724
|
return Object.assign(Object.assign({}, point), { x: point.x, y: groupBottom, x1: point.x1, y1: groupBottom, defined: point.defined !== false });
|
|
3661
3725
|
}
|
|
@@ -3665,7 +3729,7 @@ const changePointsY = (graphic, options, animationParameters) => {
|
|
|
3665
3729
|
const growPointsYIn = (graphic, options, animationParameters) => {
|
|
3666
3730
|
const attrs = graphic.getFinalAttribute();
|
|
3667
3731
|
return {
|
|
3668
|
-
from: { points: changePointsY(graphic, options
|
|
3732
|
+
from: { points: changePointsY(graphic, options) },
|
|
3669
3733
|
to: { points: attrs.points }
|
|
3670
3734
|
};
|
|
3671
3735
|
};
|
|
@@ -3673,11 +3737,12 @@ const growPointsYOut = (graphic, options, animationParameters) => {
|
|
|
3673
3737
|
const attrs = graphic.getFinalAttribute();
|
|
3674
3738
|
return {
|
|
3675
3739
|
from: { points: attrs.points },
|
|
3676
|
-
to: { points: changePointsY(graphic, options
|
|
3740
|
+
to: { points: changePointsY(graphic, options) }
|
|
3677
3741
|
};
|
|
3678
3742
|
};
|
|
3679
3743
|
class GrowPointsYIn extends GworPointsBase {
|
|
3680
3744
|
onBind() {
|
|
3745
|
+
var _a;
|
|
3681
3746
|
super.onBind();
|
|
3682
3747
|
if (['area', 'line', 'polygon'].includes(this.target.type)) {
|
|
3683
3748
|
const { from, to } = growPointsYIn(this.target, this.params.options, this.params);
|
|
@@ -3689,7 +3754,9 @@ class GrowPointsYIn extends GworPointsBase {
|
|
|
3689
3754
|
if (finalAttribute) {
|
|
3690
3755
|
Object.assign(this.target.attribute, finalAttribute);
|
|
3691
3756
|
}
|
|
3692
|
-
this.
|
|
3757
|
+
if (((_a = this.params.controlOptions) === null || _a === void 0 ? void 0 : _a.immediatelyApply) !== false) {
|
|
3758
|
+
this.target.setAttributes(from);
|
|
3759
|
+
}
|
|
3693
3760
|
}
|
|
3694
3761
|
else {
|
|
3695
3762
|
this.valid = false;
|
|
@@ -4959,7 +5026,7 @@ class ScaleIn extends ACustomAnimate {
|
|
|
4959
5026
|
super(from, to, duration, easing, params);
|
|
4960
5027
|
}
|
|
4961
5028
|
onBind() {
|
|
4962
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
5029
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
4963
5030
|
super.onBind();
|
|
4964
5031
|
let from;
|
|
4965
5032
|
let to;
|
|
@@ -4992,7 +5059,9 @@ class ScaleIn extends ACustomAnimate {
|
|
|
4992
5059
|
this.props = to;
|
|
4993
5060
|
this.from = from;
|
|
4994
5061
|
this.to = to;
|
|
4995
|
-
this.
|
|
5062
|
+
if (((_l = this.params.controlOptions) === null || _l === void 0 ? void 0 : _l.immediatelyApply) !== false) {
|
|
5063
|
+
this.target.setAttributes(from);
|
|
5064
|
+
}
|
|
4996
5065
|
}
|
|
4997
5066
|
onEnd(cb) {
|
|
4998
5067
|
super.onEnd(cb);
|
|
@@ -5551,20 +5620,14 @@ const moveIn = (graphic, options, animationParameters) => {
|
|
|
5551
5620
|
let changedX = 0;
|
|
5552
5621
|
let changedY = 0;
|
|
5553
5622
|
if (orient === 'negative') {
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
changedY = (_b = animationParameters.groupHeight) !== null && _b !== void 0 ? _b : animationParameters.group.getBounds().height();
|
|
5557
|
-
animationParameters.groupWidth = changedX;
|
|
5558
|
-
animationParameters.groupHeight = changedY;
|
|
5559
|
-
}
|
|
5560
|
-
else {
|
|
5561
|
-
changedX = animationParameters.width;
|
|
5562
|
-
changedY = animationParameters.height;
|
|
5563
|
-
}
|
|
5623
|
+
changedX = graphic.stage.viewWidth;
|
|
5624
|
+
changedY = graphic.stage.viewHeight;
|
|
5564
5625
|
}
|
|
5565
5626
|
changedX += offset;
|
|
5566
5627
|
changedY += offset;
|
|
5567
|
-
const point = isFunction(pointOpt)
|
|
5628
|
+
const point = isFunction(pointOpt)
|
|
5629
|
+
? 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)
|
|
5630
|
+
: pointOpt;
|
|
5568
5631
|
const fromX = point && isValidNumber(point.x) ? point.x : changedX;
|
|
5569
5632
|
const fromY = point && isValidNumber(point.y) ? point.y : changedY;
|
|
5570
5633
|
const finalAttrs = graphic.getFinalAttribute();
|
|
@@ -5595,12 +5658,13 @@ const moveIn = (graphic, options, animationParameters) => {
|
|
|
5595
5658
|
const moveOut = (graphic, options, animationParameters) => {
|
|
5596
5659
|
var _a, _b;
|
|
5597
5660
|
const { offset = 0, orient, direction, point: pointOpt } = options !== null && options !== void 0 ? options : {};
|
|
5598
|
-
const
|
|
5599
|
-
const
|
|
5600
|
-
const groupHeight = (_b = groupBounds === null || groupBounds === void 0 ? void 0 : groupBounds.height()) !== null && _b !== void 0 ? _b : animationParameters.height;
|
|
5661
|
+
const groupWidth = graphic.stage.viewWidth;
|
|
5662
|
+
const groupHeight = graphic.stage.viewHeight;
|
|
5601
5663
|
const changedX = (orient === 'negative' ? groupWidth : 0) + offset;
|
|
5602
5664
|
const changedY = (orient === 'negative' ? groupHeight : 0) + offset;
|
|
5603
|
-
const point = isFunction(pointOpt)
|
|
5665
|
+
const point = isFunction(pointOpt)
|
|
5666
|
+
? 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)
|
|
5667
|
+
: pointOpt;
|
|
5604
5668
|
const fromX = point && isValidNumber(point.x) ? point.x : changedX;
|
|
5605
5669
|
const fromY = point && isValidNumber(point.y) ? point.y : changedY;
|
|
5606
5670
|
switch (direction) {
|
|
@@ -5640,6 +5704,7 @@ class MoveBase extends ACustomAnimate {
|
|
|
5640
5704
|
}
|
|
5641
5705
|
class MoveIn extends MoveBase {
|
|
5642
5706
|
onBind() {
|
|
5707
|
+
var _a;
|
|
5643
5708
|
super.onBind();
|
|
5644
5709
|
const { from, to } = moveIn(this.target, this.params.options, this.params);
|
|
5645
5710
|
this.props = to;
|
|
@@ -5650,7 +5715,9 @@ class MoveIn extends MoveBase {
|
|
|
5650
5715
|
if (finalAttribute) {
|
|
5651
5716
|
Object.assign(this.target.attribute, finalAttribute);
|
|
5652
5717
|
}
|
|
5653
|
-
this.
|
|
5718
|
+
if (((_a = this.params.controlOptions) === null || _a === void 0 ? void 0 : _a.immediatelyApply) !== false) {
|
|
5719
|
+
this.target.setAttributes(from);
|
|
5720
|
+
}
|
|
5654
5721
|
}
|
|
5655
5722
|
}
|
|
5656
5723
|
class MoveOut extends MoveBase {
|
|
@@ -5723,6 +5790,7 @@ class RotateBase extends ACustomAnimate {
|
|
|
5723
5790
|
}
|
|
5724
5791
|
class RotateIn extends RotateBase {
|
|
5725
5792
|
onBind() {
|
|
5793
|
+
var _a;
|
|
5726
5794
|
super.onBind();
|
|
5727
5795
|
const { from, to } = rotateIn(this.target, this.params.options);
|
|
5728
5796
|
this.props = to;
|
|
@@ -5733,7 +5801,9 @@ class RotateIn extends RotateBase {
|
|
|
5733
5801
|
if (finalAttribute) {
|
|
5734
5802
|
Object.assign(this.target.attribute, finalAttribute);
|
|
5735
5803
|
}
|
|
5736
|
-
this.
|
|
5804
|
+
if (((_a = this.params.controlOptions) === null || _a === void 0 ? void 0 : _a.immediatelyApply) !== false) {
|
|
5805
|
+
this.target.setAttributes(from);
|
|
5806
|
+
}
|
|
5737
5807
|
}
|
|
5738
5808
|
}
|
|
5739
5809
|
class RotateOut extends RotateBase {
|
|
@@ -5786,6 +5856,7 @@ class FromTo extends ACustomAnimate {
|
|
|
5786
5856
|
this.from = from !== null && from !== void 0 ? from : {};
|
|
5787
5857
|
}
|
|
5788
5858
|
onBind() {
|
|
5859
|
+
var _a, _b;
|
|
5789
5860
|
super.onBind();
|
|
5790
5861
|
const finalAttribute = this.target.getFinalAttribute();
|
|
5791
5862
|
Object.keys(this.from).forEach(key => {
|
|
@@ -5793,6 +5864,14 @@ class FromTo extends ACustomAnimate {
|
|
|
5793
5864
|
this.props[key] = finalAttribute[key];
|
|
5794
5865
|
}
|
|
5795
5866
|
});
|
|
5867
|
+
if (((_a = this.target.context) === null || _a === void 0 ? void 0 : _a.animationState) === 'appear') {
|
|
5868
|
+
if (finalAttribute) {
|
|
5869
|
+
Object.assign(this.target.attribute, finalAttribute);
|
|
5870
|
+
}
|
|
5871
|
+
}
|
|
5872
|
+
if (((_b = this.params.controlOptions) === null || _b === void 0 ? void 0 : _b.immediatelyApply) !== false) {
|
|
5873
|
+
this.target.setAttributes(this.from);
|
|
5874
|
+
}
|
|
5796
5875
|
}
|
|
5797
5876
|
onFirstRun() {
|
|
5798
5877
|
var _a;
|
package/es/animate-extension.js
CHANGED