@visactor/vrender-animate 0.22.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/README.md +177 -0
- package/cjs/animate-extension.d.ts +15 -0
- package/cjs/animate-extension.js +46 -0
- package/cjs/animate-extension.js.map +1 -0
- package/cjs/animate.d.ts +71 -0
- package/cjs/animate.js +210 -0
- package/cjs/animate.js.map +1 -0
- package/cjs/custom/clip-graphic.d.ts +53 -0
- package/cjs/custom/clip-graphic.js +146 -0
- package/cjs/custom/clip-graphic.js.map +1 -0
- package/cjs/custom/clip.d.ts +13 -0
- package/cjs/custom/clip.js +24 -0
- package/cjs/custom/clip.js.map +1 -0
- package/cjs/custom/common.d.ts +22 -0
- package/cjs/custom/common.js +58 -0
- package/cjs/custom/common.js.map +1 -0
- package/cjs/custom/custom-animate.d.ts +15 -0
- package/cjs/custom/custom-animate.js +25 -0
- package/cjs/custom/custom-animate.js.map +1 -0
- package/cjs/custom/fade.d.ts +13 -0
- package/cjs/custom/fade.js +24 -0
- package/cjs/custom/fade.js.map +1 -0
- package/cjs/custom/group-fade.d.ts +16 -0
- package/cjs/custom/group-fade.js +66 -0
- package/cjs/custom/group-fade.js.map +1 -0
- package/cjs/custom/growAngle.d.ts +37 -0
- package/cjs/custom/growAngle.js +140 -0
- package/cjs/custom/growAngle.js.map +1 -0
- package/cjs/custom/growCenter.d.ts +17 -0
- package/cjs/custom/growCenter.js +161 -0
- package/cjs/custom/growCenter.js.map +1 -0
- package/cjs/custom/growHeight.d.ts +36 -0
- package/cjs/custom/growHeight.js +154 -0
- package/cjs/custom/growHeight.js.map +1 -0
- package/cjs/custom/growPoints.d.ts +52 -0
- package/cjs/custom/growPoints.js +227 -0
- package/cjs/custom/growPoints.js.map +1 -0
- package/cjs/custom/growRadius.d.ts +41 -0
- package/cjs/custom/growRadius.js +113 -0
- package/cjs/custom/growRadius.js.map +1 -0
- package/cjs/custom/growWidth.d.ts +36 -0
- package/cjs/custom/growWidth.js +154 -0
- package/cjs/custom/growWidth.js.map +1 -0
- package/cjs/custom/input-text.d.ts +29 -0
- package/cjs/custom/input-text.js +45 -0
- package/cjs/custom/input-text.js.map +1 -0
- package/cjs/custom/number.d.ts +25 -0
- package/cjs/custom/number.js +102 -0
- package/cjs/custom/number.js.map +1 -0
- package/cjs/custom/register.d.ts +1 -0
- package/cjs/custom/register.js +35 -0
- package/cjs/custom/register.js.map +1 -0
- package/cjs/custom/scale-in.d.ts +13 -0
- package/cjs/custom/scale-in.js +57 -0
- package/cjs/custom/scale-in.js.map +1 -0
- package/cjs/custom/scale.d.ts +20 -0
- package/cjs/custom/scale.js +106 -0
- package/cjs/custom/scale.js.map +1 -0
- package/cjs/custom/sphere.d.ts +20 -0
- package/cjs/custom/sphere.js +26 -0
- package/cjs/custom/sphere.js.map +1 -0
- package/cjs/custom/state.d.ts +13 -0
- package/cjs/custom/state.js +25 -0
- package/cjs/custom/state.js.map +1 -0
- package/cjs/custom/tag-points.d.ts +26 -0
- package/cjs/custom/tag-points.js +81 -0
- package/cjs/custom/tag-points.js.map +1 -0
- package/cjs/custom/update.d.ts +14 -0
- package/cjs/custom/update.js +26 -0
- package/cjs/custom/update.js.map +1 -0
- package/cjs/executor/animate-executor.d.ts +36 -0
- package/cjs/executor/animate-executor.js +177 -0
- package/cjs/executor/animate-executor.js.map +1 -0
- package/cjs/executor/executor.d.ts +69 -0
- package/cjs/executor/executor.js +6 -0
- package/cjs/executor/executor.js.map +1 -0
- package/cjs/index.d.ts +25 -0
- package/cjs/index.js +214 -0
- package/cjs/index.js.map +1 -0
- package/cjs/interpolate/executor.d.ts +66 -0
- package/cjs/interpolate/executor.js +6 -0
- package/cjs/interpolate/executor.js.map +1 -0
- package/cjs/interpolate/number.d.ts +1 -0
- package/cjs/interpolate/number.js +10 -0
- package/cjs/interpolate/number.js.map +1 -0
- package/cjs/interpolate/store.d.ts +32 -0
- package/cjs/interpolate/store.js +96 -0
- package/cjs/interpolate/store.js.map +1 -0
- package/cjs/intreface/animate.d.ts +91 -0
- package/cjs/intreface/animate.js +10 -0
- package/cjs/intreface/animate.js.map +1 -0
- package/cjs/intreface/easing.d.ts +3 -0
- package/cjs/intreface/easing.js +6 -0
- package/cjs/intreface/easing.js.map +1 -0
- package/cjs/intreface/state.d.ts +35 -0
- package/cjs/intreface/state.js +6 -0
- package/cjs/intreface/state.js.map +1 -0
- package/cjs/intreface/ticker.d.ts +37 -0
- package/cjs/intreface/ticker.js +10 -0
- package/cjs/intreface/ticker.js.map +1 -0
- package/cjs/intreface/timeline.d.ts +17 -0
- package/cjs/intreface/timeline.js +6 -0
- package/cjs/intreface/timeline.js.map +1 -0
- package/cjs/intreface/type.d.ts +13 -0
- package/cjs/intreface/type.js +15 -0
- package/cjs/intreface/type.js.map +1 -0
- package/cjs/register.d.ts +1 -0
- package/cjs/register.js +19 -0
- package/cjs/register.js.map +1 -0
- package/cjs/state/animation-state-machine.d.ts +22 -0
- package/cjs/state/animation-state-machine.js +53 -0
- package/cjs/state/animation-state-machine.js.map +1 -0
- package/cjs/state/animation-state-queue.d.ts +24 -0
- package/cjs/state/animation-state-queue.js +66 -0
- package/cjs/state/animation-state-queue.js.map +1 -0
- package/cjs/state/animation-state-registry.d.ts +14 -0
- package/cjs/state/animation-state-registry.js +53 -0
- package/cjs/state/animation-state-registry.js.map +1 -0
- package/cjs/state/animation-state.d.ts +25 -0
- package/cjs/state/animation-state.js +80 -0
- package/cjs/state/animation-state.js.map +1 -0
- package/cjs/state/animation-states-registry.d.ts +17 -0
- package/cjs/state/animation-states-registry.js +95 -0
- package/cjs/state/animation-states-registry.js.map +1 -0
- package/cjs/state/graphic-extension.d.ts +12 -0
- package/cjs/state/graphic-extension.js +37 -0
- package/cjs/state/graphic-extension.js.map +1 -0
- package/cjs/state/index.d.ts +3 -0
- package/cjs/state/index.js +22 -0
- package/cjs/state/index.js.map +1 -0
- package/cjs/state/types.d.ts +11 -0
- package/cjs/state/types.js +6 -0
- package/cjs/state/types.js.map +1 -0
- package/cjs/step.d.ts +49 -0
- package/cjs/step.js +124 -0
- package/cjs/step.js.map +1 -0
- package/cjs/ticker/default-ticker.d.ts +39 -0
- package/cjs/ticker/default-ticker.js +133 -0
- package/cjs/ticker/default-ticker.js.map +1 -0
- package/cjs/ticker/manual-ticker.d.ts +6 -0
- package/cjs/ticker/manual-ticker.js +37 -0
- package/cjs/ticker/manual-ticker.js.map +1 -0
- package/cjs/timeline.d.ts +34 -0
- package/cjs/timeline.js +84 -0
- package/cjs/timeline.js.map +1 -0
- package/cjs/utils/easing-func.d.ts +1 -0
- package/cjs/utils/easing-func.js +16 -0
- package/cjs/utils/easing-func.js.map +1 -0
- package/cjs/utils/easing.d.ts +49 -0
- package/cjs/utils/easing.js +141 -0
- package/cjs/utils/easing.js.map +1 -0
- package/dist/index.es.js +3824 -0
- package/es/animate-extension.d.ts +15 -0
- package/es/animate-extension.js +42 -0
- package/es/animate-extension.js.map +1 -0
- package/es/animate.d.ts +71 -0
- package/es/animate.js +207 -0
- package/es/animate.js.map +1 -0
- package/es/custom/clip-graphic.d.ts +53 -0
- package/es/custom/clip-graphic.js +134 -0
- package/es/custom/clip-graphic.js.map +1 -0
- package/es/custom/clip.d.ts +13 -0
- package/es/custom/clip.js +14 -0
- package/es/custom/clip.js.map +1 -0
- package/es/custom/common.d.ts +22 -0
- package/es/custom/common.js +48 -0
- package/es/custom/common.js.map +1 -0
- package/es/custom/custom-animate.d.ts +15 -0
- package/es/custom/custom-animate.js +17 -0
- package/es/custom/custom-animate.js.map +1 -0
- package/es/custom/fade.d.ts +13 -0
- package/es/custom/fade.js +14 -0
- package/es/custom/fade.js.map +1 -0
- package/es/custom/group-fade.d.ts +16 -0
- package/es/custom/group-fade.js +56 -0
- package/es/custom/group-fade.js.map +1 -0
- package/es/custom/growAngle.d.ts +37 -0
- package/es/custom/growAngle.js +132 -0
- package/es/custom/growAngle.js.map +1 -0
- package/es/custom/growCenter.d.ts +17 -0
- package/es/custom/growCenter.js +155 -0
- package/es/custom/growCenter.js.map +1 -0
- package/es/custom/growHeight.d.ts +36 -0
- package/es/custom/growHeight.js +144 -0
- package/es/custom/growHeight.js.map +1 -0
- package/es/custom/growPoints.d.ts +52 -0
- package/es/custom/growPoints.js +219 -0
- package/es/custom/growPoints.js.map +1 -0
- package/es/custom/growRadius.d.ts +41 -0
- package/es/custom/growRadius.js +105 -0
- package/es/custom/growRadius.js.map +1 -0
- package/es/custom/growWidth.d.ts +36 -0
- package/es/custom/growWidth.js +144 -0
- package/es/custom/growWidth.js.map +1 -0
- package/es/custom/input-text.d.ts +29 -0
- package/es/custom/input-text.js +37 -0
- package/es/custom/input-text.js.map +1 -0
- package/es/custom/number.d.ts +25 -0
- package/es/custom/number.js +94 -0
- package/es/custom/number.js.map +1 -0
- package/es/custom/register.d.ts +1 -0
- package/es/custom/register.js +39 -0
- package/es/custom/register.js.map +1 -0
- package/es/custom/scale-in.d.ts +13 -0
- package/es/custom/scale-in.js +49 -0
- package/es/custom/scale-in.js.map +1 -0
- package/es/custom/scale.d.ts +20 -0
- package/es/custom/scale.js +96 -0
- package/es/custom/scale.js.map +1 -0
- package/es/custom/sphere.d.ts +20 -0
- package/es/custom/sphere.js +20 -0
- package/es/custom/sphere.js.map +1 -0
- package/es/custom/state.d.ts +13 -0
- package/es/custom/state.js +17 -0
- package/es/custom/state.js.map +1 -0
- package/es/custom/tag-points.d.ts +26 -0
- package/es/custom/tag-points.js +77 -0
- package/es/custom/tag-points.js.map +1 -0
- package/es/custom/update.d.ts +14 -0
- package/es/custom/update.js +18 -0
- package/es/custom/update.js.map +1 -0
- package/es/executor/animate-executor.d.ts +36 -0
- package/es/executor/animate-executor.js +169 -0
- package/es/executor/animate-executor.js.map +1 -0
- package/es/executor/executor.d.ts +69 -0
- package/es/executor/executor.js +2 -0
- package/es/executor/executor.js.map +1 -0
- package/es/index.d.ts +25 -0
- package/es/index.js +50 -0
- package/es/index.js.map +1 -0
- package/es/interpolate/executor.d.ts +66 -0
- package/es/interpolate/executor.js +2 -0
- package/es/interpolate/executor.js.map +1 -0
- package/es/interpolate/number.d.ts +1 -0
- package/es/interpolate/number.js +4 -0
- package/es/interpolate/number.js.map +1 -0
- package/es/interpolate/store.d.ts +32 -0
- package/es/interpolate/store.js +88 -0
- package/es/interpolate/store.js.map +1 -0
- package/es/intreface/animate.d.ts +91 -0
- package/es/intreface/animate.js +6 -0
- package/es/intreface/animate.js.map +1 -0
- package/es/intreface/easing.d.ts +3 -0
- package/es/intreface/easing.js +2 -0
- package/es/intreface/easing.js.map +1 -0
- package/es/intreface/state.d.ts +35 -0
- package/es/intreface/state.js +2 -0
- package/es/intreface/state.js.map +1 -0
- package/es/intreface/ticker.d.ts +37 -0
- package/es/intreface/ticker.js +6 -0
- package/es/intreface/ticker.js.map +1 -0
- package/es/intreface/timeline.d.ts +17 -0
- package/es/intreface/timeline.js +2 -0
- package/es/intreface/timeline.js.map +1 -0
- package/es/intreface/type.d.ts +13 -0
- package/es/intreface/type.js +14 -0
- package/es/intreface/type.js.map +1 -0
- package/es/register.d.ts +1 -0
- package/es/register.js +20 -0
- package/es/register.js.map +1 -0
- package/es/state/animation-state-machine.d.ts +22 -0
- package/es/state/animation-state-machine.js +47 -0
- package/es/state/animation-state-machine.js.map +1 -0
- package/es/state/animation-state-queue.d.ts +24 -0
- package/es/state/animation-state-queue.js +58 -0
- package/es/state/animation-state-queue.js.map +1 -0
- package/es/state/animation-state-registry.d.ts +14 -0
- package/es/state/animation-state-registry.js +45 -0
- package/es/state/animation-state-registry.js.map +1 -0
- package/es/state/animation-state.d.ts +25 -0
- package/es/state/animation-state.js +72 -0
- package/es/state/animation-state.js.map +1 -0
- package/es/state/animation-states-registry.d.ts +17 -0
- package/es/state/animation-states-registry.js +87 -0
- package/es/state/animation-states-registry.js.map +1 -0
- package/es/state/graphic-extension.d.ts +12 -0
- package/es/state/graphic-extension.js +29 -0
- package/es/state/graphic-extension.js.map +1 -0
- package/es/state/index.d.ts +3 -0
- package/es/state/index.js +6 -0
- package/es/state/index.js.map +1 -0
- package/es/state/types.d.ts +11 -0
- package/es/state/types.js +2 -0
- package/es/state/types.js.map +1 -0
- package/es/step.d.ts +49 -0
- package/es/step.js +120 -0
- package/es/step.js.map +1 -0
- package/es/ticker/default-ticker.d.ts +39 -0
- package/es/ticker/default-ticker.js +129 -0
- package/es/ticker/default-ticker.js.map +1 -0
- package/es/ticker/manual-ticker.d.ts +6 -0
- package/es/ticker/manual-ticker.js +29 -0
- package/es/ticker/manual-ticker.js.map +1 -0
- package/es/timeline.d.ts +34 -0
- package/es/timeline.js +79 -0
- package/es/timeline.js.map +1 -0
- package/es/utils/easing-func.d.ts +1 -0
- package/es/utils/easing-func.js +8 -0
- package/es/utils/easing-func.js.map +1 -0
- package/es/utils/easing.d.ts +49 -0
- package/es/utils/easing.js +134 -0
- package/es/utils/easing.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { cloneDeep, isArray, isFunction } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
export class AnimateExecutor {
|
|
4
|
+
static registerBuiltInAnimate(name, animate) {
|
|
5
|
+
AnimateExecutor.builtInAnimateMap[name] = animate;
|
|
6
|
+
}
|
|
7
|
+
constructor(target) {
|
|
8
|
+
this._animates = [], this._startCallbacks = [], this._endCallbacks = [], this._started = !1,
|
|
9
|
+
this._activeCount = 0, this._target = target;
|
|
10
|
+
}
|
|
11
|
+
onStart(cb) {
|
|
12
|
+
cb ? (this._startCallbacks.push(cb), this._started && this._activeCount > 0 && cb()) : this._startCallbacks.forEach((cb => {
|
|
13
|
+
cb();
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
onEnd(cb) {
|
|
17
|
+
cb ? this._endCallbacks.push(cb) : this._endCallbacks.forEach((cb => {
|
|
18
|
+
cb();
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
_trackAnimation(animate) {
|
|
22
|
+
this._animates.push(animate), this._activeCount++, 1 !== this._activeCount || this._started || (this._started = !0,
|
|
23
|
+
this.onStart()), animate.onEnd((() => {
|
|
24
|
+
this._activeCount--;
|
|
25
|
+
const index = this._animates.indexOf(animate);
|
|
26
|
+
index >= 0 && this._animates.splice(index, 1), 0 === this._activeCount && this._started && (this._started = !1,
|
|
27
|
+
this.onEnd());
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
parseParams(params) {
|
|
31
|
+
const isTimeline = "timeSlices" in params, totalTime = this.resolveValue(params.totalTime, void 0, void 0), startTime = this.resolveValue(params.startTime, void 0, 0), parsedParams = cloneDeep(params);
|
|
32
|
+
parsedParams.oneByOneDelay = 0, parsedParams.startTime = startTime, parsedParams.totalTime = totalTime;
|
|
33
|
+
const oneByOne = this.resolveValue(params.oneByOne, void 0, !1);
|
|
34
|
+
if (isTimeline) {
|
|
35
|
+
const timeSlices = parsedParams.timeSlices;
|
|
36
|
+
isArray(timeSlices) || (parsedParams.timeSlices = [ timeSlices ]);
|
|
37
|
+
let sliceTime = 0;
|
|
38
|
+
parsedParams.timeSlices.forEach((slice => {
|
|
39
|
+
slice.delay = this.resolveValue(slice.delay, void 0, 0), slice.delayAfter = this.resolveValue(slice.delayAfter, void 0, 0),
|
|
40
|
+
slice.duration = this.resolveValue(slice.duration, void 0, 300), sliceTime += slice.delay + slice.duration + slice.delayAfter;
|
|
41
|
+
}));
|
|
42
|
+
let oneByOneDelay = 0, oneByOneTime = 0;
|
|
43
|
+
if (oneByOne && (oneByOneTime = Number(oneByOne), oneByOneDelay = oneByOneTime),
|
|
44
|
+
parsedParams.oneByOne = oneByOneTime, parsedParams.oneByOneDelay = oneByOneDelay,
|
|
45
|
+
totalTime) {
|
|
46
|
+
const _totalTime = sliceTime + oneByOneDelay * (this._target.count - 2), scale = totalTime ? totalTime / _totalTime : 1;
|
|
47
|
+
parsedParams.timeSlices.forEach((slice => {
|
|
48
|
+
slice.delay = slice.delay * scale, slice.delayAfter = slice.delayAfter * scale,
|
|
49
|
+
slice.duration = slice.duration * scale;
|
|
50
|
+
})), parsedParams.oneByOne = oneByOneTime * scale, parsedParams.oneByOneDelay = oneByOneDelay * scale,
|
|
51
|
+
parsedParams.startTime = startTime * scale;
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
const delay = this.resolveValue(params.delay, void 0, 0), delayAfter = this.resolveValue(params.delayAfter, void 0, 0), duration = this.resolveValue(params.duration, void 0, 300);
|
|
55
|
+
let oneByOneDelay = 0, oneByOneTime = 0;
|
|
56
|
+
if (oneByOne && (oneByOneTime = Number(oneByOne), oneByOneDelay = duration + oneByOneTime),
|
|
57
|
+
parsedParams.oneByOne = oneByOneTime, parsedParams.oneByOneDelay = oneByOneDelay,
|
|
58
|
+
totalTime) {
|
|
59
|
+
const _totalTime = delay + delayAfter + duration + oneByOneDelay * (this._target.count - 2), scale = totalTime ? totalTime / _totalTime : 1;
|
|
60
|
+
parsedParams.delay = delay * scale, parsedParams.delayAfter = delayAfter * scale,
|
|
61
|
+
parsedParams.duration = duration * scale, parsedParams.oneByOne = oneByOneTime * scale,
|
|
62
|
+
parsedParams.oneByOneDelay = oneByOneDelay * scale, parsedParams.startTime = startTime;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return parsedParams;
|
|
66
|
+
}
|
|
67
|
+
execute(params) {
|
|
68
|
+
const isTimeline = "timeSlices" in params;
|
|
69
|
+
let filteredChildren;
|
|
70
|
+
isTimeline && params.partitioner && (filteredChildren = (null != filteredChildren ? filteredChildren : this._target.getChildren()).filter((child => {
|
|
71
|
+
var _a;
|
|
72
|
+
return params.partitioner(null === (_a = child.context) || void 0 === _a ? void 0 : _a.data, child, {});
|
|
73
|
+
}))), isTimeline && params.sort && (filteredChildren = null != filteredChildren ? filteredChildren : this._target.getChildren(),
|
|
74
|
+
filteredChildren.sort(((a, b) => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
return params.sort(null === (_a = a.context) || void 0 === _a ? void 0 : _a.data, null === (_b = b.context) || void 0 === _b ? void 0 : _b.data, a, b, {});
|
|
77
|
+
})));
|
|
78
|
+
const parsedParams = this.parseParams(params), cb = isTimeline ? (child, index, count) => {
|
|
79
|
+
const animate = this.executeTimelineItem(parsedParams, child, index, count);
|
|
80
|
+
animate && this._trackAnimation(animate);
|
|
81
|
+
} : (child, index, count) => {
|
|
82
|
+
const animate = this.executeTypeConfigItem(parsedParams, child, index, count);
|
|
83
|
+
animate && this._trackAnimation(animate);
|
|
84
|
+
};
|
|
85
|
+
filteredChildren ? filteredChildren.forEach(((child, index) => cb(child, index, filteredChildren.length))) : this._target.count <= 1 ? cb(this._target, 0, 1) : this._target.forEachChildren(((child, index) => cb(child, index, this._target.count - 1)));
|
|
86
|
+
}
|
|
87
|
+
executeTypeConfigItem(params, graphic, index, count) {
|
|
88
|
+
var _a, _b, _c, _d, _e, _f;
|
|
89
|
+
const {type: type, channel: channel, customParameters: customParameters, easing: easing = "linear", delay: delay = 0, delayAfter: delayAfter = 0, duration: duration = 300, startTime: startTime = 0, oneByOneDelay: oneByOneDelay = 0, loop: loop, bounce: bounce, priority: priority = 0, options: options, controlOptions: controlOptions} = params, custom = null !== (_a = params.custom) && void 0 !== _a ? _a : AnimateExecutor.builtInAnimateMap[type], animate = graphic.animate();
|
|
90
|
+
animate.priority = priority;
|
|
91
|
+
const delayValue = delay, datum = null === (_c = null === (_b = graphic.context) || void 0 === _b ? void 0 : _b.data) || void 0 === _c ? void 0 : _c[0], indexKey = null === (_d = graphic.context) || void 0 === _d ? void 0 : _d.indexKey;
|
|
92
|
+
datum && indexKey && (index = null !== (_e = datum[indexKey]) && void 0 !== _e ? _e : index),
|
|
93
|
+
animate.startAt(startTime), animate.wait(index * oneByOneDelay), delayValue > 0 && animate.wait(delayValue);
|
|
94
|
+
const props = null !== (_f = params.to) && void 0 !== _f ? _f : this.createPropsFromChannel(channel, graphic);
|
|
95
|
+
return this._handleRunAnimate(animate, custom, props, duration, easing, customParameters, options, type, graphic),
|
|
96
|
+
oneByOneDelay && animate.wait(oneByOneDelay * (count - index - 1)), delayAfter > 0 && animate.wait(delayAfter),
|
|
97
|
+
loop && loop > 0 && animate.loop(loop), bounce && animate.bounce(!0), animate;
|
|
98
|
+
}
|
|
99
|
+
_handleRunAnimate(animate, custom, props, duration, easing, customParameters, options, type, graphic) {
|
|
100
|
+
if (custom) {
|
|
101
|
+
const customParams = this.resolveValue(customParameters, graphic, {}), objOptions = isFunction(options) ? options.call(null, customParameters.data && customParameters.data[0], graphic, customParameters) : options;
|
|
102
|
+
customParams.options = objOptions, isFunction(custom) && (/^class\s/.test(Function.prototype.toString.call(custom)) ? this.createCustomAnimation(animate, custom, props, duration, easing, customParams) : this.createCustomInterpolatorAnimation(animate, custom, props, duration, easing, customParams));
|
|
103
|
+
} else "to" === type ? animate.to(props, duration, easing) : "from" === type && animate.from(props, duration, easing);
|
|
104
|
+
}
|
|
105
|
+
executeTimelineItem(params, graphic, index, count) {
|
|
106
|
+
var _a, _b, _c, _d;
|
|
107
|
+
const {timeSlices: timeSlices, startTime: startTime = 0, loop: loop, bounce: bounce, oneByOneDelay: oneByOneDelay, priority: priority, controlOptions: controlOptions} = params, datum = null === (_b = null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b[0], indexKey = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.indexKey;
|
|
108
|
+
datum && indexKey && (index = null !== (_d = datum[indexKey]) && void 0 !== _d ? _d : index);
|
|
109
|
+
const animate = graphic.animate();
|
|
110
|
+
animate.priority = priority, animate.startAt(startTime), animate.wait(index * oneByOneDelay),
|
|
111
|
+
loop && loop > 0 && animate.loop(loop), bounce && animate.bounce(!0);
|
|
112
|
+
return (Array.isArray(timeSlices) ? timeSlices : [ timeSlices ]).forEach((slice => {
|
|
113
|
+
this.applyTimeSliceToAnimate(slice, animate, graphic);
|
|
114
|
+
})), oneByOneDelay && animate.wait(oneByOneDelay * (count - index - 1)), animate;
|
|
115
|
+
}
|
|
116
|
+
applyTimeSliceToAnimate(slice, animate, graphic) {
|
|
117
|
+
const {effects: effects, duration: duration = 300, delay: delay = 0, delayAfter: delayAfter = 0} = slice, delayValue = delay, delayAfterValue = delayAfter;
|
|
118
|
+
delayValue > 0 && animate.wait(delayValue);
|
|
119
|
+
(Array.isArray(effects) ? effects : [ effects ]).forEach((effect => {
|
|
120
|
+
var _a;
|
|
121
|
+
const {type: type = "to", channel: channel, customParameters: customParameters, easing: easing = "linear", options: options} = effect, custom = null !== (_a = effect.custom) && void 0 !== _a ? _a : AnimateExecutor.builtInAnimateMap[type], props = this.createPropsFromChannel(channel, graphic);
|
|
122
|
+
this._handleRunAnimate(animate, custom, props, duration, easing, customParameters, options, type, graphic);
|
|
123
|
+
})), delayAfterValue > 0 && animate.wait(delayAfterValue);
|
|
124
|
+
}
|
|
125
|
+
createCustomInterpolatorAnimation(animate, interpolator, props, duration, easing, customParams) {
|
|
126
|
+
const from = {}, to = props;
|
|
127
|
+
Object.keys(to).forEach((key => {
|
|
128
|
+
from[key] = animate.target.getComputedAttribute(key);
|
|
129
|
+
})), animate.interpolateUpdateFunction = (from, to, ratio, step, target) => {
|
|
130
|
+
interpolator(ratio, from, to, step, target, animate.target, customParams);
|
|
131
|
+
}, animate.to(props, duration, easing);
|
|
132
|
+
}
|
|
133
|
+
createCustomAnimation(animate, CustomAnimateConstructor, props, duration, easing, customParams) {
|
|
134
|
+
const from = {}, to = props;
|
|
135
|
+
Object.keys(to).forEach((key => {
|
|
136
|
+
from[key] = animate.target.getComputedAttribute(key);
|
|
137
|
+
}));
|
|
138
|
+
const customAnimate = new CustomAnimateConstructor(from, to, duration, easing, customParams);
|
|
139
|
+
animate.play(customAnimate);
|
|
140
|
+
}
|
|
141
|
+
createPropsFromChannel(channel, graphic) {
|
|
142
|
+
const props = {};
|
|
143
|
+
return channel ? (Array.isArray(channel) || Object.entries(channel).forEach((([key, config]) => {
|
|
144
|
+
var _a;
|
|
145
|
+
void 0 !== config.to && ("function" == typeof config.to ? props[key] = config.to(null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.data, graphic, {}) : props[key] = config.to);
|
|
146
|
+
})), props) : props;
|
|
147
|
+
}
|
|
148
|
+
resolveValue(value, graphic, defaultValue) {
|
|
149
|
+
var _a;
|
|
150
|
+
return void 0 === value ? defaultValue : "function" == typeof value && graphic ? value(null === (_a = graphic.context) || void 0 === _a ? void 0 : _a.data, graphic, {}) : value;
|
|
151
|
+
}
|
|
152
|
+
executeItem(params, graphic, index = 0, count = 1) {
|
|
153
|
+
if (!graphic) return null;
|
|
154
|
+
let animate = null;
|
|
155
|
+
return animate = "timeSlices" in params ? this.executeTimelineItem(params, graphic, index, count) : this.executeTypeConfigItem(params, graphic, index, count),
|
|
156
|
+
animate && this._trackAnimation(animate), animate;
|
|
157
|
+
}
|
|
158
|
+
stop(type) {
|
|
159
|
+
for (;this._animates.length > 0; ) {
|
|
160
|
+
const animate = this._animates.pop();
|
|
161
|
+
null == animate || animate.stop(type);
|
|
162
|
+
}
|
|
163
|
+
this._animates = [], this._activeCount = 0, this._started && (this._started = !1,
|
|
164
|
+
this.onEnd());
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
AnimateExecutor.builtInAnimateMap = {};
|
|
169
|
+
//# sourceMappingURL=animate-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/executor/animate-executor.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAS,MAAM,kBAAkB,CAAC;AASzE,MAAM,OAAO,eAAe;IAG1B,MAAM,CAAC,sBAAsB,CAAC,IAAY,EAAE,OAAoC;QAC9E,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACpD,CAAC;IAkBD,YAAY,MAAgB;QAbpB,cAAS,GAAe,EAAE,CAAC;QAG3B,oBAAe,GAAmB,EAAE,CAAC;QAErC,kBAAa,GAAmB,EAAE,CAAC;QAGnC,aAAQ,GAAY,KA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C1C,IAAI,OAAO,GAAoB,IAAI,CAAC;QAEpC,IAAI,UAAU,EAAE;YAEd,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAA4B,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SACzF;aAAM;YAEL,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAA8B,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SAC7F;QAGD,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;SAC/B;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAKD,IAAI,CAAC,IAA4C;QAE/C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YAChC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;YACrC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;QAGD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QAGtB,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACtB,IAAI,CAAC,KAAK,EAAE,CAAC;SACd;IACH,CAAC;;AA7kBM,iCAAiB,GAAgD,EAAE,CAAC","file":"animate-executor.js","sourcesContent":["import type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport type {\n IAnimationConfig,\n IAnimationTimeline,\n IAnimationTypeConfig,\n MarkFunctionCallback,\n MarkFunctionValueType,\n IAnimationTimeSlice,\n IAnimationChannelAttrs,\n IAnimationChannelAttributes,\n IAnimationCustomConstructor,\n IAnimationChannelInterpolator\n} from './executor';\nimport type { EasingType } from '../intreface/easing';\nimport type { IAnimate } from '../intreface/animate';\nimport { cloneDeep, isArray, isFunction, scale } from '@visactor/vutils';\n\ninterface IAnimateExecutor {\n execute: (params: IAnimationConfig) => void;\n executeItem: (params: IAnimationConfig, graphic: IGraphic, index?: number) => IAnimate | null;\n onStart: (cb?: () => void) => void;\n onEnd: (cb?: () => void) => void;\n}\n\nexport class AnimateExecutor implements IAnimateExecutor {\n static builtInAnimateMap: Record<string, IAnimationCustomConstructor> = {};\n\n static registerBuiltInAnimate(name: string, animate: IAnimationCustomConstructor) {\n AnimateExecutor.builtInAnimateMap[name] = animate;\n }\n\n declare _target: IGraphic;\n\n // 所有动画实例\n private _animates: IAnimate[] = [];\n\n // 动画开始回调\n private _startCallbacks: (() => void)[] = [];\n // 动画结束回调\n private _endCallbacks: (() => void)[] = [];\n\n // 是否已经开始动画\n private _started: boolean = false;\n\n // 当前正在运行的动画数量\n private _activeCount: number = 0;\n\n constructor(target: IGraphic) {\n this._target = target;\n }\n\n /**\n * 注册一个回调,当动画开始时调用\n */\n onStart(cb?: () => void): void {\n if (cb) {\n this._startCallbacks.push(cb);\n\n // 如果动画已经开始,立即调用回调\n if (this._started && this._activeCount > 0) {\n cb();\n }\n } else {\n this._startCallbacks.forEach(cb => {\n cb();\n });\n }\n }\n\n /**\n * 注册一个回调,当所有动画结束时调用\n */\n onEnd(cb?: () => void): void {\n if (cb) {\n this._endCallbacks.push(cb);\n } else {\n this._endCallbacks.forEach(cb => {\n cb();\n });\n }\n }\n\n /**\n * 跟踪动画并附加生命周期钩子\n */\n private _trackAnimation(animate: IAnimate): void {\n this._animates.push(animate);\n this._activeCount++;\n\n // 如果这是第一个正在运行的动画,触发onStart回调\n if (this._activeCount === 1 && !this._started) {\n this._started = true;\n this.onStart();\n }\n\n // 处理动画完成\n animate.onEnd(() => {\n this._activeCount--;\n\n // 从跟踪的动画中移除\n const index = this._animates.indexOf(animate);\n if (index >= 0) {\n this._animates.splice(index, 1);\n }\n\n // 如果所有动画都已完成,触发onEnd回调\n if (this._activeCount === 0 && this._started) {\n this._started = false;\n this.onEnd();\n }\n });\n }\n\n parseParams(params: IAnimationConfig): IAnimationConfig {\n const isTimeline = 'timeSlices' in params;\n\n const totalTime = this.resolveValue(params.totalTime, undefined, undefined);\n const startTime = this.resolveValue(params.startTime, undefined, 0);\n\n // execute只在mark层面调用,所以性能影响可以忽略\n // TODO 如果后续调用频繁,需要重新修改\n const parsedParams = cloneDeep(params);\n parsedParams.oneByOneDelay = 0;\n parsedParams.startTime = startTime;\n parsedParams.totalTime = totalTime;\n\n const oneByOne = this.resolveValue(params.oneByOne, undefined, false);\n\n if (isTimeline) {\n const timeSlices = (parsedParams as IAnimationTimeline).timeSlices;\n if (!isArray(timeSlices)) {\n (parsedParams as IAnimationTimeline).timeSlices = [timeSlices];\n }\n let sliceTime = 0;\n ((parsedParams as IAnimationTimeline).timeSlices as IAnimationTimeSlice[]).forEach(slice => {\n slice.delay = this.resolveValue(slice.delay, undefined, 0);\n slice.delayAfter = this.resolveValue(slice.delayAfter, undefined, 0);\n slice.duration = this.resolveValue(slice.duration, undefined, 300);\n sliceTime += slice.delay + slice.duration + slice.delayAfter;\n });\n let oneByOneDelay = 0;\n let oneByOneTime = 0;\n if (oneByOne) {\n oneByOneTime = Number(oneByOne);\n oneByOneDelay = oneByOneTime;\n }\n parsedParams.oneByOne = oneByOneTime;\n parsedParams.oneByOneDelay = oneByOneDelay;\n\n if (totalTime) {\n const _totalTime = sliceTime + oneByOneDelay * (this._target.count - 2);\n const scale = totalTime ? totalTime / _totalTime : 1;\n ((parsedParams as IAnimationTimeline).timeSlices as IAnimationTimeSlice[]).forEach(slice => {\n slice.delay = (slice.delay as number) * scale;\n slice.delayAfter = (slice.delayAfter as number) * scale;\n slice.duration = (slice.duration as number) * scale;\n });\n parsedParams.oneByOne = oneByOneTime * scale;\n parsedParams.oneByOneDelay = oneByOneDelay * scale;\n (parsedParams as IAnimationTimeline).startTime = startTime * scale;\n }\n } else {\n const delay = this.resolveValue(params.delay, undefined, 0);\n const delayAfter = this.resolveValue(params.delayAfter, undefined, 0);\n const duration = this.resolveValue(params.duration, undefined, 300);\n\n let oneByOneDelay = 0;\n let oneByOneTime = 0;\n if (oneByOne) {\n oneByOneTime = Number(oneByOne);\n oneByOneDelay = duration + oneByOneTime;\n }\n parsedParams.oneByOne = oneByOneTime;\n parsedParams.oneByOneDelay = oneByOneDelay;\n\n if (totalTime) {\n const _totalTime = delay + delayAfter + duration + oneByOneDelay * (this._target.count - 2);\n const scale = totalTime ? totalTime / _totalTime : 1;\n parsedParams.delay = delay * scale;\n parsedParams.delayAfter = delayAfter * scale;\n parsedParams.duration = duration * scale;\n parsedParams.oneByOne = oneByOneTime * scale;\n parsedParams.oneByOneDelay = oneByOneDelay * scale;\n (parsedParams as IAnimationTypeConfig).startTime = startTime;\n }\n }\n\n return parsedParams;\n }\n\n /**\n * 执行动画,针对一组元素\n */\n execute(params: IAnimationConfig) {\n // 判断是否为timeline配置\n const isTimeline = 'timeSlices' in params;\n\n // 筛选符合条件的子图元\n let filteredChildren: IGraphic[];\n\n // 如果设置了partitioner,则进行筛选\n if (isTimeline && params.partitioner) {\n filteredChildren = (filteredChildren ?? (this._target.getChildren() as IGraphic[])).filter(child => {\n return (params as IAnimationTimeline).partitioner((child.context as any)?.data, child, {});\n });\n }\n\n // 如果需要排序,则进行排序\n if (isTimeline && (params as IAnimationTimeline).sort) {\n filteredChildren = filteredChildren ?? (this._target.getChildren() as IGraphic[]);\n filteredChildren.sort((a, b) => {\n return (params as IAnimationTimeline).sort((a.context as any)?.data, (b.context as any)?.data, a, b, {});\n });\n }\n\n const parsedParams = this.parseParams(params);\n\n const cb = isTimeline\n ? (child: IGraphic, index: number, count: number) => {\n // 执行单个图元的timeline动画\n const animate = this.executeTimelineItem(parsedParams as IAnimationTimeline, child, index, count);\n if (animate) {\n this._trackAnimation(animate);\n }\n }\n : (child: IGraphic, index: number, count: number) => {\n // 执行单个图元的config动画\n const animate = this.executeTypeConfigItem(parsedParams as IAnimationTypeConfig, child, index, count);\n if (animate) {\n this._trackAnimation(animate);\n }\n };\n\n // 执行每个图元的动画\n if (filteredChildren) {\n filteredChildren.forEach((child, index) => cb(child, index, filteredChildren.length));\n } else if (this._target.count <= 1) {\n cb(this._target, 0, 1);\n } else {\n this._target.forEachChildren((child, index) => cb(child as IGraphic, index, this._target.count - 1));\n }\n\n return;\n }\n\n /**\n * 执行 TypeConfig 类型的动画\n */\n private executeTypeConfigItem(\n params: IAnimationTypeConfig,\n graphic: IGraphic,\n index: number,\n count: number\n ): IAnimate {\n const {\n type,\n channel,\n customParameters,\n easing = 'linear',\n delay = 0,\n delayAfter = 0,\n duration = 300,\n startTime = 0,\n oneByOneDelay = 0,\n loop,\n bounce,\n priority = 0,\n options,\n controlOptions\n } = params as any;\n const custom = params.custom ?? AnimateExecutor.builtInAnimateMap[type];\n\n // 创建动画实例\n const animate = graphic.animate() as unknown as IAnimate;\n animate.priority = priority;\n\n const delayValue = delay as number;\n\n // 如果设置了indexKey,则使用indexKey作为index\n const datum = graphic.context?.data?.[0];\n const indexKey = graphic.context?.indexKey;\n if (datum && indexKey) {\n index = datum[indexKey] ?? index;\n }\n\n // 设置开始时间\n animate.startAt(startTime as number);\n animate.wait(index * oneByOneDelay);\n\n // 添加延迟\n if (delayValue > 0) {\n animate.wait(delayValue);\n }\n\n // 根据 channel 配置创建属性对象\n const props = params.to ?? this.createPropsFromChannel(channel, graphic);\n\n this._handleRunAnimate(\n animate,\n custom,\n props,\n duration as number,\n easing,\n customParameters,\n options,\n type,\n graphic\n );\n\n if (oneByOneDelay) {\n animate.wait(oneByOneDelay * (count - index - 1));\n }\n\n // 添加后延迟\n if ((delayAfter as number) > 0) {\n animate.wait(delayAfter as number);\n }\n\n // 设置循环\n if (loop && (loop as number) > 0) {\n animate.loop(loop as number);\n }\n\n // 设置反弹\n if (bounce) {\n animate.bounce(true);\n }\n\n return animate;\n }\n\n private _handleRunAnimate(\n animate: IAnimate,\n custom: IAnimationCustomConstructor | IAnimationChannelInterpolator,\n props: Record<string, any>,\n duration: number,\n easing: EasingType,\n customParameters: any,\n options: any,\n type: string,\n graphic: IGraphic\n ) {\n // 处理自定义动画\n if (custom) {\n const customParams = this.resolveValue(customParameters, graphic, {});\n const objOptions = isFunction(options)\n ? options.call(null, customParameters.data && customParameters.data[0], graphic, customParameters)\n : options;\n customParams.options = objOptions;\n if (isFunction(custom)) {\n if (/^class\\s/.test(Function.prototype.toString.call(custom))) {\n // 自定义动画构造器 - 创建自定义动画类\n this.createCustomAnimation(\n animate,\n custom as IAnimationCustomConstructor,\n props,\n duration as number,\n easing,\n customParams\n );\n } else {\n // 自定义插值器 - 创建自定义插值动画\n this.createCustomInterpolatorAnimation(\n animate,\n custom as IAnimationChannelInterpolator,\n props,\n duration as number,\n easing,\n customParams\n );\n }\n }\n } else if (type === 'to') {\n animate.to(props, duration as number, easing);\n } else if (type === 'from') {\n animate.from(props, duration as number, easing);\n }\n }\n\n /**\n * 执行 Timeline 类型的动画\n */\n private executeTimelineItem(params: IAnimationTimeline, graphic: IGraphic, index: number, count: number): IAnimate {\n const { timeSlices, startTime = 0, loop, bounce, oneByOneDelay, priority, controlOptions } = params as any;\n\n // 如果设置了indexKey,则使用indexKey作为index\n const datum = graphic.context?.data?.[0];\n const indexKey = graphic.context?.indexKey;\n if (datum && indexKey) {\n index = datum[indexKey] ?? index;\n }\n\n // 创建动画实例\n const animate = graphic.animate() as unknown as IAnimate;\n animate.priority = priority;\n\n // 设置开始时间\n animate.startAt(startTime as number);\n animate.wait(index * oneByOneDelay);\n\n // 设置循环\n if (loop && (loop as number) > 0) {\n animate.loop(loop as number);\n }\n\n // 设置反弹\n if (bounce) {\n animate.bounce(true);\n }\n\n // 处理时间切片\n const slices = Array.isArray(timeSlices) ? timeSlices : [timeSlices];\n\n slices.forEach(slice => {\n this.applyTimeSliceToAnimate(slice, animate, graphic);\n });\n\n // 后等待\n if (oneByOneDelay) {\n animate.wait(oneByOneDelay * (count - index - 1));\n }\n\n return animate;\n }\n\n /**\n * 将时间切片应用到动画实例\n */\n private applyTimeSliceToAnimate(slice: IAnimationTimeSlice, animate: IAnimate, graphic: IGraphic) {\n const { effects, duration = 300, delay = 0, delayAfter = 0 } = slice;\n\n // 解析时间参数\n // const durationValue = duration as number;\n const delayValue = delay as number;\n const delayAfterValue = delayAfter as number;\n\n // 添加延迟\n if (delayValue > 0) {\n animate.wait(delayValue);\n }\n\n // 处理动画效果\n const effectsArray = Array.isArray(effects) ? effects : [effects];\n\n effectsArray.forEach(effect => {\n const { type = 'to', channel, customParameters, easing = 'linear', options } = effect;\n\n const custom = effect.custom ?? AnimateExecutor.builtInAnimateMap[type];\n\n // 根据 channel 配置创建属性对象\n const props = this.createPropsFromChannel(channel, graphic);\n this._handleRunAnimate(\n animate,\n custom,\n props,\n duration as number,\n easing,\n customParameters,\n options,\n type,\n graphic\n );\n });\n\n // 添加后延迟\n if (delayAfterValue > 0) {\n animate.wait(delayAfterValue);\n }\n }\n\n /**\n * 创建自定义插值器动画\n */\n private createCustomInterpolatorAnimation(\n animate: IAnimate,\n interpolator: IAnimationChannelInterpolator,\n props: Record<string, any>,\n duration: number,\n easing: EasingType,\n customParams: any\n ) {\n // 获取动画目标的当前属性作为起始值\n const from: Record<string, any> = {};\n const to = props;\n\n // 为每个属性填充起始值\n Object.keys(to).forEach(key => {\n from[key] = animate.target.getComputedAttribute(key);\n });\n\n animate.interpolateUpdateFunction = (from, to, ratio, step, target) => {\n interpolator(ratio, from, to, step, target, animate.target, customParams);\n };\n\n animate.to(props, duration, easing);\n }\n\n /**\n * 创建自定义动画类\n */\n private createCustomAnimation(\n animate: IAnimate,\n CustomAnimateConstructor: IAnimationCustomConstructor,\n props: Record<string, any>,\n duration: number,\n easing: EasingType,\n customParams: any\n ) {\n // 获取动画目标的当前属性作为起始值\n const from: Record<string, any> = {};\n const to = props;\n\n // 为每个属性填充起始值\n Object.keys(to).forEach(key => {\n from[key] = animate.target.getComputedAttribute(key);\n });\n\n // 实例化自定义动画类\n const customAnimate = new CustomAnimateConstructor(from, to, duration, easing, customParams);\n\n // 播放自定义动画\n animate.play(customAnimate);\n }\n\n /**\n * 从 channel 配置创建属性对象\n */\n private createPropsFromChannel(\n channel: IAnimationChannelAttrs | IAnimationChannelAttributes | undefined,\n graphic: IGraphic\n ): Record<string, any> {\n const props: Record<string, any> = {};\n\n if (!channel) {\n return props;\n }\n\n if (!Array.isArray(channel)) {\n // 如果是对象,解析 from/to 配置\n Object.entries(channel).forEach(([key, config]) => {\n if (config.to !== undefined) {\n if (typeof config.to === 'function') {\n props[key] = config.to((graphic.context as any)?.data, graphic, {});\n } else {\n props[key] = config.to;\n }\n }\n });\n }\n\n return props;\n }\n\n /**\n * 解析函数或值类型的配置项\n */\n private resolveValue<T>(value: MarkFunctionValueType<T> | undefined, graphic?: IGraphic, defaultValue?: T): T {\n if (value === undefined) {\n return defaultValue as T;\n }\n\n if (typeof value === 'function' && graphic) {\n return (value as MarkFunctionCallback<T>)((graphic.context as any)?.data, graphic, {});\n }\n\n return value as T;\n }\n\n /**\n * 执行动画(具体执行到内部的单个图元)\n */\n executeItem(params: IAnimationConfig, graphic: IGraphic, index: number = 0, count: number = 1): IAnimate | null {\n if (!graphic) {\n return null;\n }\n\n const isTimeline = 'timeSlices' in params;\n let animate: IAnimate | null = null;\n\n if (isTimeline) {\n // 处理 Timeline 类型的动画配置\n animate = this.executeTimelineItem(params as IAnimationTimeline, graphic, index, count);\n } else {\n // 处理 TypeConfig 类型的动画配置\n animate = this.executeTypeConfigItem(params as IAnimationTypeConfig, graphic, index, count);\n }\n\n // 跟踪动画以进行生命周期管理\n if (animate) {\n this._trackAnimation(animate);\n }\n\n return animate;\n }\n\n /**\n * 停止所有由该执行器管理的动画\n */\n stop(type?: 'start' | 'end' | Record<string, any>): void {\n // animate.stop会从数组里删除,所以需要while循环,不能forEach\n while (this._animates.length > 0) {\n const animate = this._animates.pop();\n animate?.stop(type);\n }\n\n // 清空动画实例数组\n this._animates = [];\n this._activeCount = 0;\n\n // 如果动画正在运行,触发结束回调\n if (this._started) {\n this._started = false;\n this.onEnd();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { IGraphic } from '@visactor/vrender-core';
|
|
2
|
+
import type { EasingType } from '../intreface/easing';
|
|
3
|
+
import type { ACustomAnimate } from '../custom/custom-animate';
|
|
4
|
+
export type MarkFunctionCallback<T> = (datum: any, graphic: IGraphic, parameters: any) => T;
|
|
5
|
+
export type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;
|
|
6
|
+
interface IAnimationParameters {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export type IAnimationChannelFunction = (datum: any, element: IGraphic, parameters: IAnimationParameters) => any;
|
|
10
|
+
export type IAnimationChannelAttrs = Record<string, {
|
|
11
|
+
from?: any | IAnimationChannelFunction;
|
|
12
|
+
to?: any | IAnimationChannelFunction;
|
|
13
|
+
}>;
|
|
14
|
+
export type IAnimationChannelAttributes = string[];
|
|
15
|
+
export type IAnimationChannelInterpolator = (ratio: number, from: any, to: any, nextAttributes: any, datum: any, element: IGraphic, parameters: IAnimationParameters) => boolean | void;
|
|
16
|
+
export interface IAnimationCustomConstructor {
|
|
17
|
+
new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;
|
|
18
|
+
}
|
|
19
|
+
export interface IAnimationEffect {
|
|
20
|
+
type?: string;
|
|
21
|
+
channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
|
|
22
|
+
custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
|
|
23
|
+
customParameters?: MarkFunctionValueType<any>;
|
|
24
|
+
easing?: EasingType;
|
|
25
|
+
options?: MarkFunctionValueType<any>;
|
|
26
|
+
}
|
|
27
|
+
export interface IAnimationTimeSlice {
|
|
28
|
+
effects: IAnimationEffect | IAnimationEffect[];
|
|
29
|
+
duration?: MarkFunctionValueType<number>;
|
|
30
|
+
delay?: MarkFunctionValueType<number>;
|
|
31
|
+
delayAfter?: MarkFunctionValueType<number>;
|
|
32
|
+
}
|
|
33
|
+
export interface IAnimationControlOptions {
|
|
34
|
+
stopWhenStateChange?: boolean;
|
|
35
|
+
immediatelyApply?: boolean;
|
|
36
|
+
ignoreLoopFinalAttributes?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface IAnimationTypeConfig {
|
|
39
|
+
type?: string;
|
|
40
|
+
channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
|
|
41
|
+
to?: Record<string, any>;
|
|
42
|
+
custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
|
|
43
|
+
customParameters?: MarkFunctionValueType<any>;
|
|
44
|
+
easing?: EasingType;
|
|
45
|
+
delay?: MarkFunctionValueType<number>;
|
|
46
|
+
delayAfter?: MarkFunctionValueType<number>;
|
|
47
|
+
duration?: MarkFunctionValueType<number>;
|
|
48
|
+
oneByOne?: MarkFunctionValueType<boolean | number>;
|
|
49
|
+
startTime?: MarkFunctionValueType<number>;
|
|
50
|
+
totalTime?: MarkFunctionValueType<number>;
|
|
51
|
+
loop?: boolean | number;
|
|
52
|
+
options?: MarkFunctionValueType<any>;
|
|
53
|
+
controlOptions?: IAnimationControlOptions;
|
|
54
|
+
priority?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface IAnimationTimeline {
|
|
57
|
+
id?: string;
|
|
58
|
+
timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];
|
|
59
|
+
startTime?: MarkFunctionValueType<number>;
|
|
60
|
+
totalTime?: MarkFunctionValueType<number>;
|
|
61
|
+
oneByOne?: MarkFunctionValueType<number | boolean>;
|
|
62
|
+
loop?: MarkFunctionValueType<number | boolean>;
|
|
63
|
+
partitioner?: MarkFunctionCallback<boolean>;
|
|
64
|
+
sort?: (datumA: any, datumB: any, elementA: IGraphic, elementB: IGraphic, parameters: any) => number;
|
|
65
|
+
controlOptions?: IAnimationControlOptions;
|
|
66
|
+
priority?: number;
|
|
67
|
+
}
|
|
68
|
+
export type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/executor/executor.ts"],"names":[],"mappings":"","file":"executor.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { EasingType } from '../intreface/easing';\nimport type { ACustomAnimate } from '../custom/custom-animate';\n\nexport type MarkFunctionCallback<T> = (datum: any, graphic: IGraphic, parameters: any) => T;\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\ninterface IAnimationParameters {\n [key: string]: any;\n}\n\n/**\n * 动画 channel 配置\n */\nexport type IAnimationChannelFunction = (datum: any, element: IGraphic, parameters: IAnimationParameters) => any;\n\n/**\n * 动画 channel 属性配置\n */\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\n\n/**\n * 动画 channel 插值器\n */\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IGraphic,\n parameters: IAnimationParameters\n) => boolean | void;\n\n/**\n * 动画 custom 构造器\n */\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n /** 动画类型 */\n type?: string;\n /** 动画 channel 配置 */\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n /** 动画 自定义插值 配置 */\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n /** 动画 custom 参数配置 */\n customParameters?: MarkFunctionValueType<any>;\n /** 动画 easing 配置 */\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationTimeSlice {\n /** 动画效果 */\n effects: IAnimationEffect | IAnimationEffect[];\n /** 动画时长 */\n duration?: MarkFunctionValueType<number>;\n /** 延迟delay后执行动画 */\n delay?: MarkFunctionValueType<number>;\n /** effect动画后再延迟delayAfter结束这个周期 */\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n /** encode 计算图元最终状态时是否忽略循环动画 */\n ignoreLoopFinalAttributes?: boolean;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n /** 动画类型 */\n type?: string;\n /** 动画 channel 配置 */\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n /** 动画 to 配置(和channel互斥,如果同时设置,以to为准) */\n to?: Record<string, any>;\n /** 动画 自定义插值 配置 */\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n /** 动画 custom 参数配置 */\n customParameters?: MarkFunctionValueType<any>;\n /** 动画 easing 配置 */\n easing?: EasingType;\n /** 动画 delay 配置 */\n delay?: MarkFunctionValueType<number>;\n /** 动画 delayAfter 配置 */\n delayAfter?: MarkFunctionValueType<number>;\n /** 动画 duration 配置 */\n duration?: MarkFunctionValueType<number>;\n /** 动画 oneByOne 配置(是否依次执行) */\n oneByOne?: MarkFunctionValueType<boolean | number>;\n /** 动画 startTime 配置 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画 totalTime 配置(如果有循环,只算一个周期) */\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n /** 动画优先级 */\n priority?: number;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IGraphic, elementB: IGraphic, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n /** 动画优先级 */\n priority?: number;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n"]}
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export * from './intreface/animate';
|
|
2
|
+
export * from './intreface/timeline';
|
|
3
|
+
export * from './intreface/easing';
|
|
4
|
+
export * from './intreface/type';
|
|
5
|
+
export { Animate } from './animate';
|
|
6
|
+
export { DefaultTimeline } from './timeline';
|
|
7
|
+
export { ManualTicker } from './ticker/manual-ticker';
|
|
8
|
+
export { DefaultTicker } from './ticker/default-ticker';
|
|
9
|
+
export { Step } from './step';
|
|
10
|
+
export * from './utils/easing-func';
|
|
11
|
+
export { registerAnimate } from './register';
|
|
12
|
+
export { ACustomAnimate } from './custom/custom-animate';
|
|
13
|
+
export { IncreaseCount } from './custom/number';
|
|
14
|
+
export { InputText } from './custom/input-text';
|
|
15
|
+
export { ClipGraphicAnimate, ClipAngleAnimate, ClipRadiusAnimate, ClipDirectionAnimate } from './custom/clip-graphic';
|
|
16
|
+
export { TagPointsUpdate } from './custom/tag-points';
|
|
17
|
+
export { GroupFadeIn, GroupFadeOut } from './custom/group-fade';
|
|
18
|
+
export { RotateBySphereAnimate } from './custom/sphere';
|
|
19
|
+
export { AnimateExecutor } from './executor/animate-executor';
|
|
20
|
+
export { registerCustomAnimate } from './custom/register';
|
|
21
|
+
export * from './state';
|
|
22
|
+
export { AnimationTransitionRegistry } from './state/animation-states-registry';
|
|
23
|
+
export { transitionRegistry } from './state/animation-states-registry';
|
|
24
|
+
export { AnimationStateManager } from './state/animation-state';
|
|
25
|
+
export { AnimationStateStore } from './state/animation-state';
|
package/es/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export * from "./intreface/animate";
|
|
2
|
+
|
|
3
|
+
export * from "./intreface/timeline";
|
|
4
|
+
|
|
5
|
+
export * from "./intreface/easing";
|
|
6
|
+
|
|
7
|
+
export * from "./intreface/type";
|
|
8
|
+
|
|
9
|
+
export { Animate } from "./animate";
|
|
10
|
+
|
|
11
|
+
export { DefaultTimeline } from "./timeline";
|
|
12
|
+
|
|
13
|
+
export { ManualTicker } from "./ticker/manual-ticker";
|
|
14
|
+
|
|
15
|
+
export { DefaultTicker } from "./ticker/default-ticker";
|
|
16
|
+
|
|
17
|
+
export { Step } from "./step";
|
|
18
|
+
|
|
19
|
+
export * from "./utils/easing-func";
|
|
20
|
+
|
|
21
|
+
export { registerAnimate } from "./register";
|
|
22
|
+
|
|
23
|
+
export { ACustomAnimate } from "./custom/custom-animate";
|
|
24
|
+
|
|
25
|
+
export { IncreaseCount } from "./custom/number";
|
|
26
|
+
|
|
27
|
+
export { InputText } from "./custom/input-text";
|
|
28
|
+
|
|
29
|
+
export { ClipGraphicAnimate, ClipAngleAnimate, ClipRadiusAnimate, ClipDirectionAnimate } from "./custom/clip-graphic";
|
|
30
|
+
|
|
31
|
+
export { TagPointsUpdate } from "./custom/tag-points";
|
|
32
|
+
|
|
33
|
+
export { GroupFadeIn, GroupFadeOut } from "./custom/group-fade";
|
|
34
|
+
|
|
35
|
+
export { RotateBySphereAnimate } from "./custom/sphere";
|
|
36
|
+
|
|
37
|
+
export { AnimateExecutor } from "./executor/animate-executor";
|
|
38
|
+
|
|
39
|
+
export { registerCustomAnimate } from "./custom/register";
|
|
40
|
+
|
|
41
|
+
export * from "./state";
|
|
42
|
+
|
|
43
|
+
export { AnimationTransitionRegistry } from "./state/animation-states-registry";
|
|
44
|
+
|
|
45
|
+
export { transitionRegistry } from "./state/animation-states-registry";
|
|
46
|
+
|
|
47
|
+
export { AnimationStateManager } from "./state/animation-state";
|
|
48
|
+
|
|
49
|
+
export { AnimationStateStore } from "./state/animation-state";
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
package/es/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACtH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC","file":"index.js","sourcesContent":["// 导出接口\nexport * from './intreface/animate';\nexport * from './intreface/timeline';\nexport * from './intreface/easing';\nexport * from './intreface/type';\n\n// 导出实现\nexport { Animate } from './animate';\nexport { DefaultTimeline } from './timeline';\nexport { ManualTicker } from './ticker/manual-ticker';\nexport { DefaultTicker } from './ticker/default-ticker';\nexport { Step } from './step';\n\n// 导出工具函数\nexport * from './utils/easing-func';\nexport { registerAnimate } from './register';\nexport { ACustomAnimate } from './custom/custom-animate';\nexport { IncreaseCount } from './custom/number';\nexport { InputText } from './custom/input-text';\nexport { ClipGraphicAnimate, ClipAngleAnimate, ClipRadiusAnimate, ClipDirectionAnimate } from './custom/clip-graphic';\nexport { TagPointsUpdate } from './custom/tag-points';\nexport { GroupFadeIn, GroupFadeOut } from './custom/group-fade';\nexport { RotateBySphereAnimate } from './custom/sphere';\nexport { AnimateExecutor } from './executor/animate-executor';\nexport { registerCustomAnimate } from './custom/register';\n// Export animation state modules\nexport * from './state';\nexport { AnimationTransitionRegistry } from './state/animation-states-registry';\nexport { transitionRegistry } from './state/animation-states-registry';\nexport { AnimationStateManager } from './state/animation-state';\nexport { AnimationStateStore } from './state/animation-state';\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { IGraphic } from '@visactor/vrender-core';
|
|
2
|
+
import type { EasingType } from '../intreface/easing';
|
|
3
|
+
import type { ACustomAnimate } from '../custom/custom-animate';
|
|
4
|
+
export type MarkFunctionCallback<T> = (datum: any, graphic: IGraphic, parameters: any) => T;
|
|
5
|
+
export type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;
|
|
6
|
+
interface IAnimationParameters {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export type IAnimationChannelFunction = (datum: any, element: IGraphic, parameters: IAnimationParameters) => any;
|
|
10
|
+
export type IAnimationChannelAttrs = Record<string, {
|
|
11
|
+
from?: any | IAnimationChannelFunction;
|
|
12
|
+
to?: any | IAnimationChannelFunction;
|
|
13
|
+
}>;
|
|
14
|
+
export type IAnimationChannelAttributes = string[];
|
|
15
|
+
export type IAnimationChannelInterpolator = (ratio: number, from: any, to: any, nextAttributes: any, datum: any, element: IGraphic, parameters: IAnimationParameters) => boolean | void;
|
|
16
|
+
export interface IAnimationCustomConstructor {
|
|
17
|
+
new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;
|
|
18
|
+
}
|
|
19
|
+
export interface IAnimationEffect {
|
|
20
|
+
type?: string;
|
|
21
|
+
channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
|
|
22
|
+
custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
|
|
23
|
+
customParameters?: MarkFunctionValueType<any>;
|
|
24
|
+
easing?: EasingType;
|
|
25
|
+
options?: MarkFunctionValueType<any>;
|
|
26
|
+
}
|
|
27
|
+
export interface IAnimationTimeSlice {
|
|
28
|
+
effects: IAnimationEffect | IAnimationEffect[];
|
|
29
|
+
duration?: MarkFunctionValueType<number>;
|
|
30
|
+
delay?: MarkFunctionValueType<number>;
|
|
31
|
+
delayAfter?: MarkFunctionValueType<number>;
|
|
32
|
+
}
|
|
33
|
+
export interface IAnimationControlOptions {
|
|
34
|
+
stopWhenStateChange?: boolean;
|
|
35
|
+
immediatelyApply?: boolean;
|
|
36
|
+
ignoreLoopFinalAttributes?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface IAnimationTypeConfig {
|
|
39
|
+
type?: string;
|
|
40
|
+
channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
|
|
41
|
+
custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
|
|
42
|
+
customParameters?: MarkFunctionValueType<any>;
|
|
43
|
+
easing?: EasingType;
|
|
44
|
+
delay?: MarkFunctionValueType<number>;
|
|
45
|
+
delayAfter?: MarkFunctionValueType<number>;
|
|
46
|
+
duration?: MarkFunctionValueType<number>;
|
|
47
|
+
oneByOne?: MarkFunctionValueType<boolean | number>;
|
|
48
|
+
startTime?: MarkFunctionValueType<number>;
|
|
49
|
+
totalTime?: MarkFunctionValueType<number>;
|
|
50
|
+
loop?: boolean | number;
|
|
51
|
+
options?: MarkFunctionValueType<any>;
|
|
52
|
+
controlOptions?: IAnimationControlOptions;
|
|
53
|
+
}
|
|
54
|
+
export interface IAnimationTimeline {
|
|
55
|
+
id?: string;
|
|
56
|
+
timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];
|
|
57
|
+
startTime?: MarkFunctionValueType<number>;
|
|
58
|
+
totalTime?: MarkFunctionValueType<number>;
|
|
59
|
+
oneByOne?: MarkFunctionValueType<number | boolean>;
|
|
60
|
+
loop?: MarkFunctionValueType<number | boolean>;
|
|
61
|
+
partitioner?: MarkFunctionCallback<boolean>;
|
|
62
|
+
sort?: (datumA: any, datumB: any, elementA: IGraphic, elementB: IGraphic, parameters: any) => number;
|
|
63
|
+
controlOptions?: IAnimationControlOptions;
|
|
64
|
+
}
|
|
65
|
+
export type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interpolate/executor.ts"],"names":[],"mappings":"","file":"executor.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { EasingType } from '../intreface/easing';\nimport type { ACustomAnimate } from '../custom/custom-animate';\n\nexport type MarkFunctionCallback<T> = (datum: any, graphic: IGraphic, parameters: any) => T;\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\ninterface IAnimationParameters {\n [key: string]: any;\n}\n\n/**\n * 动画 channel 配置\n */\nexport type IAnimationChannelFunction = (datum: any, element: IGraphic, parameters: IAnimationParameters) => any;\n\n/**\n * 动画 channel 属性配置\n */\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\n\n/**\n * 动画 channel 插值器\n */\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IGraphic,\n parameters: IAnimationParameters\n) => boolean | void;\n\n/**\n * 动画 custom 构造器\n */\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n /** 动画类型 */\n type?: string;\n /** 动画 channel 配置 */\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n /** 动画 自定义插值 配置 */\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n /** 动画 custom 参数配置 */\n customParameters?: MarkFunctionValueType<any>;\n /** 动画 easing 配置 */\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationTimeSlice {\n /** 动画效果 */\n effects: IAnimationEffect | IAnimationEffect[];\n /** 动画时长 */\n duration?: MarkFunctionValueType<number>;\n /** 延迟delay后执行动画 */\n delay?: MarkFunctionValueType<number>;\n /** effect动画后再延迟delayAfter结束这个周期 */\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n /** encode 计算图元最终状态时是否忽略循环动画 */\n ignoreLoopFinalAttributes?: boolean;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n /** 动画类型 */\n type?: string;\n /** 动画 channel 配置 */\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n /** 动画 自定义插值 配置 */\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n /** 动画 custom 参数配置 */\n customParameters?: MarkFunctionValueType<any>;\n /** 动画 easing 配置 */\n easing?: EasingType;\n /** 动画 delay 配置 */\n delay?: MarkFunctionValueType<number>;\n /** 动画 delayAfter 配置 */\n delayAfter?: MarkFunctionValueType<number>;\n /** 动画 duration 配置 */\n duration?: MarkFunctionValueType<number>;\n /** 动画 oneByOne 配置(是否依次执行) */\n oneByOne?: MarkFunctionValueType<boolean | number>;\n /** 动画 startTime 配置 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画 totalTime 配置 */\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IGraphic, elementB: IGraphic, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function interpolateNumber(from: number, to: number, ratio: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interpolate/number.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,EAAU,EAAE,KAAa;IACvE,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;AACpC,CAAC","file":"number.js","sourcesContent":["export function interpolateNumber(from: number, to: number, ratio: number): number {\n return from + (to - from) * ratio;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IGraphic } from '@visactor/vrender-core';
|
|
2
|
+
import type { IStep } from '../intreface/animate';
|
|
3
|
+
export declare class InterpolateUpdateStore {
|
|
4
|
+
opacity: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
5
|
+
fillOpacity: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
6
|
+
strokeOpacity: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
7
|
+
zIndex: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
8
|
+
backgroundOpacity: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
9
|
+
shadowOffsetX: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
10
|
+
shadowOffsetY: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
11
|
+
shadowBlur: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
12
|
+
fill: (key: string, from: [number, number, number, number], to: [number, number, number, number], ratio: number, step: IStep, target: IGraphic) => void;
|
|
13
|
+
fillPure: (key: string, from: [number, number, number, number], to: [number, number, number, number], ratio: number, step: IStep, target: IGraphic) => void;
|
|
14
|
+
stroke: (key: string, from: [number, number, number, number], to: [number, number, number, number], ratio: number, step: IStep, target: IGraphic) => void;
|
|
15
|
+
strokePure: (key: string, from: [number, number, number, number], to: [number, number, number, number], ratio: number, step: IStep, target: IGraphic) => void;
|
|
16
|
+
width: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
17
|
+
height: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
18
|
+
x: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
19
|
+
y: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
20
|
+
angle: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
21
|
+
scaleX: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
22
|
+
scaleY: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
23
|
+
lineWidth: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
24
|
+
startAngle: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
25
|
+
endAngle: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
26
|
+
radius: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
27
|
+
outerRadius: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
28
|
+
innerRadius: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
29
|
+
size: (key: string, from: number, to: number, ratio: number, step: IStep, target: IGraphic) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare const interpolateUpdateStore: InterpolateUpdateStore;
|
|
32
|
+
export declare function commonInterpolateUpdate(key: string, from: any, to: any, ratio: number, step: IStep, target: IGraphic): boolean;
|