@visactor/vrender-animate 1.0.8-alpha.1 → 1.0.8-alpha.2
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 +0 -3
- package/cjs/animate-extension.js +4 -16
- package/cjs/animate-extension.js.map +1 -1
- package/cjs/animate.d.ts +0 -1
- package/cjs/animate.js +2 -11
- package/cjs/animate.js.map +1 -1
- package/cjs/custom/custom-animate.d.ts +1 -14
- package/cjs/custom/custom-animate.js +2 -42
- package/cjs/custom/custom-animate.js.map +1 -1
- package/cjs/custom/fromTo.d.ts +0 -1
- package/cjs/custom/fromTo.js +0 -3
- package/cjs/custom/fromTo.js.map +1 -1
- package/cjs/custom/growCenter.js +2 -2
- package/cjs/custom/growCenter.js.map +1 -1
- package/cjs/custom/growHeight.js +2 -2
- package/cjs/custom/growHeight.js.map +1 -1
- package/cjs/custom/move.d.ts +4 -4
- package/cjs/custom/move.js +10 -11
- package/cjs/custom/move.js.map +1 -1
- package/cjs/executor/animate-executor.js +3 -4
- package/cjs/executor/animate-executor.js.map +1 -1
- package/cjs/index.d.ts +1 -2
- package/cjs/index.js +2 -7
- package/cjs/index.js.map +1 -1
- package/cjs/state/animation-state.d.ts +0 -1
- package/cjs/state/animation-state.js +0 -5
- package/cjs/state/animation-state.js.map +1 -1
- package/cjs/state/graphic-extension.d.ts +1 -2
- package/cjs/state/graphic-extension.js +2 -9
- package/cjs/state/graphic-extension.js.map +1 -1
- package/cjs/step.d.ts +0 -1
- package/cjs/step.js +0 -1
- package/cjs/step.js.map +1 -1
- package/cjs/ticker/default-ticker.d.ts +2 -2
- package/cjs/ticker/default-ticker.js +7 -9
- package/cjs/ticker/default-ticker.js.map +1 -1
- package/cjs/timeline.d.ts +0 -1
- package/cjs/timeline.js +2 -4
- package/cjs/timeline.js.map +1 -1
- package/dist/index.es.js +39 -178
- package/es/animate-extension.d.ts +0 -3
- package/es/animate-extension.js +4 -16
- package/es/animate-extension.js.map +1 -1
- package/es/animate.d.ts +0 -1
- package/es/animate.js +2 -11
- package/es/animate.js.map +1 -1
- package/es/custom/custom-animate.d.ts +1 -14
- package/es/custom/custom-animate.js +1 -39
- package/es/custom/custom-animate.js.map +1 -1
- package/es/custom/fromTo.d.ts +0 -1
- package/es/custom/fromTo.js +0 -3
- package/es/custom/fromTo.js.map +1 -1
- package/es/custom/growCenter.js +2 -2
- package/es/custom/growCenter.js.map +1 -1
- package/es/custom/growHeight.js +2 -2
- package/es/custom/growHeight.js.map +1 -1
- package/es/custom/move.d.ts +4 -4
- package/es/custom/move.js +8 -8
- package/es/custom/move.js.map +1 -1
- package/es/executor/animate-executor.js +3 -4
- package/es/executor/animate-executor.js.map +1 -1
- package/es/index.d.ts +1 -2
- package/es/index.js +1 -3
- package/es/index.js.map +1 -1
- package/es/state/animation-state.d.ts +0 -1
- package/es/state/animation-state.js +0 -5
- package/es/state/animation-state.js.map +1 -1
- package/es/state/graphic-extension.d.ts +1 -2
- package/es/state/graphic-extension.js +2 -9
- package/es/state/graphic-extension.js.map +1 -1
- package/es/step.d.ts +0 -1
- package/es/step.js +0 -1
- package/es/step.js.map +1 -1
- package/es/ticker/default-ticker.d.ts +2 -2
- package/es/ticker/default-ticker.js +7 -9
- package/es/ticker/default-ticker.js.map +1 -1
- package/es/timeline.d.ts +0 -1
- package/es/timeline.js +2 -3
- package/es/timeline.js.map +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -556,8 +556,6 @@ class Step {
|
|
|
556
556
|
}
|
|
557
557
|
stop() {
|
|
558
558
|
}
|
|
559
|
-
release() {
|
|
560
|
-
}
|
|
561
559
|
}
|
|
562
560
|
class WaitStep extends Step {
|
|
563
561
|
constructor(type, props, duration, easing) {
|
|
@@ -592,7 +590,6 @@ class DefaultTimeline extends EventEmitter {
|
|
|
592
590
|
this._totalDuration = 0;
|
|
593
591
|
this._startTime = 0;
|
|
594
592
|
this._currentTime = 0;
|
|
595
|
-
this._animationEndFlag = true;
|
|
596
593
|
this.id = Generator.GenAutoIncrementId();
|
|
597
594
|
this.paused = false;
|
|
598
595
|
}
|
|
@@ -640,10 +637,6 @@ class DefaultTimeline extends EventEmitter {
|
|
|
640
637
|
if (this.paused) {
|
|
641
638
|
return;
|
|
642
639
|
}
|
|
643
|
-
if (this._animationEndFlag) {
|
|
644
|
-
this._animationEndFlag = false;
|
|
645
|
-
this.emit('animationStart');
|
|
646
|
-
}
|
|
647
640
|
const scaledDelta = delta * this._playSpeed;
|
|
648
641
|
this._currentTime += scaledDelta;
|
|
649
642
|
this.forEachAccessAnimate((animate, i) => {
|
|
@@ -655,7 +648,6 @@ class DefaultTimeline extends EventEmitter {
|
|
|
655
648
|
}
|
|
656
649
|
});
|
|
657
650
|
if (this._animateCount === 0) {
|
|
658
|
-
this._animationEndFlag = true;
|
|
659
651
|
this.emit('animationEnd');
|
|
660
652
|
}
|
|
661
653
|
}
|
|
@@ -776,14 +768,6 @@ class Animate {
|
|
|
776
768
|
}
|
|
777
769
|
bind(target) {
|
|
778
770
|
this.target = target;
|
|
779
|
-
if (!this.target.animates) {
|
|
780
|
-
this.target.animates = new Map();
|
|
781
|
-
}
|
|
782
|
-
this.target.animates.set(this.id, this);
|
|
783
|
-
this.onRemove(() => {
|
|
784
|
-
this.stop();
|
|
785
|
-
this.target.animates.delete(this.id);
|
|
786
|
-
});
|
|
787
771
|
if (this.target.onAnimateBind && !this.slience) {
|
|
788
772
|
this.target.onAnimateBind(this);
|
|
789
773
|
}
|
|
@@ -987,9 +971,6 @@ class Animate {
|
|
|
987
971
|
this._onFrame = [];
|
|
988
972
|
this._onEnd = [];
|
|
989
973
|
this._onRemove = [];
|
|
990
|
-
this.forEachStep(step => {
|
|
991
|
-
step.release();
|
|
992
|
-
});
|
|
993
974
|
}
|
|
994
975
|
getDuration() {
|
|
995
976
|
return this._duration;
|
|
@@ -1124,13 +1105,6 @@ class Animate {
|
|
|
1124
1105
|
getLoop() {
|
|
1125
1106
|
return this._loopCount;
|
|
1126
1107
|
}
|
|
1127
|
-
forEachStep(cb) {
|
|
1128
|
-
let step = this._firstStep;
|
|
1129
|
-
while (step) {
|
|
1130
|
-
cb(step);
|
|
1131
|
-
step = step.next;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
1108
|
}
|
|
1135
1109
|
|
|
1136
1110
|
const performanceRAF = new PerformanceRAF();
|
|
@@ -1211,10 +1185,10 @@ class DefaultTicker extends EventEmitter {
|
|
|
1211
1185
|
this.interval = 16;
|
|
1212
1186
|
this.status = STATUS.INITIAL;
|
|
1213
1187
|
application.global.hooks.onSetEnv.tap('graph-ticker', () => {
|
|
1214
|
-
this.initHandler(
|
|
1188
|
+
this.initHandler();
|
|
1215
1189
|
});
|
|
1216
1190
|
if (application.global.env) {
|
|
1217
|
-
this.initHandler(
|
|
1191
|
+
this.initHandler();
|
|
1218
1192
|
}
|
|
1219
1193
|
}
|
|
1220
1194
|
addTimeline(timeline) {
|
|
@@ -1226,13 +1200,10 @@ class DefaultTicker extends EventEmitter {
|
|
|
1226
1200
|
getTimelines() {
|
|
1227
1201
|
return this.timelines;
|
|
1228
1202
|
}
|
|
1229
|
-
initHandler(
|
|
1230
|
-
this.setupTickHandler(
|
|
1203
|
+
initHandler() {
|
|
1204
|
+
this.setupTickHandler();
|
|
1231
1205
|
}
|
|
1232
|
-
setupTickHandler(
|
|
1233
|
-
if (!force && this.tickerHandler) {
|
|
1234
|
-
return true;
|
|
1235
|
-
}
|
|
1206
|
+
setupTickHandler() {
|
|
1236
1207
|
const handler = new RAFTickHandler();
|
|
1237
1208
|
if (this.tickerHandler) {
|
|
1238
1209
|
this.tickerHandler.release();
|
|
@@ -1312,7 +1283,7 @@ class DefaultTicker extends EventEmitter {
|
|
|
1312
1283
|
}
|
|
1313
1284
|
stop() {
|
|
1314
1285
|
this.status = STATUS.INITIAL;
|
|
1315
|
-
this.setupTickHandler(
|
|
1286
|
+
this.setupTickHandler();
|
|
1316
1287
|
this.lastFrameTime = -1;
|
|
1317
1288
|
}
|
|
1318
1289
|
trySyncTickStatus() {
|
|
@@ -1332,8 +1303,7 @@ class DefaultTicker extends EventEmitter {
|
|
|
1332
1303
|
this.lastFrameTime = -1;
|
|
1333
1304
|
}
|
|
1334
1305
|
checkSkip(delta) {
|
|
1335
|
-
|
|
1336
|
-
if (((_c = (_b = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.optimize) === null || _c === void 0 ? void 0 : _c.tickRenderMode) === 'performance') {
|
|
1306
|
+
if (this.stage.params.optimize.tickRenderMode === 'performance') {
|
|
1337
1307
|
return false;
|
|
1338
1308
|
}
|
|
1339
1309
|
const skip = delta < this.interval + (Math.random() - 0.5) * 2 * this._jitter;
|
|
@@ -1801,7 +1771,10 @@ class AnimateExecutor {
|
|
|
1801
1771
|
_handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic) {
|
|
1802
1772
|
var _a, _b, _c, _d;
|
|
1803
1773
|
if (custom && customType) {
|
|
1804
|
-
const customParams =
|
|
1774
|
+
const customParams = this.resolveValue(customParameters, graphic, {
|
|
1775
|
+
width: graphic.stage.width,
|
|
1776
|
+
height: graphic.stage.height
|
|
1777
|
+
});
|
|
1805
1778
|
const objOptions = isFunction(options)
|
|
1806
1779
|
? 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)
|
|
1807
1780
|
: options;
|
|
@@ -2129,14 +2102,6 @@ class AnimationStateManager {
|
|
|
2129
2102
|
});
|
|
2130
2103
|
this.stateList = null;
|
|
2131
2104
|
}
|
|
2132
|
-
reApplyState(state) {
|
|
2133
|
-
var _a;
|
|
2134
|
-
const stateInfo = (_a = this.stateList) === null || _a === void 0 ? void 0 : _a.find(stateInfo => stateInfo.state === state);
|
|
2135
|
-
if (stateInfo) {
|
|
2136
|
-
stateInfo.executor.stop();
|
|
2137
|
-
stateInfo.executor.execute(stateInfo.animationConfig);
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
2105
|
}
|
|
2141
2106
|
|
|
2142
2107
|
class GraphicStateExtension {
|
|
@@ -2180,28 +2145,14 @@ class GraphicStateExtension {
|
|
|
2180
2145
|
this._getAnimationStateManager(this).applyUnhighlightState(animationConfig, callback);
|
|
2181
2146
|
return this;
|
|
2182
2147
|
}
|
|
2183
|
-
stopAnimationState(state, type
|
|
2148
|
+
stopAnimationState(state, type) {
|
|
2184
2149
|
this._getAnimationStateManager(this).stopState(state, type);
|
|
2185
|
-
if (deep && this.isContainer) {
|
|
2186
|
-
this.forEachChildren((child) => {
|
|
2187
|
-
child.stopAnimationState(state, type, deep);
|
|
2188
|
-
});
|
|
2189
|
-
}
|
|
2190
2150
|
return this;
|
|
2191
2151
|
}
|
|
2192
2152
|
clearAnimationStates() {
|
|
2193
2153
|
this._getAnimationStateManager(this).clearState();
|
|
2194
2154
|
return this;
|
|
2195
2155
|
}
|
|
2196
|
-
reApplyAnimationState(state, deep = false) {
|
|
2197
|
-
this._getAnimationStateManager(this).reApplyState(state);
|
|
2198
|
-
if (deep && this.isContainer) {
|
|
2199
|
-
this.forEachChildren((child) => {
|
|
2200
|
-
child.reApplyAnimationState(state, deep);
|
|
2201
|
-
});
|
|
2202
|
-
}
|
|
2203
|
-
return this;
|
|
2204
|
-
}
|
|
2205
2156
|
static extend(graphic) {
|
|
2206
2157
|
const extension = new GraphicStateExtension();
|
|
2207
2158
|
extension._getAnimationStateManager(graphic);
|
|
@@ -2218,6 +2169,9 @@ class AnimateExtension {
|
|
|
2218
2169
|
}
|
|
2219
2170
|
animate(params) {
|
|
2220
2171
|
var _a, _b, _c;
|
|
2172
|
+
if (!this.animates) {
|
|
2173
|
+
this.animates = new Map();
|
|
2174
|
+
}
|
|
2221
2175
|
const animate = new Animate(params === null || params === void 0 ? void 0 : params.id, (_b = (_a = params === null || params === void 0 ? void 0 : params.timeline) !== null && _a !== void 0 ? _a : (this.stage && this.stage.getTimeline())) !== null && _b !== void 0 ? _b : defaultTimeline, params === null || params === void 0 ? void 0 : params.slience);
|
|
2222
2176
|
animate.bind(this);
|
|
2223
2177
|
if (params) {
|
|
@@ -2226,6 +2180,11 @@ class AnimateExtension {
|
|
|
2226
2180
|
onEnd != null && animate.onEnd(onEnd);
|
|
2227
2181
|
onRemove != null && animate.onRemove(onRemove);
|
|
2228
2182
|
}
|
|
2183
|
+
this.animates.set(animate.id, animate);
|
|
2184
|
+
animate.onRemove(() => {
|
|
2185
|
+
animate.stop();
|
|
2186
|
+
this.animates.delete(animate.id);
|
|
2187
|
+
});
|
|
2229
2188
|
(_c = this.stage) === null || _c === void 0 ? void 0 : _c.ticker.start();
|
|
2230
2189
|
return animate;
|
|
2231
2190
|
}
|
|
@@ -2270,30 +2229,6 @@ class AnimateExtension {
|
|
|
2270
2229
|
}
|
|
2271
2230
|
return this.attribute[key];
|
|
2272
2231
|
}
|
|
2273
|
-
pauseAnimation(deep = false) {
|
|
2274
|
-
this.animates && this.animates.forEach(animate => animate.pause());
|
|
2275
|
-
if (deep && this.isContainer) {
|
|
2276
|
-
this.forEachChildren((child) => {
|
|
2277
|
-
child.pauseAnimation(deep);
|
|
2278
|
-
});
|
|
2279
|
-
}
|
|
2280
|
-
}
|
|
2281
|
-
resumeAnimation(deep = false) {
|
|
2282
|
-
this.animates && this.animates.forEach(animate => animate.resume());
|
|
2283
|
-
if (deep && this.isContainer) {
|
|
2284
|
-
this.forEachChildren((child) => {
|
|
2285
|
-
child.resumeAnimation(deep);
|
|
2286
|
-
});
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
stopAnimation(deep = false) {
|
|
2290
|
-
this.animates && this.animates.forEach(animate => animate.stop());
|
|
2291
|
-
if (deep && this.isContainer) {
|
|
2292
|
-
this.forEachChildren((child) => {
|
|
2293
|
-
child.stopAnimation(deep);
|
|
2294
|
-
});
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
2232
|
}
|
|
2298
2233
|
|
|
2299
2234
|
function registerAnimate() {
|
|
@@ -2307,8 +2242,6 @@ class ACustomAnimate extends Step {
|
|
|
2307
2242
|
this.type = 'customAnimate';
|
|
2308
2243
|
this.customFrom = customFrom;
|
|
2309
2244
|
this.params = params;
|
|
2310
|
-
this.from = customFrom;
|
|
2311
|
-
this.to = customTo;
|
|
2312
2245
|
}
|
|
2313
2246
|
update(end, ratio, out) {
|
|
2314
2247
|
this.onStart();
|
|
@@ -2335,70 +2268,6 @@ class AComponentAnimate extends ACustomAnimate {
|
|
|
2335
2268
|
this._animator && this._animator.stop();
|
|
2336
2269
|
}
|
|
2337
2270
|
}
|
|
2338
|
-
class AStageAnimate extends ACustomAnimate {
|
|
2339
|
-
constructor(customFrom, customTo, duration, easing, params) {
|
|
2340
|
-
super(customFrom, customTo, duration, easing, params);
|
|
2341
|
-
this.willCallBeforeStageRender = true;
|
|
2342
|
-
this.willCallAfterStageRender = true;
|
|
2343
|
-
this._beforeStageRender = () => {
|
|
2344
|
-
if (!this.willCallBeforeStageRender) {
|
|
2345
|
-
return;
|
|
2346
|
-
}
|
|
2347
|
-
this.willCallBeforeStageRender = false;
|
|
2348
|
-
const stage = this.target.stage;
|
|
2349
|
-
const canvas = stage.window.getContext().canvas.nativeCanvas;
|
|
2350
|
-
const outputCanvas = this.beforeStageRender(stage, canvas);
|
|
2351
|
-
if (outputCanvas) {
|
|
2352
|
-
this.renderToStage(stage, outputCanvas);
|
|
2353
|
-
}
|
|
2354
|
-
};
|
|
2355
|
-
this._afterStageRender = () => {
|
|
2356
|
-
if (!this.willCallAfterStageRender) {
|
|
2357
|
-
return;
|
|
2358
|
-
}
|
|
2359
|
-
this.willCallAfterStageRender = false;
|
|
2360
|
-
const stage = this.target.stage;
|
|
2361
|
-
const canvas = stage.window.getContext().canvas.nativeCanvas;
|
|
2362
|
-
const outputCanvas = this.afterStageRender(stage, canvas);
|
|
2363
|
-
if (outputCanvas) {
|
|
2364
|
-
this.renderToStage(stage, outputCanvas);
|
|
2365
|
-
}
|
|
2366
|
-
};
|
|
2367
|
-
this.props = {};
|
|
2368
|
-
}
|
|
2369
|
-
beforeStageRender(stage, canvas) {
|
|
2370
|
-
return false;
|
|
2371
|
-
}
|
|
2372
|
-
afterStageRender(stage, canvas) {
|
|
2373
|
-
return false;
|
|
2374
|
-
}
|
|
2375
|
-
onFirstRun() {
|
|
2376
|
-
super.onFirstRun();
|
|
2377
|
-
this.target.stage.setBeforeRender(this._beforeStageRender);
|
|
2378
|
-
this.target.stage.setAfterRender(this._afterStageRender);
|
|
2379
|
-
this.target.stage.disableDirtyBounds();
|
|
2380
|
-
}
|
|
2381
|
-
stop() {
|
|
2382
|
-
super.stop();
|
|
2383
|
-
this.target.stage.removeBeforeRender(this._beforeStageRender);
|
|
2384
|
-
this.target.stage.removeAfterRender(this._afterStageRender);
|
|
2385
|
-
}
|
|
2386
|
-
onUpdate(end, ratio, out) {
|
|
2387
|
-
super.onUpdate(end, ratio, out);
|
|
2388
|
-
this.willCallBeforeStageRender = true;
|
|
2389
|
-
this.willCallAfterStageRender = true;
|
|
2390
|
-
}
|
|
2391
|
-
renderToStage(stage, canvas) {
|
|
2392
|
-
const stageCanvas = stage.window.getContext().canvas.nativeCanvas;
|
|
2393
|
-
const ctx = stageCanvas.getContext('2d');
|
|
2394
|
-
if (!ctx) {
|
|
2395
|
-
return false;
|
|
2396
|
-
}
|
|
2397
|
-
ctx.clearRect(0, 0, stageCanvas.width, stageCanvas.height);
|
|
2398
|
-
ctx.drawImage(canvas, 0, 0);
|
|
2399
|
-
return stageCanvas;
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
2271
|
|
|
2403
2272
|
class ComponentAnimator {
|
|
2404
2273
|
constructor(component) {
|
|
@@ -4047,7 +3916,7 @@ class GrowCenterIn extends ACustomAnimate {
|
|
|
4047
3916
|
super(from, to, duration, easing, params);
|
|
4048
3917
|
}
|
|
4049
3918
|
onBind() {
|
|
4050
|
-
var _a, _b
|
|
3919
|
+
var _a, _b;
|
|
4051
3920
|
super.onBind();
|
|
4052
3921
|
const { from, to } = growCenterIn(this.target, this.params.options, this.params);
|
|
4053
3922
|
const fromAttrs = (_b = (_a = this.target.context) === null || _a === void 0 ? void 0 : _a.lastAttrs) !== null && _b !== void 0 ? _b : from;
|
|
@@ -4059,9 +3928,7 @@ class GrowCenterIn extends ACustomAnimate {
|
|
|
4059
3928
|
if (finalAttribute) {
|
|
4060
3929
|
this.target.setAttributes(finalAttribute);
|
|
4061
3930
|
}
|
|
4062
|
-
|
|
4063
|
-
this.target.setAttributes(fromAttrs);
|
|
4064
|
-
}
|
|
3931
|
+
this.target.setAttributes(fromAttrs);
|
|
4065
3932
|
}
|
|
4066
3933
|
onEnd(cb) {
|
|
4067
3934
|
super.onEnd(cb);
|
|
@@ -4157,7 +4024,7 @@ class GrowHeightIn extends ACustomAnimate {
|
|
|
4157
4024
|
super(from, to, duration, easing, params);
|
|
4158
4025
|
}
|
|
4159
4026
|
onBind() {
|
|
4160
|
-
var _a, _b
|
|
4027
|
+
var _a, _b;
|
|
4161
4028
|
super.onBind();
|
|
4162
4029
|
const { from, to } = growHeightIn(this.target, this.params.options, this.params);
|
|
4163
4030
|
const fromAttrs = (_b = (_a = this.target.context) === null || _a === void 0 ? void 0 : _a.lastAttrs) !== null && _b !== void 0 ? _b : from;
|
|
@@ -4169,9 +4036,7 @@ class GrowHeightIn extends ACustomAnimate {
|
|
|
4169
4036
|
if (finalAttribute) {
|
|
4170
4037
|
this.target.setAttributes(finalAttribute);
|
|
4171
4038
|
}
|
|
4172
|
-
|
|
4173
|
-
this.target.setAttributes(fromAttrs);
|
|
4174
|
-
}
|
|
4039
|
+
this.target.setAttributes(fromAttrs);
|
|
4175
4040
|
}
|
|
4176
4041
|
onEnd(cb) {
|
|
4177
4042
|
super.onEnd(cb);
|
|
@@ -6622,14 +6487,15 @@ const moveIn = (graphic, options, animationParameters) => {
|
|
|
6622
6487
|
const point = isFunction(pointOpt)
|
|
6623
6488
|
? 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)
|
|
6624
6489
|
: pointOpt;
|
|
6625
|
-
const
|
|
6626
|
-
const
|
|
6627
|
-
const
|
|
6628
|
-
const
|
|
6490
|
+
const fromX = point && isValidNumber(point.x) ? point.x : changedX;
|
|
6491
|
+
const fromY = point && isValidNumber(point.y) ? point.y : changedY;
|
|
6492
|
+
const finalAttrs = graphic.getFinalAttribute();
|
|
6493
|
+
const finalAttrsX = excludeChannels.includes('x') ? graphic.attribute.x : finalAttrs.x;
|
|
6494
|
+
const finalAttrsY = excludeChannels.includes('y') ? graphic.attribute.y : finalAttrs.y;
|
|
6629
6495
|
switch (direction) {
|
|
6630
6496
|
case 'x':
|
|
6631
6497
|
return {
|
|
6632
|
-
from: { x:
|
|
6498
|
+
from: { x: fromX },
|
|
6633
6499
|
to: { x: finalAttrsX }
|
|
6634
6500
|
};
|
|
6635
6501
|
case 'y':
|
|
@@ -6649,35 +6515,34 @@ const moveIn = (graphic, options, animationParameters) => {
|
|
|
6649
6515
|
}
|
|
6650
6516
|
};
|
|
6651
6517
|
const moveOut = (graphic, options, animationParameters) => {
|
|
6652
|
-
var _a, _b, _c, _d;
|
|
6518
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6653
6519
|
const { offset = 0, orient, direction, point: pointOpt } = options !== null && options !== void 0 ? options : {};
|
|
6654
|
-
const
|
|
6655
|
-
const
|
|
6656
|
-
const groupHeight = (_b = groupBounds.height()) !== null && _b !== void 0 ? _b : animationParameters.height;
|
|
6520
|
+
const groupWidth = (_b = (_a = options.layoutRect) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : graphic.stage.viewWidth;
|
|
6521
|
+
const groupHeight = (_d = (_c = options.layoutRect) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : graphic.stage.viewHeight;
|
|
6657
6522
|
const changedX = (orient === 'negative' ? groupWidth : 0) + offset;
|
|
6658
6523
|
const changedY = (orient === 'negative' ? groupHeight : 0) + offset;
|
|
6659
6524
|
const point = isFunction(pointOpt)
|
|
6660
|
-
? pointOpt.call(null, (
|
|
6525
|
+
? 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)
|
|
6661
6526
|
: pointOpt;
|
|
6662
6527
|
const fromX = point && isValidNumber(point.x) ? point.x : changedX;
|
|
6663
6528
|
const fromY = point && isValidNumber(point.y) ? point.y : changedY;
|
|
6664
6529
|
switch (direction) {
|
|
6665
6530
|
case 'x':
|
|
6666
6531
|
return {
|
|
6667
|
-
from: { x: graphic.
|
|
6532
|
+
from: { x: graphic.attribute.x },
|
|
6668
6533
|
to: { x: fromX }
|
|
6669
6534
|
};
|
|
6670
6535
|
case 'y':
|
|
6671
6536
|
return {
|
|
6672
|
-
from: { y: graphic.
|
|
6537
|
+
from: { y: graphic.attribute.y },
|
|
6673
6538
|
to: { y: fromY }
|
|
6674
6539
|
};
|
|
6675
6540
|
case 'xy':
|
|
6676
6541
|
default:
|
|
6677
6542
|
return {
|
|
6678
6543
|
from: {
|
|
6679
|
-
x: graphic.
|
|
6680
|
-
y: graphic.
|
|
6544
|
+
x: graphic.attribute.x,
|
|
6545
|
+
y: graphic.attribute.y
|
|
6681
6546
|
},
|
|
6682
6547
|
to: { x: fromX, y: fromY }
|
|
6683
6548
|
};
|
|
@@ -6877,10 +6742,6 @@ class FromTo extends ACustomAnimate {
|
|
|
6877
6742
|
});
|
|
6878
6743
|
this.target.setAttributes(this.from);
|
|
6879
6744
|
}
|
|
6880
|
-
deleteSelfAttr(key) {
|
|
6881
|
-
super.deleteSelfAttr(key);
|
|
6882
|
-
delete this.from[key];
|
|
6883
|
-
}
|
|
6884
6745
|
update(end, ratio, out) {
|
|
6885
6746
|
this.onStart();
|
|
6886
6747
|
if (!this.props || !this.propKeys) {
|
|
@@ -7198,4 +7059,4 @@ const registerCustomAnimate = () => {
|
|
|
7198
7059
|
AnimateExecutor.registerBuiltInAnimate('streamLight', StreamLight);
|
|
7199
7060
|
};
|
|
7200
7061
|
|
|
7201
|
-
export { AComponentAnimate, ACustomAnimate,
|
|
7062
|
+
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 };
|
|
@@ -19,7 +19,4 @@ export declare class AnimateExtension {
|
|
|
19
19
|
executeAnimations(configs: IAnimationConfig[]): this;
|
|
20
20
|
protected getFinalAttribute(): Record<string, any>;
|
|
21
21
|
getGraphicAttribute(key: string, prev?: boolean): any;
|
|
22
|
-
pauseAnimation(deep?: boolean): void;
|
|
23
|
-
resumeAnimation(deep?: boolean): void;
|
|
24
|
-
stopAnimation(deep?: boolean): void;
|
|
25
22
|
}
|
package/es/animate-extension.js
CHANGED
|
@@ -12,13 +12,16 @@ export class AnimateExtension {
|
|
|
12
12
|
}
|
|
13
13
|
animate(params) {
|
|
14
14
|
var _a, _b, _c;
|
|
15
|
+
this.animates || (this.animates = new Map);
|
|
15
16
|
const animate = new Animate(null == params ? void 0 : params.id, null !== (_b = null !== (_a = null == params ? void 0 : params.timeline) && void 0 !== _a ? _a : this.stage && this.stage.getTimeline()) && void 0 !== _b ? _b : defaultTimeline, null == params ? void 0 : params.slience);
|
|
16
17
|
if (animate.bind(this), params) {
|
|
17
18
|
const {onStart: onStart, onEnd: onEnd, onRemove: onRemove} = params;
|
|
18
19
|
null != onStart && animate.onStart(onStart), null != onEnd && animate.onEnd(onEnd),
|
|
19
20
|
null != onRemove && animate.onRemove(onRemove);
|
|
20
21
|
}
|
|
21
|
-
return
|
|
22
|
+
return this.animates.set(animate.id, animate), animate.onRemove((() => {
|
|
23
|
+
animate.stop(), this.animates.delete(animate.id);
|
|
24
|
+
})), null === (_c = this.stage) || void 0 === _c || _c.ticker.start(), animate;
|
|
22
25
|
}
|
|
23
26
|
createTimeline() {
|
|
24
27
|
return new DefaultTimeline;
|
|
@@ -49,19 +52,4 @@ export class AnimateExtension {
|
|
|
49
52
|
getGraphicAttribute(key, prev = !1) {
|
|
50
53
|
return !prev && this.finalAttribute ? this.finalAttribute[key] : this.attribute[key];
|
|
51
54
|
}
|
|
52
|
-
pauseAnimation(deep = !1) {
|
|
53
|
-
this.animates && this.animates.forEach((animate => animate.pause())), deep && this.isContainer && this.forEachChildren((child => {
|
|
54
|
-
child.pauseAnimation(deep);
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
resumeAnimation(deep = !1) {
|
|
58
|
-
this.animates && this.animates.forEach((animate => animate.resume())), deep && this.isContainer && this.forEachChildren((child => {
|
|
59
|
-
child.resumeAnimation(deep);
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
62
|
-
stopAnimation(deep = !1) {
|
|
63
|
-
this.animates && this.animates.forEach((animate => animate.stop())), deep && this.isContainer && this.forEachChildren((child => {
|
|
64
|
-
child.stopAnimation(deep);
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/animate-extension.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,MAAM,OAAO,gBAAgB;IAM3B,aAAa,CAAC,QAAiB,KAAK;QAClC,IAAI,KAAK,IAAI,IAAI,CAAC,cAAc,EAAE;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC;SAC5B;QACD,OAAQ,IAAY,CAAC,SAAS,CAAC;IACjC,CAAC;IAED,OAAO,CAAC,MAA8B;;QACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE,EACV,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,mCAAI,CAAE,IAAY,CAAC,KAAK,IAAK,IAAY,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,mCAAI,eAAe,EACjG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAChB,CAAC;QAEF,OAAO,CAAC,IAAI,CAAC,IAAW,CAAC,CAAC;QAC1B,IAAI,MAAM,EAAE;YACV,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;YAC5C,OAAO,IAAI,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AmB,EAAE,CAAC;QAC3B,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAOD,iBAAiB,CAAC,OAA2B;QAC3C,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAES,iBAAiB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAGD,mBAAmB,CAAC,GAAW,EAAE,OAAgB,KAAK;QACpD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,cAAc,EAAE;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;SACjC;QACD,OAAQ,IAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;CACF","file":"animate-extension.js","sourcesContent":["// 1. 支持animate函数\n// 2. 支持animates map\n// 2. 支持animatedAttribute 为所有动画的最终结果(loop为INFINITY的动画不算)\n// 3. 支持finalAttribute 为所有动画的最终结果(animatedAttribute 合并了 graphic.attribute之后的最终结果)\n// 3. 重载Graphic的getAttributes方法,根据参数getAttributes(final = true)返回finalAttribute = {}; merge(finalAttribute, graphic.attribute, animatedAttribute),\n// animatedAttribute为所有动画的最终结果(loop为INFINITY的动画不算)\n\nimport type { IGraphicAnimateParams, IAnimate } from '@visactor/vrender-core';\nimport { Animate } from './animate';\nimport { DefaultTimeline, defaultTimeline } from './timeline';\nimport { DefaultTicker } from './ticker/default-ticker';\nimport type { IAnimationConfig } from './executor/executor';\nimport { AnimateExecutor } from './executor/animate-executor';\n\n// 基于性能考虑,每次调用animate函数,都会设置animatedAttribute为null,每次getAttributes(true)会根据animatedAttribute属性判断是否需要重新计算animatedAttribute。\nexport class AnimateExtension {\n declare finalAttribute: Record<string, any>;\n _animateExecutor: AnimateExecutor | null;\n\n declare animates: Map<string | number, IAnimate>;\n\n getAttributes(final: boolean = false) {\n if (final && this.finalAttribute) {\n return this.finalAttribute;\n }\n return (this as any).attribute;\n }\n\n animate(params?: IGraphicAnimateParams) {\n if (!this.animates) {\n this.animates = new Map();\n }\n const animate = new Animate(\n params?.id,\n params?.timeline ?? ((this as any).stage && (this as any).stage.getTimeline()) ?? defaultTimeline,\n params?.slience\n );\n\n animate.bind(this as any);\n if (params) {\n const { onStart, onEnd, onRemove } = params;\n onStart != null && animate.onStart(onStart);\n onEnd != null && animate.onEnd(onEnd);\n onRemove != null && animate.onRemove(onRemove);\n }\n this.animates.set(animate.id, animate);\n animate.onRemove(() => {\n animate.stop();\n this.animates.delete(animate.id);\n });\n\n // TODO 考虑性能问题\n (this as any).stage?.ticker.start();\n\n return animate;\n }\n\n createTimeline() {\n return new DefaultTimeline();\n }\n\n createTicker(stage: any) {\n return new DefaultTicker(stage);\n }\n\n setFinalAttributes(finalAttribute: Record<string, any>) {\n if (!this.finalAttribute) {\n this.finalAttribute = {};\n }\n Object.assign(this.finalAttribute, finalAttribute);\n }\n\n initFinalAttributes(finalAttribute: Record<string, any>) {\n this.finalAttribute = finalAttribute;\n }\n\n initAnimateExecutor(): void {\n if (!this._animateExecutor) {\n this._animateExecutor = new AnimateExecutor(this as any);\n }\n }\n\n /**\n * Apply animation configuration to the component\n * @param config Animation configuration\n * @returns This component instance\n */\n executeAnimation(config: IAnimationConfig): this {\n this.initAnimateExecutor();\n this._animateExecutor.execute(config);\n return this;\n }\n\n /**\n * Apply animations to multiple components\n * @param configs Animation configurations\n * @returns This component instance\n */\n executeAnimations(configs: IAnimationConfig[]): this {\n this.initAnimateExecutor();\n configs.forEach(config => {\n this._animateExecutor.execute(config);\n });\n return this;\n }\n\n protected getFinalAttribute() {\n return this.finalAttribute;\n }\n\n // TODO prev是兼容原本VGrammar函数的一个参数,用于动画中获取上一次属性,目前的逻辑中应该不需要,直接去当前帧的属性即可\n getGraphicAttribute(key: string, prev: boolean = false) {\n if (!prev && this.finalAttribute) {\n return this.finalAttribute[key];\n }\n return (this as any).attribute[key];\n }\n}\n"]}
|
package/es/animate.d.ts
CHANGED
package/es/animate.js
CHANGED
|
@@ -28,10 +28,7 @@ export class Animate {
|
|
|
28
28
|
return this._timeline;
|
|
29
29
|
}
|
|
30
30
|
bind(target) {
|
|
31
|
-
return this.target = target, this.target.
|
|
32
|
-
this.target.animates.set(this.id, this), this.onRemove((() => {
|
|
33
|
-
this.stop(), this.target.animates.delete(this.id);
|
|
34
|
-
})), this.target.onAnimateBind && !this.slience && this.target.onAnimateBind(this),
|
|
31
|
+
return this.target = target, this.target.onAnimateBind && !this.slience && this.target.onAnimateBind(this),
|
|
35
32
|
this.target.animationAttribute || (this.target.animationAttribute = {}), this;
|
|
36
33
|
}
|
|
37
34
|
to(props, duration = 300, easing = "linear") {
|
|
@@ -133,9 +130,7 @@ export class Animate {
|
|
|
133
130
|
}
|
|
134
131
|
release() {
|
|
135
132
|
this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach((cb => cb())),
|
|
136
|
-
this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = []
|
|
137
|
-
step.release();
|
|
138
|
-
}));
|
|
133
|
+
this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [];
|
|
139
134
|
}
|
|
140
135
|
getDuration() {
|
|
141
136
|
return this._duration;
|
|
@@ -211,9 +206,5 @@ export class Animate {
|
|
|
211
206
|
getLoop() {
|
|
212
207
|
return this._loopCount;
|
|
213
208
|
}
|
|
214
|
-
forEachStep(cb) {
|
|
215
|
-
let step = this._firstStep;
|
|
216
|
-
for (;step; ) cb(step), step = step.next;
|
|
217
|
-
}
|
|
218
209
|
}
|
|
219
210
|
//# sourceMappingURL=animate.js.map
|