@visactor/vrender-animate 1.0.37 → 1.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/animate.js +1 -2
- package/cjs/animate.js.map +1 -1
- package/cjs/custom/clip-graphic.js +3 -3
- package/cjs/custom/clip-graphic.js.map +1 -1
- package/cjs/custom/custom-animate.d.ts +2 -1
- package/cjs/custom/custom-animate.js +3 -3
- package/cjs/custom/custom-animate.js.map +1 -1
- package/cjs/custom/disappear/base/DisappearAnimateBase.js.map +1 -1
- package/cjs/custom/disappear/base/ImageProcessUtils.js.map +1 -1
- package/cjs/custom/disappear/gaussian-blur.js.map +1 -1
- package/cjs/custom/disappear/pixelation.js.map +1 -1
- package/cjs/custom/morphing.js +9 -9
- package/cjs/custom/morphing.js.map +1 -1
- package/cjs/custom/streamLight.js +2 -2
- package/cjs/custom/streamLight.js.map +1 -1
- package/cjs/register.js +2 -1
- package/cjs/register.js.map +1 -1
- package/cjs/ticker/default-ticker.js +2 -2
- package/cjs/ticker/default-ticker.js.map +1 -1
- package/cjs/timeline.js.map +1 -1
- package/dist/index.es.js +27 -29
- package/es/animate.js +1 -2
- package/es/animate.js.map +1 -1
- package/es/custom/clip-graphic.js +4 -4
- package/es/custom/clip-graphic.js.map +1 -1
- package/es/custom/custom-animate.d.ts +2 -1
- package/es/custom/custom-animate.js +4 -2
- package/es/custom/custom-animate.js.map +1 -1
- package/es/custom/disappear/base/DisappearAnimateBase.js.map +1 -1
- package/es/custom/disappear/base/ImageProcessUtils.js.map +1 -1
- package/es/custom/disappear/gaussian-blur.js.map +1 -1
- package/es/custom/disappear/pixelation.js.map +1 -1
- package/es/custom/morphing.js +10 -10
- package/es/custom/morphing.js.map +1 -1
- package/es/custom/streamLight.js +3 -3
- package/es/custom/streamLight.js.map +1 -1
- package/es/register.js +2 -2
- package/es/register.js.map +1 -1
- package/es/ticker/default-ticker.js +3 -3
- package/es/ticker/default-ticker.js.map +1 -1
- package/es/timeline.js.map +1 -1
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { interpolateColor, interpolatePureColorArrayToStr, pointsInterpolation, Generator, ColorStore, ColorType, AnimateStatus, AnimateStepType, PerformanceRAF, STATUS,
|
|
1
|
+
import { interpolateColor, interpolatePureColorArrayToStr, pointsInterpolation, Generator, ColorStore, ColorType, AnimateStatus, AnimateStepType, PerformanceRAF, STATUS, vglobal, CustomPath2D, CurveContext, Graphic, Stage, graphicService, splitRect, splitArc, splitCircle, splitLine, splitPolygon, splitArea, splitPath, AttributeUpdateType, pathToBezierCurves, applyTransformOnBezierCurves, alignBezierCurves, findBestMorphingRotation, pointInterpolation, RichText, divideCubic } from '@visactor/vrender-core';
|
|
2
2
|
import { pi2, isString, EventEmitter, isFunction, isArray, isValidNumber, mixin, isNil, clamp, Point, pi, isNumber, isValid, isNumberClose, PointService } from '@visactor/vutils';
|
|
3
3
|
|
|
4
4
|
class Easing {
|
|
@@ -846,15 +846,8 @@ class Animate {
|
|
|
846
846
|
}
|
|
847
847
|
from(props, duration = 300, easing = 'linear') {
|
|
848
848
|
const step = new Step(AnimateStepType.from, props, duration, easing);
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
this._lastStep = step;
|
|
852
|
-
}
|
|
853
|
-
else {
|
|
854
|
-
this._lastStep.append(step);
|
|
855
|
-
this._lastStep = step;
|
|
856
|
-
}
|
|
857
|
-
this.updateDuration();
|
|
849
|
+
step.bind(this.target, this);
|
|
850
|
+
this.updateStepAfterAppend(step);
|
|
858
851
|
return this;
|
|
859
852
|
}
|
|
860
853
|
play(customAnimate) {
|
|
@@ -1208,10 +1201,10 @@ class DefaultTicker extends EventEmitter {
|
|
|
1208
1201
|
init() {
|
|
1209
1202
|
this.interval = 16;
|
|
1210
1203
|
this.status = STATUS.INITIAL;
|
|
1211
|
-
|
|
1204
|
+
vglobal.hooks.onSetEnv.tap('graph-ticker', () => {
|
|
1212
1205
|
this.initHandler(false);
|
|
1213
1206
|
});
|
|
1214
|
-
if (
|
|
1207
|
+
if (vglobal.env) {
|
|
1215
1208
|
this.initHandler(false);
|
|
1216
1209
|
}
|
|
1217
1210
|
}
|
|
@@ -2329,6 +2322,7 @@ class AnimateExtension {
|
|
|
2329
2322
|
function registerAnimate() {
|
|
2330
2323
|
mixin(Graphic, GraphicStateExtension);
|
|
2331
2324
|
mixin(Graphic, AnimateExtension);
|
|
2325
|
+
mixin(Stage, AnimateExtension);
|
|
2332
2326
|
}
|
|
2333
2327
|
|
|
2334
2328
|
class ACustomAnimate extends Step {
|
|
@@ -2370,6 +2364,7 @@ class AStageAnimate extends ACustomAnimate {
|
|
|
2370
2364
|
super(customFrom, customTo, duration, easing, params);
|
|
2371
2365
|
this.willCallBeforeStageRender = true;
|
|
2372
2366
|
this.willCallAfterStageRender = true;
|
|
2367
|
+
this.checkStatusAfterRender = true;
|
|
2373
2368
|
this._beforeStageRender = () => {
|
|
2374
2369
|
if (!this.willCallBeforeStageRender) {
|
|
2375
2370
|
return;
|
|
@@ -2393,6 +2388,9 @@ class AStageAnimate extends ACustomAnimate {
|
|
|
2393
2388
|
if (outputCanvas) {
|
|
2394
2389
|
this.renderToStage(stage, outputCanvas);
|
|
2395
2390
|
}
|
|
2391
|
+
if (this.checkStatusAfterRender && this.animate.status === AnimateStatus.END) {
|
|
2392
|
+
this.animate.timeline.removeAnimate(this.animate);
|
|
2393
|
+
}
|
|
2396
2394
|
};
|
|
2397
2395
|
this.props = {};
|
|
2398
2396
|
}
|
|
@@ -2910,7 +2908,7 @@ const oneToMultiMorph = (fromGraphic, toGraphics, animationConfig) => {
|
|
|
2910
2908
|
console.error(fromGraphic, ' is not validate');
|
|
2911
2909
|
}
|
|
2912
2910
|
}
|
|
2913
|
-
const childGraphics = ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.splitPath) === 'clone' ? cloneGraphic : (
|
|
2911
|
+
const childGraphics = ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.splitPath) === 'clone' ? cloneGraphic : (_a = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.splitPath) !== null && _a !== void 0 ? _a : splitGraphic)(fromGraphic, validateToGraphics.length, false);
|
|
2914
2912
|
const oldOnEnd = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.onEnd;
|
|
2915
2913
|
let count = validateToGraphics.length;
|
|
2916
2914
|
const onEachEnd = () => {
|
|
@@ -3001,7 +2999,7 @@ const appendShadowChildrenToGraphic = (graphic, children, count) => {
|
|
|
3001
2999
|
rect: childAttrs
|
|
3002
3000
|
});
|
|
3003
3001
|
new Array(count).fill(0).forEach(el => {
|
|
3004
|
-
const child =
|
|
3002
|
+
const child = graphicService.creator.rect({
|
|
3005
3003
|
x: 0,
|
|
3006
3004
|
y: 0,
|
|
3007
3005
|
width,
|
|
@@ -3021,7 +3019,7 @@ const cloneGraphic = (graphic, count, needAppend) => {
|
|
|
3021
3019
|
const element = {
|
|
3022
3020
|
path: new CustomPath2D().fromCustomPath2D(path)
|
|
3023
3021
|
};
|
|
3024
|
-
children.push(
|
|
3022
|
+
children.push(graphicService.creator.path(needAppend ? element : Object.assign({}, childAttrs, element)));
|
|
3025
3023
|
}
|
|
3026
3024
|
if (needAppend) {
|
|
3027
3025
|
appendShadowChildrenToGraphic(graphic, children, count);
|
|
@@ -3034,48 +3032,48 @@ const splitGraphic = (graphic, count, needAppend) => {
|
|
|
3034
3032
|
if (graphic.type === 'rect') {
|
|
3035
3033
|
const childrenAttrs = splitRect(graphic, count);
|
|
3036
3034
|
childrenAttrs.forEach(element => {
|
|
3037
|
-
children.push(
|
|
3035
|
+
children.push(graphicService.creator.rect(needAppend ? element : Object.assign({}, childAttrs, element)));
|
|
3038
3036
|
});
|
|
3039
3037
|
}
|
|
3040
3038
|
else if (graphic.type === 'arc') {
|
|
3041
3039
|
const childrenAttrs = splitArc(graphic, count);
|
|
3042
3040
|
childrenAttrs.forEach(element => {
|
|
3043
|
-
children.push(
|
|
3041
|
+
children.push(graphicService.creator.arc(needAppend ? element : Object.assign({}, childAttrs, element)));
|
|
3044
3042
|
});
|
|
3045
3043
|
}
|
|
3046
3044
|
else if (graphic.type === 'circle') {
|
|
3047
3045
|
const childrenAttrs = splitCircle(graphic, count);
|
|
3048
3046
|
childrenAttrs.forEach(element => {
|
|
3049
|
-
children.push(
|
|
3047
|
+
children.push(graphicService.creator.arc(needAppend ? element : Object.assign({}, childAttrs, element)));
|
|
3050
3048
|
});
|
|
3051
3049
|
}
|
|
3052
3050
|
else if (graphic.type === 'line') {
|
|
3053
3051
|
const childrenAttrs = splitLine(graphic, count);
|
|
3054
3052
|
const defaultSymbol = { size: 10, symbolType: 'circle' };
|
|
3055
3053
|
childrenAttrs.forEach(element => {
|
|
3056
|
-
children.push(
|
|
3054
|
+
children.push(graphicService.creator.symbol(needAppend ? Object.assign({}, element, defaultSymbol) : Object.assign({}, childAttrs, element, defaultSymbol)));
|
|
3057
3055
|
});
|
|
3058
3056
|
}
|
|
3059
3057
|
else if (graphic.type === 'polygon') {
|
|
3060
3058
|
const childrenAttrs = splitPolygon(graphic, count);
|
|
3061
3059
|
childrenAttrs.forEach(element => {
|
|
3062
|
-
children.push(
|
|
3060
|
+
children.push(graphicService.creator.polygon(needAppend ? element : Object.assign({}, childAttrs, element)));
|
|
3063
3061
|
});
|
|
3064
3062
|
}
|
|
3065
3063
|
else if (graphic.type === 'area') {
|
|
3066
3064
|
const childrenAttrs = splitArea(graphic, count);
|
|
3067
3065
|
childrenAttrs.forEach(element => {
|
|
3068
|
-
children.push(
|
|
3066
|
+
children.push(graphicService.creator.polygon(needAppend ? element : Object.assign({}, childAttrs, element)));
|
|
3069
3067
|
});
|
|
3070
3068
|
}
|
|
3071
3069
|
else if (graphic.type === 'path') {
|
|
3072
3070
|
const childrenAttrs = splitPath(graphic, count);
|
|
3073
3071
|
childrenAttrs.forEach(element => {
|
|
3074
3072
|
if ('path' in element) {
|
|
3075
|
-
children.push(
|
|
3073
|
+
children.push(graphicService.creator.path(needAppend ? element : Object.assign({}, childAttrs, element)));
|
|
3076
3074
|
}
|
|
3077
3075
|
else {
|
|
3078
|
-
children.push(
|
|
3076
|
+
children.push(graphicService.creator.polygon(needAppend ? element : Object.assign({}, childAttrs, element)));
|
|
3079
3077
|
}
|
|
3080
3078
|
});
|
|
3081
3079
|
}
|
|
@@ -3097,7 +3095,7 @@ const multiToOneMorph = (fromGraphics, toGraphic, animationConfig) => {
|
|
|
3097
3095
|
console.error(toGraphic, ' is not validate');
|
|
3098
3096
|
}
|
|
3099
3097
|
}
|
|
3100
|
-
const childGraphics = ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.splitPath) === 'clone' ? cloneGraphic : (
|
|
3098
|
+
const childGraphics = ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.splitPath) === 'clone' ? cloneGraphic : (_a = animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.splitPath) !== null && _a !== void 0 ? _a : splitGraphic)(toGraphic, validateFromGraphics.length, true);
|
|
3101
3099
|
const toAttrs = toGraphic.attribute;
|
|
3102
3100
|
toGraphic.setAttribute('visible', false);
|
|
3103
3101
|
const morphingData = validateFromGraphics.map((graphic, index) => {
|
|
@@ -3310,7 +3308,7 @@ class ClipAngleAnimate extends ClipGraphicAnimate {
|
|
|
3310
3308
|
arcStartAngle = startAngle;
|
|
3311
3309
|
arcEndAngle = animationType === 'out' ? startAngle + Math.PI * 2 : startAngle;
|
|
3312
3310
|
}
|
|
3313
|
-
const arc =
|
|
3311
|
+
const arc = graphicService.creator.arc({
|
|
3314
3312
|
x: (_j = (_h = params === null || params === void 0 ? void 0 : params.center) === null || _h === void 0 ? void 0 : _h.x) !== null && _j !== void 0 ? _j : width / 2,
|
|
3315
3313
|
y: (_l = (_k = params === null || params === void 0 ? void 0 : params.center) === null || _k === void 0 ? void 0 : _k.y) !== null && _l !== void 0 ? _l : height / 2,
|
|
3316
3314
|
outerRadius: (_m = params === null || params === void 0 ? void 0 : params.radius) !== null && _m !== void 0 ? _m : (width + height) / 2,
|
|
@@ -3341,7 +3339,7 @@ class ClipRadiusAnimate extends ClipGraphicAnimate {
|
|
|
3341
3339
|
const animationType = (_e = params === null || params === void 0 ? void 0 : params.animationType) !== null && _e !== void 0 ? _e : 'in';
|
|
3342
3340
|
const startRadius = (_f = params === null || params === void 0 ? void 0 : params.startRadius) !== null && _f !== void 0 ? _f : 0;
|
|
3343
3341
|
const endRadius = (_g = params === null || params === void 0 ? void 0 : params.endRadius) !== null && _g !== void 0 ? _g : Math.sqrt((width / 2) ** 2 + (height / 2) ** 2);
|
|
3344
|
-
const arc =
|
|
3342
|
+
const arc = graphicService.creator.arc({
|
|
3345
3343
|
x: (_j = (_h = params === null || params === void 0 ? void 0 : params.center) === null || _h === void 0 ? void 0 : _h.x) !== null && _j !== void 0 ? _j : width / 2,
|
|
3346
3344
|
y: (_l = (_k = params === null || params === void 0 ? void 0 : params.center) === null || _k === void 0 ? void 0 : _k.y) !== null && _l !== void 0 ? _l : height / 2,
|
|
3347
3345
|
outerRadius: animationType === 'out' ? endRadius : startRadius,
|
|
@@ -3364,7 +3362,7 @@ class ClipDirectionAnimate extends ClipGraphicAnimate {
|
|
|
3364
3362
|
const animationType = (_g = params === null || params === void 0 ? void 0 : params.animationType) !== null && _g !== void 0 ? _g : 'in';
|
|
3365
3363
|
const direction = (_h = params === null || params === void 0 ? void 0 : params.direction) !== null && _h !== void 0 ? _h : 'x';
|
|
3366
3364
|
const orient = (_j = params === null || params === void 0 ? void 0 : params.orient) !== null && _j !== void 0 ? _j : 'positive';
|
|
3367
|
-
const rect =
|
|
3365
|
+
const rect = graphicService.creator.rect({
|
|
3368
3366
|
x: 0,
|
|
3369
3367
|
y: 0,
|
|
3370
3368
|
width: animationType === 'in' && direction === 'x' ? 0 : width,
|
|
@@ -6963,7 +6961,7 @@ class StreamLight extends ACustomAnimate {
|
|
|
6963
6961
|
onStartLineOrArea(type) {
|
|
6964
6962
|
var _a;
|
|
6965
6963
|
const root = this.target.attachShadow();
|
|
6966
|
-
const line =
|
|
6964
|
+
const line = graphicService.creator[type](Object.assign({}, (_a = this.params) === null || _a === void 0 ? void 0 : _a.attribute));
|
|
6967
6965
|
this[type] = line;
|
|
6968
6966
|
line.pathProxy = new CustomPath2D();
|
|
6969
6967
|
root.add(line);
|
|
@@ -6976,7 +6974,7 @@ class StreamLight extends ACustomAnimate {
|
|
|
6976
6974
|
const otherSizeAttr = isHorizontal ? 'width' : 'height';
|
|
6977
6975
|
const size = this.target.AABBBounds[sizeAttr]();
|
|
6978
6976
|
const y = isHorizontal ? 0 : this.target.AABBBounds.y1;
|
|
6979
|
-
const rect =
|
|
6977
|
+
const rect = graphicService.creator.rect(Object.assign(Object.assign({ [sizeAttr]: size, fill: '#bcdeff', shadowBlur: 30, shadowColor: '#bcdeff' }, (_c = this.params) === null || _c === void 0 ? void 0 : _c.attribute), { x: 0, y, [otherSizeAttr]: 0 }));
|
|
6980
6978
|
this.rect = rect;
|
|
6981
6979
|
root.add(rect);
|
|
6982
6980
|
}
|
package/es/animate.js
CHANGED
|
@@ -67,8 +67,7 @@ export class Animate {
|
|
|
67
67
|
}
|
|
68
68
|
from(props, duration = 300, easing = "linear") {
|
|
69
69
|
const step = new Step(AnimateStepType.from, props, duration, easing);
|
|
70
|
-
return
|
|
71
|
-
this._lastStep = step), this.updateDuration(), this;
|
|
70
|
+
return step.bind(this.target, this), this.updateStepAfterAppend(step), this;
|
|
72
71
|
}
|
|
73
72
|
play(customAnimate) {
|
|
74
73
|
return customAnimate.bind(this.target, this), this.updateStepAfterAppend(customAnimate),
|
package/es/animate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/animate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EAOhB,MAAM,wBAAwB,CAAC;AAChC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CAAC;QAC9E,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAES,WAAW,CAAC,EAAyB;QAC7C,IAAI,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QAC3B,OAAO,IAAI,EAAE;YACX,EAAE,CAAC,IAAI,CAAC,CAAC;YACT,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;SAClB;IACH,CAAC;CACF","file":"animate.js","sourcesContent":["import { Step, WaitStep } from './step';\nimport {\n Generator,\n AnimateStatus,\n AnimateStepType,\n type IGraphic,\n type IAnimate,\n type IStep,\n type ICustomAnimate,\n type EasingType,\n type ITimeline\n} from '@visactor/vrender-core';\nimport { defaultTimeline } from './timeline';\n\nexport class Animate implements IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n target: IGraphic;\n\n // 回调函数列表\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n // 时间控制\n private _timeline: ITimeline;\n private _startTime: number;\n private _duration: number;\n private _totalDuration: number;\n\n // 动画控制\n // private _reversed: boolean;\n private _loopCount: number;\n private _currentLoop: number;\n private _bounce: boolean;\n\n // 链表头节点和尾节点\n private _firstStep: IStep | null;\n private _lastStep: IStep | null;\n\n // 初始属性和屏蔽的属性\n private _startProps: Record<string, any>;\n private _endProps: Record<string, any>;\n private _preventAttrs: Set<string>;\n // 优先级,用于判定是否能被后续的动画preventAttr\n declare priority: number;\n\n protected currentTime: number;\n slience?: boolean;\n\n // 临时变量\n lastRunStep?: IStep;\n\n interpolateUpdateFunction:\n | ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void)\n | null;\n\n constructor(\n id: string | number = Generator.GenAutoIncrementId(),\n timeline: ITimeline = defaultTimeline,\n slience?: boolean\n ) {\n this.id = id;\n this.status = AnimateStatus.INITIAL;\n this._timeline = timeline;\n timeline.addAnimate(this);\n this.slience = slience;\n this._startTime = 0;\n this._duration = 0;\n this._totalDuration = 0;\n // this._reversed = false;\n this._loopCount = 0;\n this._currentLoop = 0;\n this._bounce = false;\n this._firstStep = null;\n this._lastStep = null;\n this._startProps = {};\n this._endProps = {};\n this._preventAttrs = new Set();\n this.currentTime = 0;\n this.interpolateUpdateFunction = null;\n this.priority = 0;\n }\n\n /**\n * 获取开始属性\n */\n getStartProps(): Record<string, any> {\n return this._startProps;\n }\n\n /**\n * 获取结束属性\n */\n getEndProps(): Record<string, any> {\n return this._endProps;\n }\n\n /**\n * 设置时间线\n */\n setTimeline(timeline: ITimeline): void {\n this._timeline = timeline;\n }\n\n /**\n * 获取时间线\n */\n getTimeline(): ITimeline {\n return this._timeline;\n }\n\n /**\n * 时间线属性访问器\n */\n get timeline(): ITimeline {\n return this._timeline;\n }\n\n /**\n * 绑定目标图形\n */\n bind(target: IGraphic): this {\n this.target = target;\n\n if (!this.target.animates) {\n this.target.animates = new Map();\n }\n this.target.animates.set(this.id, this);\n this.onRemove(() => {\n this.stop();\n this.target.animates.delete(this.id);\n });\n\n if (this.target.onAnimateBind && !this.slience) {\n this.target.onAnimateBind(this as any);\n }\n // 添加一个animationAttribute属性,用于存储动画过程中的属性\n if (!this.target.animationAttribute) {\n this.target.animationAttribute = {};\n }\n return this;\n }\n\n /**\n * 动画步骤:to\n * 添加一个to步骤,这会在当前状态到指定状态间进行插值\n */\n to(props: Record<string, any>, duration: number = 300, easing: EasingType = 'linear'): this {\n // 创建新的step\n const step = new Step(AnimateStepType.to, props, duration, easing);\n\n step.bind(this.target, this);\n\n this.updateStepAfterAppend(step);\n\n return this;\n }\n\n /**\n * 等待延迟\n */\n wait(delay: number): this {\n // 创建新的wait step\n const step = new WaitStep(AnimateStepType.wait, {}, delay, 'linear');\n\n step.bind(this.target, this);\n\n this.updateStepAfterAppend(step);\n\n return this;\n }\n\n protected updateStepAfterAppend(step: IStep): void {\n // 如果是第一个step\n if (!this._firstStep) {\n this._firstStep = step;\n this._lastStep = step;\n } else {\n // 添加到链表末尾\n this._lastStep.append(step);\n this._lastStep = step;\n }\n\n this.parseStepProps(step);\n\n this.updateDuration();\n }\n\n /**\n * 解析step的props\n * 1. 预先获取step的propKeys并保存\n * 2. 将截止目前的最新props设置到step.props中,这样该props上的属性就是最终的属性了,跳帧时直接设置即可\n * 3. 同步到_endProps中,保存这个Animate实例的最终props\n * 4. 给step的props的原型链上绑定Animate的_startProps,这样在下一个step查找fromProps的时候,一定能拿得到值\n */\n parseStepProps(step: IStep) {\n if (!this._lastStep) {\n return;\n }\n\n /* 预设置step的属性,基于性能考虑,实现比较复杂 */\n // step.propKeys为真实的props属性的key\n step.propKeys = step.propKeys || Object.keys(step.props);\n // step.props为包含前序step的props的最终props,用于跳帧等场景,可以直接设置\n Object.keys(this._endProps).forEach(key => {\n step.props[key] = step.props[key] ?? this._endProps[key];\n });\n // 将最终的props设置到step.props中\n step.propKeys.forEach(key => {\n this._endProps[key] = step.props[key];\n });\n // 给step的props的原型链上绑定Animate的_startProps\n // 下一个step在查找上一个step.props(也就是找到它的fromProps)的时候,就能拿到初始的props了\n // 比如:\n // rect.animate().to({ x: 100 }, 1000, 'linear').to({ y: 100 }, 1000, 'linear');\n // 在第二个step查找fromProps的时候,就能拿到第一个step的endProps中的y值(在原型链上)\n // TODO 由于会有其他animate的干扰,所以不能直接设置原型链\n // Object.setPrototypeOf(step.props, this._startProps);\n }\n\n /**\n * 重新同步和计算props,用于内部某些step发生了变更后,重新计算自身\n * 性能较差,不要频繁调用\n * @returns\n */\n reSyncProps() {\n if (!this._lastStep) {\n return;\n }\n this._endProps = {};\n let currentStep: IStep = this._firstStep;\n // 从前向后寻找当前时间所在的step\n while (currentStep) {\n // step.props为包含前序step的props的最终props,用于跳帧等场景,可以直接设置\n // eslint-disable-next-line no-loop-func\n Object.keys(this._endProps).forEach(key => {\n currentStep.props[key] = currentStep.props[key] ?? this._endProps[key];\n });\n // 将最终的props设置到step.props中\n // eslint-disable-next-line no-loop-func\n currentStep.propKeys.forEach(key => {\n this._endProps[key] = currentStep.props[key];\n });\n // 给step的props的原型链上绑定Animate的_startProps\n // 下一个step在查找上一个step.props(也就是找到它的fromProps)的时候,就能拿到初始的props了\n // 比如:\n // rect.animate().to({ x: 100 }, 1000, 'linear').to({ y: 100 }, 1000, 'linear');\n // 在第二个step查找fromProps的时候,就能拿到第一个step的endProps中的y值(在原型链上)\n // TODO 由于会有其他animate的干扰,所以不能直接设置原型链\n // Object.setPrototypeOf(currentStep.props, this._startProps);\n currentStep = currentStep.next;\n }\n }\n\n /**\n * 动画步骤:from\n * 添加一个from步骤,这会将目标属性先设置为指定值,然后过渡到当前状态\n * 【注意】这可能会导致动画跳变,请谨慎使用\n */\n from(props: Record<string, any>, duration: number = 300, easing: EasingType = 'linear'): this {\n // 创建新的step\n const step = new Step(AnimateStepType.from, props, duration, easing);\n\n // 如果是第一个step\n if (!this._firstStep) {\n this._firstStep = step;\n this._lastStep = step;\n } else {\n // 添加到链表末尾\n this._lastStep.append(step);\n this._lastStep = step;\n }\n\n this.updateDuration();\n\n return this;\n }\n\n /**\n * 自定义动画\n */\n play(customAnimate: ICustomAnimate): this {\n customAnimate.bind(this.target, this);\n this.updateStepAfterAppend(customAnimate);\n\n return this;\n }\n\n /**\n * 暂停动画\n */\n pause(): void {\n if (this.status === AnimateStatus.RUNNING) {\n this.status = AnimateStatus.PAUSED;\n }\n }\n\n /**\n * 恢复动画\n */\n resume(): void {\n if (this.status === AnimateStatus.PAUSED) {\n this.status = AnimateStatus.RUNNING;\n }\n }\n\n /**\n * 注册开始回调\n */\n onStart(cb?: () => void): void {\n if (cb) {\n if (!this._onStart) {\n this._onStart = [];\n }\n this._onStart.push(cb);\n } else {\n this._onStart?.forEach(cb => cb());\n // 设置开始属性,Animate不会重复执行start所以不需要判断firstStart\n Object.keys(this._endProps).forEach(key => {\n this._startProps[key] = this.target.getComputedAttribute(key);\n });\n }\n }\n\n /**\n * 注册结束回调\n */\n onEnd(cb?: () => void): void {\n if (cb) {\n if (!this._onEnd) {\n this._onEnd = [];\n }\n this._onEnd.push(cb);\n } else {\n this._onEnd?.forEach(cb => cb());\n }\n }\n\n /**\n * 注册帧回调\n */\n onFrame(cb?: (step: IStep, ratio: number) => void): void {\n if (cb) {\n if (!this._onFrame) {\n this._onFrame = [];\n }\n this._onFrame.push(cb);\n }\n }\n\n /**\n * 注册移除回调\n */\n onRemove(cb?: () => void): void {\n if (cb) {\n if (!this._onRemove) {\n this._onRemove = [];\n }\n this._onRemove.push(cb);\n } else {\n this._onRemove?.forEach(cb => cb());\n }\n }\n\n /**\n * 屏蔽单个属性\n */\n preventAttr(key: string): void {\n this._preventAttrs.add(key);\n // 从所有step中移除该属性,并从自身的_startProps和_endProps中移除该属性\n delete this._startProps[key];\n delete this._endProps[key];\n let step = this._firstStep;\n while (step) {\n step.deleteSelfAttr(key);\n step = step.next;\n }\n }\n\n /**\n * 屏蔽多个属性\n */\n preventAttrs(keys: string[]): void {\n keys.forEach(key => this._preventAttrs.add(key));\n }\n\n /**\n * 检查属性是否合法(未被屏蔽)\n */\n validAttr(key: string): boolean {\n return !this._preventAttrs.has(key);\n }\n\n /**\n * 运行自定义回调\n */\n runCb(cb: (a: IAnimate, step: IStep) => void): IAnimate {\n this._lastStep?.onEnd(cb);\n return this;\n }\n\n /**\n * 设置动画开始时间\n */\n startAt(t: number): this {\n this._startTime = t;\n\n return this;\n }\n\n /**\n * 自定义插值函数,返回false表示没有匹配上\n */\n customInterpolate(\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IGraphic,\n ret: Record<string, any>\n ): boolean {\n // 默认无自定义插值,可由子类重写\n return false;\n }\n\n /**\n * 获取起始值,该起始值为animate的起始值,并不一定为step的起始值\n */\n getFromValue(): Record<string, any> {\n return this._startProps;\n }\n\n /**\n * 获取结束值\n */\n getToValue(): Record<string, any> {\n return this._endProps;\n }\n\n /**\n * 停止动画\n */\n stop(type?: 'start' | 'end' | Record<string, any>): void {\n // TODO 有些动画可能一添加就被删除\n // if (this.status === AnimateStatus.END) {\n // return;\n // }\n // 遍历step,调用其stop\n let step = this._firstStep;\n while (step) {\n step.stop();\n step = step.next;\n }\n\n if (this.status !== AnimateStatus.END) {\n this.onEnd();\n }\n\n this.status = AnimateStatus.END;\n\n if (!this.target) {\n return;\n }\n\n if (type === 'start') {\n // 设置为开始状态\n this.target.setAttributes(this._startProps);\n } else if (type === 'end') {\n // 设置为结束状态\n this.target.setAttributes(this._endProps);\n } else if (type) {\n // 设置为自定义状态\n this.target.setAttributes(type);\n }\n }\n\n /**\n * 释放动画资源\n */\n release(): void {\n this.status = AnimateStatus.END;\n\n // 触发移除回调\n if (this._onRemove) {\n this._onRemove.forEach(cb => cb());\n }\n\n // 清空回调\n this._onStart = [];\n this._onFrame = [];\n this._onEnd = [];\n this._onRemove = [];\n\n this.forEachStep(step => {\n step.release();\n });\n }\n\n /**\n * 获取动画持续时间\n */\n getDuration(): number {\n return this._duration;\n }\n\n /**\n * 获取动画开始时间\n */\n getStartTime(): number {\n return this._startTime;\n }\n\n /**\n * 在所有动画完成后执行\n */\n afterAll(list: IAnimate[]): this {\n if (!list || list.length === 0) {\n return this;\n }\n\n // 计算所有动画结束的最大时间点\n let maxEndTime = 0;\n list.forEach(animate => {\n const endTime = animate.getStartTime() + animate.getTotalDuration();\n maxEndTime = Math.max(maxEndTime, endTime);\n });\n\n // 设置当前动画的开始时间为最大结束时间\n return this.startAt(maxEndTime);\n }\n\n /**\n * 在指定动画完成后执行\n */\n after(animate: IAnimate): this {\n if (!animate) {\n return this;\n }\n\n // 计算指定动画结束的时间点\n const endTime = animate.getStartTime() + animate.getTotalDuration();\n\n // 设置当前动画的开始时间为结束时间\n return this.startAt(endTime);\n }\n\n /**\n * 并行执行动画\n */\n parallel(animate: IAnimate): this {\n if (!animate) {\n return this;\n }\n\n // 设置指定动画的开始时间为当前动画的开始时间\n this.startAt(animate.getStartTime());\n\n return this;\n }\n\n // /**\n // * 设置动画是否反转\n // */\n // reversed(r: boolean): this {\n // this._reversed = r;\n // return this;\n // }\n\n /**\n * 设置动画循环次数,如果传入true,则无限循环,如果传入false,则不循环\n */\n loop(n: number | boolean): this {\n if (n === true) {\n n = Infinity;\n } else if (n === false) {\n n = 0;\n }\n this._loopCount = n;\n this.updateDuration();\n return this;\n }\n\n /**\n * 设置动画是否反弹\n */\n bounce(b: boolean): this {\n this._bounce = b;\n return this;\n }\n\n /**\n * 推进动画\n */\n advance(delta: number): void {\n if (this.status === AnimateStatus.END) {\n console.warn('aaa 动画已经结束,不能推进');\n return;\n }\n const nextTime = this.currentTime + delta;\n // 如果还没开始,直接return\n if (nextTime < this._startTime) {\n this.currentTime = nextTime;\n return;\n }\n // 如果已经结束,设置状态后return\n if (nextTime >= this._startTime + this._totalDuration) {\n this._lastStep?.onUpdate(true, 1, {});\n this._lastStep?.onEnd();\n this.onEnd();\n this.status = AnimateStatus.END;\n return;\n }\n\n this.status = AnimateStatus.RUNNING;\n\n // 如果是第一次运行,触发开始回调\n if (this.currentTime <= this._startTime) {\n this.onStart();\n }\n this.currentTime = nextTime;\n\n let cycleTime = nextTime - this._startTime;\n let newLoop = false;\n let bounceTime = false;\n if (this._loopCount > 0) {\n cycleTime = (nextTime - this._startTime) % this._duration;\n const currentLoop = Math.floor((nextTime - this._startTime) / this._duration);\n newLoop = currentLoop > this._currentLoop;\n this._currentLoop = currentLoop;\n\n bounceTime = this._bounce && currentLoop % 2 === 1;\n if (bounceTime) {\n cycleTime = this._duration - cycleTime;\n }\n }\n\n // 如果是新的循环,重置为初始状态\n if (newLoop && !bounceTime) {\n this.target.setAttributes(this._startProps);\n }\n\n // 选择起始步骤和遍历方向\n let targetStep: IStep | null = null;\n\n if (this._lastStep === this._firstStep) {\n targetStep = this._firstStep;\n } else {\n let currentStep: IStep = this._firstStep;\n // 从前向后寻找当前时间所在的step\n while (currentStep) {\n const stepStartTime = currentStep.getStartTime();\n const stepDuration = currentStep.getDuration();\n const stepEndTime = stepStartTime + stepDuration;\n\n // 找到当前周期时间所在的step\n if (cycleTime >= stepStartTime && cycleTime <= stepEndTime) {\n targetStep = currentStep;\n break;\n }\n\n currentStep = currentStep.next;\n }\n }\n\n // 如果没找到目标step(可能是所有step都执行完了,但整体动画还没结束,这正常是不存在的)\n if (!targetStep) {\n // this.currentTime = nextTime;\n // console.warn('动画出现问题');\n return;\n }\n\n // 如果当前step和上一次执行的step不一样,则调用上一次step的onEnd,确保所有完成的step都调用了结束\n // 如果上一次的step已经调用了onEnd,在下面的onEnd那里会将lastRunStep设置为null\n if (targetStep !== this.lastRunStep) {\n this.lastRunStep?.onEnd();\n }\n\n this.lastRunStep = targetStep;\n\n // 计算当前step的进度比例(基于当前step内的相对时间)\n const stepStartTime = targetStep.getStartTime();\n const stepDuration = targetStep.getDuration();\n\n const ratio = (cycleTime - stepStartTime) / stepDuration;\n // // 限制ratio在0-1之间\n // ratio = Math.max(0, Math.min(1, ratio));\n\n const isEnd = ratio >= 1;\n targetStep.update(isEnd, ratio, {});\n\n // 如果step执行完毕\n if (isEnd) {\n targetStep.onEnd();\n this.lastRunStep = null;\n // 不立即调用onFinish,让动画系统来决定何时结束\n }\n\n // 触发帧回调\n // if (this._onFrame) {\n // this._onFrame.forEach(cb => cb(targetStep, ratio));\n // }\n }\n\n updateDuration(): void {\n if (!this._lastStep) {\n this._duration = 0;\n return;\n }\n\n this._duration = this._lastStep.getStartTime() + this._lastStep.getDuration();\n this._totalDuration = this._duration * (this._loopCount + 1);\n }\n\n getTotalDuration(): number {\n return this._totalDuration;\n }\n\n getLoop(): number {\n return this._loopCount;\n }\n\n protected forEachStep(cb: (step: IStep) => void): void {\n let step = this._firstStep;\n while (step) {\n cb(step);\n step = step.next;\n }\n }\n}\n"]}
|
|
1
|
+
{"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AC,WAAW,EAAE,CAAC;QAC9E,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAES,WAAW,CAAC,EAAyB;QAC7C,IAAI,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QAC3B,OAAO,IAAI,EAAE;YACX,EAAE,CAAC,IAAI,CAAC,CAAC;YACT,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;SAClB;IACH,CAAC;CACF","file":"animate.js","sourcesContent":["import { Step, WaitStep } from './step';\nimport {\n Generator,\n AnimateStatus,\n AnimateStepType,\n type IGraphic,\n type IAnimate,\n type IStep,\n type ICustomAnimate,\n type EasingType,\n type ITimeline\n} from '@visactor/vrender-core';\nimport { defaultTimeline } from './timeline';\n\nexport class Animate implements IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n target: IGraphic;\n\n // 回调函数列表\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n // 时间控制\n private _timeline: ITimeline;\n private _startTime: number;\n private _duration: number;\n private _totalDuration: number;\n\n // 动画控制\n // private _reversed: boolean;\n private _loopCount: number;\n private _currentLoop: number;\n private _bounce: boolean;\n\n // 链表头节点和尾节点\n private _firstStep: IStep | null;\n private _lastStep: IStep | null;\n\n // 初始属性和屏蔽的属性\n private _startProps: Record<string, any>;\n private _endProps: Record<string, any>;\n private _preventAttrs: Set<string>;\n // 优先级,用于判定是否能被后续的动画preventAttr\n declare priority: number;\n\n protected currentTime: number;\n slience?: boolean;\n\n // 临时变量\n lastRunStep?: IStep;\n\n interpolateUpdateFunction:\n | ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void)\n | null;\n\n constructor(\n id: string | number = Generator.GenAutoIncrementId(),\n timeline: ITimeline = defaultTimeline,\n slience?: boolean\n ) {\n this.id = id;\n this.status = AnimateStatus.INITIAL;\n this._timeline = timeline;\n timeline.addAnimate(this);\n this.slience = slience;\n this._startTime = 0;\n this._duration = 0;\n this._totalDuration = 0;\n // this._reversed = false;\n this._loopCount = 0;\n this._currentLoop = 0;\n this._bounce = false;\n this._firstStep = null;\n this._lastStep = null;\n this._startProps = {};\n this._endProps = {};\n this._preventAttrs = new Set();\n this.currentTime = 0;\n this.interpolateUpdateFunction = null;\n this.priority = 0;\n }\n\n /**\n * 获取开始属性\n */\n getStartProps(): Record<string, any> {\n return this._startProps;\n }\n\n /**\n * 获取结束属性\n */\n getEndProps(): Record<string, any> {\n return this._endProps;\n }\n\n /**\n * 设置时间线\n */\n setTimeline(timeline: ITimeline): void {\n this._timeline = timeline;\n }\n\n /**\n * 获取时间线\n */\n getTimeline(): ITimeline {\n return this._timeline;\n }\n\n /**\n * 时间线属性访问器\n */\n get timeline(): ITimeline {\n return this._timeline;\n }\n\n /**\n * 绑定目标图形\n */\n bind(target: IGraphic): this {\n this.target = target;\n\n if (!this.target.animates) {\n this.target.animates = new Map();\n }\n this.target.animates.set(this.id, this);\n this.onRemove(() => {\n this.stop();\n this.target.animates.delete(this.id);\n });\n\n if (this.target.onAnimateBind && !this.slience) {\n this.target.onAnimateBind(this as any);\n }\n // 添加一个animationAttribute属性,用于存储动画过程中的属性\n if (!this.target.animationAttribute) {\n this.target.animationAttribute = {};\n }\n return this;\n }\n\n /**\n * 动画步骤:to\n * 添加一个to步骤,这会在当前状态到指定状态间进行插值\n */\n to(props: Record<string, any>, duration: number = 300, easing: EasingType = 'linear'): this {\n // 创建新的step\n const step = new Step(AnimateStepType.to, props, duration, easing);\n\n step.bind(this.target, this);\n\n this.updateStepAfterAppend(step);\n\n return this;\n }\n\n /**\n * 等待延迟\n */\n wait(delay: number): this {\n // 创建新的wait step\n const step = new WaitStep(AnimateStepType.wait, {}, delay, 'linear');\n\n step.bind(this.target, this);\n\n this.updateStepAfterAppend(step);\n\n return this;\n }\n\n protected updateStepAfterAppend(step: IStep): void {\n // 如果是第一个step\n if (!this._firstStep) {\n this._firstStep = step;\n this._lastStep = step;\n } else {\n // 添加到链表末尾\n this._lastStep.append(step);\n this._lastStep = step;\n }\n\n this.parseStepProps(step);\n\n this.updateDuration();\n }\n\n /**\n * 解析step的props\n * 1. 预先获取step的propKeys并保存\n * 2. 将截止目前的最新props设置到step.props中,这样该props上的属性就是最终的属性了,跳帧时直接设置即可\n * 3. 同步到_endProps中,保存这个Animate实例的最终props\n * 4. 给step的props的原型链上绑定Animate的_startProps,这样在下一个step查找fromProps的时候,一定能拿得到值\n */\n parseStepProps(step: IStep) {\n if (!this._lastStep) {\n return;\n }\n\n /* 预设置step的属性,基于性能考虑,实现比较复杂 */\n // step.propKeys为真实的props属性的key\n step.propKeys = step.propKeys || Object.keys(step.props);\n // step.props为包含前序step的props的最终props,用于跳帧等场景,可以直接设置\n Object.keys(this._endProps).forEach(key => {\n step.props[key] = step.props[key] ?? this._endProps[key];\n });\n // 将最终的props设置到step.props中\n step.propKeys.forEach(key => {\n this._endProps[key] = step.props[key];\n });\n // 给step的props的原型链上绑定Animate的_startProps\n // 下一个step在查找上一个step.props(也就是找到它的fromProps)的时候,就能拿到初始的props了\n // 比如:\n // rect.animate().to({ x: 100 }, 1000, 'linear').to({ y: 100 }, 1000, 'linear');\n // 在第二个step查找fromProps的时候,就能拿到第一个step的endProps中的y值(在原型链上)\n // TODO 由于会有其他animate的干扰,所以不能直接设置原型链\n // Object.setPrototypeOf(step.props, this._startProps);\n }\n\n /**\n * 重新同步和计算props,用于内部某些step发生了变更后,重新计算自身\n * 性能较差,不要频繁调用\n * @returns\n */\n reSyncProps() {\n if (!this._lastStep) {\n return;\n }\n this._endProps = {};\n let currentStep: IStep = this._firstStep;\n // 从前向后寻找当前时间所在的step\n while (currentStep) {\n // step.props为包含前序step的props的最终props,用于跳帧等场景,可以直接设置\n // eslint-disable-next-line no-loop-func\n Object.keys(this._endProps).forEach(key => {\n currentStep.props[key] = currentStep.props[key] ?? this._endProps[key];\n });\n // 将最终的props设置到step.props中\n // eslint-disable-next-line no-loop-func\n currentStep.propKeys.forEach(key => {\n this._endProps[key] = currentStep.props[key];\n });\n // 给step的props的原型链上绑定Animate的_startProps\n // 下一个step在查找上一个step.props(也就是找到它的fromProps)的时候,就能拿到初始的props了\n // 比如:\n // rect.animate().to({ x: 100 }, 1000, 'linear').to({ y: 100 }, 1000, 'linear');\n // 在第二个step查找fromProps的时候,就能拿到第一个step的endProps中的y值(在原型链上)\n // TODO 由于会有其他animate的干扰,所以不能直接设置原型链\n // Object.setPrototypeOf(currentStep.props, this._startProps);\n currentStep = currentStep.next;\n }\n }\n\n /**\n * 动画步骤:from\n * 添加一个from步骤,这会将目标属性先设置为指定值,然后过渡到当前状态\n * 【注意】这可能会导致动画跳变,请谨慎使用\n */\n from(props: Record<string, any>, duration: number = 300, easing: EasingType = 'linear'): this {\n // 创建新的step\n const step = new Step(AnimateStepType.from, props, duration, easing);\n\n step.bind(this.target, this);\n\n this.updateStepAfterAppend(step);\n\n return this;\n }\n\n /**\n * 自定义动画\n */\n play(customAnimate: ICustomAnimate): this {\n customAnimate.bind(this.target, this);\n this.updateStepAfterAppend(customAnimate);\n\n return this;\n }\n\n /**\n * 暂停动画\n */\n pause(): void {\n if (this.status === AnimateStatus.RUNNING) {\n this.status = AnimateStatus.PAUSED;\n }\n }\n\n /**\n * 恢复动画\n */\n resume(): void {\n if (this.status === AnimateStatus.PAUSED) {\n this.status = AnimateStatus.RUNNING;\n }\n }\n\n /**\n * 注册开始回调\n */\n onStart(cb?: () => void): void {\n if (cb) {\n if (!this._onStart) {\n this._onStart = [];\n }\n this._onStart.push(cb);\n } else {\n this._onStart?.forEach(cb => cb());\n // 设置开始属性,Animate不会重复执行start所以不需要判断firstStart\n Object.keys(this._endProps).forEach(key => {\n this._startProps[key] = this.target.getComputedAttribute(key);\n });\n }\n }\n\n /**\n * 注册结束回调\n */\n onEnd(cb?: () => void): void {\n if (cb) {\n if (!this._onEnd) {\n this._onEnd = [];\n }\n this._onEnd.push(cb);\n } else {\n this._onEnd?.forEach(cb => cb());\n }\n }\n\n /**\n * 注册帧回调\n */\n onFrame(cb?: (step: IStep, ratio: number) => void): void {\n if (cb) {\n if (!this._onFrame) {\n this._onFrame = [];\n }\n this._onFrame.push(cb);\n }\n }\n\n /**\n * 注册移除回调\n */\n onRemove(cb?: () => void): void {\n if (cb) {\n if (!this._onRemove) {\n this._onRemove = [];\n }\n this._onRemove.push(cb);\n } else {\n this._onRemove?.forEach(cb => cb());\n }\n }\n\n /**\n * 屏蔽单个属性\n */\n preventAttr(key: string): void {\n this._preventAttrs.add(key);\n // 从所有step中移除该属性,并从自身的_startProps和_endProps中移除该属性\n delete this._startProps[key];\n delete this._endProps[key];\n let step = this._firstStep;\n while (step) {\n step.deleteSelfAttr(key);\n step = step.next;\n }\n }\n\n /**\n * 屏蔽多个属性\n */\n preventAttrs(keys: string[]): void {\n keys.forEach(key => this._preventAttrs.add(key));\n }\n\n /**\n * 检查属性是否合法(未被屏蔽)\n */\n validAttr(key: string): boolean {\n return !this._preventAttrs.has(key);\n }\n\n /**\n * 运行自定义回调\n */\n runCb(cb: (a: IAnimate, step: IStep) => void): IAnimate {\n this._lastStep?.onEnd(cb);\n return this;\n }\n\n /**\n * 设置动画开始时间\n */\n startAt(t: number): this {\n this._startTime = t;\n\n return this;\n }\n\n /**\n * 自定义插值函数,返回false表示没有匹配上\n */\n customInterpolate(\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IGraphic,\n ret: Record<string, any>\n ): boolean {\n // 默认无自定义插值,可由子类重写\n return false;\n }\n\n /**\n * 获取起始值,该起始值为animate的起始值,并不一定为step的起始值\n */\n getFromValue(): Record<string, any> {\n return this._startProps;\n }\n\n /**\n * 获取结束值\n */\n getToValue(): Record<string, any> {\n return this._endProps;\n }\n\n /**\n * 停止动画\n */\n stop(type?: 'start' | 'end' | Record<string, any>): void {\n // TODO 有些动画可能一添加就被删除\n // if (this.status === AnimateStatus.END) {\n // return;\n // }\n // 遍历step,调用其stop\n let step = this._firstStep;\n while (step) {\n step.stop();\n step = step.next;\n }\n\n if (this.status !== AnimateStatus.END) {\n this.onEnd();\n }\n\n this.status = AnimateStatus.END;\n\n if (!this.target) {\n return;\n }\n\n if (type === 'start') {\n // 设置为开始状态\n this.target.setAttributes(this._startProps);\n } else if (type === 'end') {\n // 设置为结束状态\n this.target.setAttributes(this._endProps);\n } else if (type) {\n // 设置为自定义状态\n this.target.setAttributes(type);\n }\n }\n\n /**\n * 释放动画资源\n */\n release(): void {\n this.status = AnimateStatus.END;\n\n // 触发移除回调\n if (this._onRemove) {\n this._onRemove.forEach(cb => cb());\n }\n\n // 清空回调\n this._onStart = [];\n this._onFrame = [];\n this._onEnd = [];\n this._onRemove = [];\n\n this.forEachStep(step => {\n step.release();\n });\n }\n\n /**\n * 获取动画持续时间\n */\n getDuration(): number {\n return this._duration;\n }\n\n /**\n * 获取动画开始时间\n */\n getStartTime(): number {\n return this._startTime;\n }\n\n /**\n * 在所有动画完成后执行\n */\n afterAll(list: IAnimate[]): this {\n if (!list || list.length === 0) {\n return this;\n }\n\n // 计算所有动画结束的最大时间点\n let maxEndTime = 0;\n list.forEach(animate => {\n const endTime = animate.getStartTime() + animate.getTotalDuration();\n maxEndTime = Math.max(maxEndTime, endTime);\n });\n\n // 设置当前动画的开始时间为最大结束时间\n return this.startAt(maxEndTime);\n }\n\n /**\n * 在指定动画完成后执行\n */\n after(animate: IAnimate): this {\n if (!animate) {\n return this;\n }\n\n // 计算指定动画结束的时间点\n const endTime = animate.getStartTime() + animate.getTotalDuration();\n\n // 设置当前动画的开始时间为结束时间\n return this.startAt(endTime);\n }\n\n /**\n * 并行执行动画\n */\n parallel(animate: IAnimate): this {\n if (!animate) {\n return this;\n }\n\n // 设置指定动画的开始时间为当前动画的开始时间\n this.startAt(animate.getStartTime());\n\n return this;\n }\n\n // /**\n // * 设置动画是否反转\n // */\n // reversed(r: boolean): this {\n // this._reversed = r;\n // return this;\n // }\n\n /**\n * 设置动画循环次数,如果传入true,则无限循环,如果传入false,则不循环\n */\n loop(n: number | boolean): this {\n if (n === true) {\n n = Infinity;\n } else if (n === false) {\n n = 0;\n }\n this._loopCount = n;\n this.updateDuration();\n return this;\n }\n\n /**\n * 设置动画是否反弹\n */\n bounce(b: boolean): this {\n this._bounce = b;\n return this;\n }\n\n /**\n * 推进动画\n */\n advance(delta: number): void {\n if (this.status === AnimateStatus.END) {\n console.warn('aaa 动画已经结束,不能推进');\n return;\n }\n const nextTime = this.currentTime + delta;\n // 如果还没开始,直接return\n if (nextTime < this._startTime) {\n this.currentTime = nextTime;\n return;\n }\n // 如果已经结束,设置状态后return\n if (nextTime >= this._startTime + this._totalDuration) {\n this._lastStep?.onUpdate(true, 1, {});\n this._lastStep?.onEnd();\n this.onEnd();\n this.status = AnimateStatus.END;\n return;\n }\n\n this.status = AnimateStatus.RUNNING;\n\n // 如果是第一次运行,触发开始回调\n if (this.currentTime <= this._startTime) {\n this.onStart();\n }\n this.currentTime = nextTime;\n\n let cycleTime = nextTime - this._startTime;\n let newLoop = false;\n let bounceTime = false;\n if (this._loopCount > 0) {\n cycleTime = (nextTime - this._startTime) % this._duration;\n const currentLoop = Math.floor((nextTime - this._startTime) / this._duration);\n newLoop = currentLoop > this._currentLoop;\n this._currentLoop = currentLoop;\n\n bounceTime = this._bounce && currentLoop % 2 === 1;\n if (bounceTime) {\n cycleTime = this._duration - cycleTime;\n }\n }\n\n // 如果是新的循环,重置为初始状态\n if (newLoop && !bounceTime) {\n this.target.setAttributes(this._startProps);\n }\n\n // 选择起始步骤和遍历方向\n let targetStep: IStep | null = null;\n\n if (this._lastStep === this._firstStep) {\n targetStep = this._firstStep;\n } else {\n let currentStep: IStep = this._firstStep;\n // 从前向后寻找当前时间所在的step\n while (currentStep) {\n const stepStartTime = currentStep.getStartTime();\n const stepDuration = currentStep.getDuration();\n const stepEndTime = stepStartTime + stepDuration;\n\n // 找到当前周期时间所在的step\n if (cycleTime >= stepStartTime && cycleTime <= stepEndTime) {\n targetStep = currentStep;\n break;\n }\n\n currentStep = currentStep.next;\n }\n }\n\n // 如果没找到目标step(可能是所有step都执行完了,但整体动画还没结束,这正常是不存在的)\n if (!targetStep) {\n // this.currentTime = nextTime;\n // console.warn('动画出现问题');\n return;\n }\n\n // 如果当前step和上一次执行的step不一样,则调用上一次step的onEnd,确保所有完成的step都调用了结束\n // 如果上一次的step已经调用了onEnd,在下面的onEnd那里会将lastRunStep设置为null\n if (targetStep !== this.lastRunStep) {\n this.lastRunStep?.onEnd();\n }\n\n this.lastRunStep = targetStep;\n\n // 计算当前step的进度比例(基于当前step内的相对时间)\n const stepStartTime = targetStep.getStartTime();\n const stepDuration = targetStep.getDuration();\n\n const ratio = (cycleTime - stepStartTime) / stepDuration;\n // // 限制ratio在0-1之间\n // ratio = Math.max(0, Math.min(1, ratio));\n\n const isEnd = ratio >= 1;\n targetStep.update(isEnd, ratio, {});\n\n // 如果step执行完毕\n if (isEnd) {\n targetStep.onEnd();\n this.lastRunStep = null;\n // 不立即调用onFinish,让动画系统来决定何时结束\n }\n\n // 触发帧回调\n // if (this._onFrame) {\n // this._onFrame.forEach(cb => cb(targetStep, ratio));\n // }\n }\n\n updateDuration(): void {\n if (!this._lastStep) {\n this._duration = 0;\n return;\n }\n\n this._duration = this._lastStep.getStartTime() + this._lastStep.getDuration();\n this._totalDuration = this._duration * (this._loopCount + 1);\n }\n\n getTotalDuration(): number {\n return this._totalDuration;\n }\n\n getLoop(): number {\n return this._loopCount;\n }\n\n protected forEachStep(cb: (step: IStep) => void): void {\n let step = this._firstStep;\n while (step) {\n cb(step);\n step = step.next;\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttributeUpdateType, graphicService } from "@visactor/vrender-core";
|
|
2
2
|
|
|
3
3
|
import { ACustomAnimate } from "./custom-animate";
|
|
4
4
|
|
|
@@ -46,7 +46,7 @@ export class ClipAngleAnimate extends ClipGraphicAnimate {
|
|
|
46
46
|
let arcStartAngle = 0, arcEndAngle = 0;
|
|
47
47
|
"anticlockwise" === orient ? (arcEndAngle = "in" === animationType ? startAngle + 2 * Math.PI : startAngle,
|
|
48
48
|
arcEndAngle = startAngle + 2 * Math.PI) : (arcStartAngle = startAngle, arcEndAngle = "out" === animationType ? startAngle + 2 * Math.PI : startAngle);
|
|
49
|
-
const arc =
|
|
49
|
+
const arc = graphicService.creator.arc({
|
|
50
50
|
x: null !== (_j = null === (_h = null == params ? void 0 : params.center) || void 0 === _h ? void 0 : _h.x) && void 0 !== _j ? _j : width / 2,
|
|
51
51
|
y: null !== (_l = null === (_k = null == params ? void 0 : params.center) || void 0 === _k ? void 0 : _k.y) && void 0 !== _l ? _l : height / 2,
|
|
52
52
|
outerRadius: null !== (_m = null == params ? void 0 : params.radius) && void 0 !== _m ? _m : (width + height) / 2,
|
|
@@ -74,7 +74,7 @@ export class ClipAngleAnimate extends ClipGraphicAnimate {
|
|
|
74
74
|
export class ClipRadiusAnimate extends ClipGraphicAnimate {
|
|
75
75
|
constructor(from, to, duration, easing, params) {
|
|
76
76
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
77
|
-
const groupAttribute = null !== (_b = null === (_a = null == params ? void 0 : params.group) || void 0 === _a ? void 0 : _a.attribute) && void 0 !== _b ? _b : {}, width = null !== (_c = groupAttribute.width) && void 0 !== _c ? _c : 0, height = null !== (_d = groupAttribute.height) && void 0 !== _d ? _d : 0, animationType = null !== (_e = null == params ? void 0 : params.animationType) && void 0 !== _e ? _e : "in", startRadius = null !== (_f = null == params ? void 0 : params.startRadius) && void 0 !== _f ? _f : 0, endRadius = null !== (_g = null == params ? void 0 : params.endRadius) && void 0 !== _g ? _g : Math.sqrt((width / 2) ** 2 + (height / 2) ** 2), arc =
|
|
77
|
+
const groupAttribute = null !== (_b = null === (_a = null == params ? void 0 : params.group) || void 0 === _a ? void 0 : _a.attribute) && void 0 !== _b ? _b : {}, width = null !== (_c = groupAttribute.width) && void 0 !== _c ? _c : 0, height = null !== (_d = groupAttribute.height) && void 0 !== _d ? _d : 0, animationType = null !== (_e = null == params ? void 0 : params.animationType) && void 0 !== _e ? _e : "in", startRadius = null !== (_f = null == params ? void 0 : params.startRadius) && void 0 !== _f ? _f : 0, endRadius = null !== (_g = null == params ? void 0 : params.endRadius) && void 0 !== _g ? _g : Math.sqrt((width / 2) ** 2 + (height / 2) ** 2), arc = graphicService.creator.arc({
|
|
78
78
|
x: null !== (_j = null === (_h = null == params ? void 0 : params.center) || void 0 === _h ? void 0 : _h.x) && void 0 !== _j ? _j : width / 2,
|
|
79
79
|
y: null !== (_l = null === (_k = null == params ? void 0 : params.center) || void 0 === _k ? void 0 : _k.y) && void 0 !== _l ? _l : height / 2,
|
|
80
80
|
outerRadius: "out" === animationType ? endRadius : startRadius,
|
|
@@ -97,7 +97,7 @@ export class ClipRadiusAnimate extends ClipGraphicAnimate {
|
|
|
97
97
|
export class ClipDirectionAnimate extends ClipGraphicAnimate {
|
|
98
98
|
constructor(from, to, duration, easing, params) {
|
|
99
99
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
100
|
-
const groupAttribute = null !== (_b = null === (_a = null == params ? void 0 : params.group) || void 0 === _a ? void 0 : _a.attribute) && void 0 !== _b ? _b : {}, width = null !== (_d = null !== (_c = null == params ? void 0 : params.width) && void 0 !== _c ? _c : groupAttribute.width) && void 0 !== _d ? _d : 0, height = null !== (_f = null !== (_e = null == params ? void 0 : params.height) && void 0 !== _e ? _e : groupAttribute.height) && void 0 !== _f ? _f : 0, animationType = null !== (_g = null == params ? void 0 : params.animationType) && void 0 !== _g ? _g : "in", direction = null !== (_h = null == params ? void 0 : params.direction) && void 0 !== _h ? _h : "x", orient = null !== (_j = null == params ? void 0 : params.orient) && void 0 !== _j ? _j : "positive", rect =
|
|
100
|
+
const groupAttribute = null !== (_b = null === (_a = null == params ? void 0 : params.group) || void 0 === _a ? void 0 : _a.attribute) && void 0 !== _b ? _b : {}, width = null !== (_d = null !== (_c = null == params ? void 0 : params.width) && void 0 !== _c ? _c : groupAttribute.width) && void 0 !== _d ? _d : 0, height = null !== (_f = null !== (_e = null == params ? void 0 : params.height) && void 0 !== _e ? _e : groupAttribute.height) && void 0 !== _f ? _f : 0, animationType = null !== (_g = null == params ? void 0 : params.animationType) && void 0 !== _g ? _g : "in", direction = null !== (_h = null == params ? void 0 : params.direction) && void 0 !== _h ? _h : "x", orient = null !== (_j = null == params ? void 0 : params.orient) && void 0 !== _j ? _j : "positive", rect = graphicService.creator.rect({
|
|
101
101
|
x: 0,
|
|
102
102
|
y: 0,
|
|
103
103
|
width: "in" === animationType && "x" === direction ? 0 : width,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/custom/clip-graphic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAmB,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,OAAO,kBAAmB,SAAQ,cAAmB;IASzD,YACE,IAAS,EACT,EAAO,EACP,QAAgB,EAChB,MAAkB,EAClB,MAAgD;QAEhD,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,CAAC;IAC1C,CAAC;IAED,MAAM;QACJ,KAAK,CAAC,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AAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,EACtD,QAAQ,EACR,MAAM,EACN,EAAE,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAC5C,CAAC;IACJ,CAAC;CACF","file":"clip-graphic.js","sourcesContent":["import type { IArcGraphicAttribute, IGraphic, IGroup, IRectGraphicAttribute } from '@visactor/vrender-core';\nimport { application, AttributeUpdateType, type EasingType } from '@visactor/vrender-core';\nimport { ACustomAnimate } from './custom-animate';\n\nexport class ClipGraphicAnimate extends ACustomAnimate<any> {\n private _group?: IGroup;\n private _clipGraphic?: IGraphic;\n protected clipFromAttribute?: any;\n protected clipToAttribute?: any;\n\n private _lastClip?: boolean;\n private _lastPath?: IGraphic[];\n\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: { group: IGroup; clipGraphic: IGraphic }\n ) {\n super(null, {}, duration, easing, params);\n this.clipFromAttribute = from;\n this.clipToAttribute = to;\n this._group = params?.group;\n this._clipGraphic = params?.clipGraphic;\n }\n\n onBind() {\n super.onBind();\n if (this._group && this._clipGraphic) {\n this._lastClip = this._group.attribute.clip;\n this._lastPath = this._group.attribute.path;\n this._group.setAttributes(\n {\n clip: true,\n path: [this._clipGraphic]\n },\n false,\n { type: AttributeUpdateType.ANIMATE_BIND }\n );\n }\n }\n\n onEnd() {\n if (this._group) {\n this._group.setAttributes(\n {\n clip: this._lastClip,\n path: this._lastPath\n },\n false,\n { type: AttributeUpdateType.ANIMATE_END }\n );\n }\n return;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this._clipGraphic) {\n return;\n }\n const res: any = {};\n Object.keys(this.clipFromAttribute).forEach(k => {\n res[k] = this.clipFromAttribute[k] + (this.clipToAttribute[k] - this.clipFromAttribute[k]) * ratio;\n });\n this._clipGraphic.setAttributes(res, false, {\n type: AttributeUpdateType.ANIMATE_UPDATE,\n animationState: { ratio, end }\n });\n }\n}\n\nexport class ClipAngleAnimate extends ClipGraphicAnimate {\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: {\n group: IGroup;\n center?: { x: number; y: number };\n startAngle?: number;\n radius?: number;\n orient?: 'clockwise' | 'anticlockwise';\n animationType?: 'in' | 'out';\n }\n ) {\n const groupAttribute = params?.group?.attribute ?? {};\n const width = groupAttribute.width ?? 0;\n const height = groupAttribute.height ?? 0;\n\n const animationType = params?.animationType ?? 'in';\n const startAngle = params?.startAngle ?? 0;\n const orient = params?.orient ?? 'clockwise';\n\n let arcStartAngle = 0;\n let arcEndAngle = 0;\n if (orient === 'anticlockwise') {\n arcEndAngle = animationType === 'in' ? startAngle + Math.PI * 2 : startAngle;\n arcEndAngle = startAngle + Math.PI * 2;\n } else {\n arcStartAngle = startAngle;\n arcEndAngle = animationType === 'out' ? startAngle + Math.PI * 2 : startAngle;\n }\n const arc = application.graphicService.creator.arc({\n x: params?.center?.x ?? width / 2,\n y: params?.center?.y ?? height / 2,\n outerRadius: params?.radius ?? (width + height) / 2,\n innerRadius: 0,\n startAngle: arcStartAngle,\n endAngle: arcEndAngle,\n fill: true\n });\n let fromAttributes: Partial<IArcGraphicAttribute>;\n let toAttributes: Partial<IArcGraphicAttribute>;\n if (orient === 'anticlockwise') {\n fromAttributes = { startAngle: startAngle + Math.PI * 2 };\n toAttributes = { startAngle: startAngle };\n } else {\n fromAttributes = { endAngle: startAngle };\n toAttributes = { endAngle: startAngle + Math.PI * 2 };\n }\n super(\n animationType === 'in' ? fromAttributes : toAttributes,\n animationType === 'in' ? toAttributes : fromAttributes,\n duration,\n easing,\n { group: params?.group, clipGraphic: arc }\n );\n }\n}\n\nexport class ClipRadiusAnimate extends ClipGraphicAnimate {\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: {\n group: IGroup;\n center?: { x: number; y: number };\n startRadius?: number;\n endRadius?: number;\n animationType?: 'in' | 'out';\n }\n ) {\n const groupAttribute = params?.group?.attribute ?? {};\n const width = groupAttribute.width ?? 0;\n const height = groupAttribute.height ?? 0;\n\n const animationType = params?.animationType ?? 'in';\n const startRadius = params?.startRadius ?? 0;\n const endRadius = params?.endRadius ?? Math.sqrt((width / 2) ** 2 + (height / 2) ** 2);\n\n const arc = application.graphicService.creator.arc({\n x: params?.center?.x ?? width / 2,\n y: params?.center?.y ?? height / 2,\n outerRadius: animationType === 'out' ? endRadius : startRadius,\n innerRadius: 0,\n startAngle: 0,\n endAngle: Math.PI * 2,\n fill: true\n });\n const fromAttributes: Partial<IArcGraphicAttribute> = { outerRadius: startRadius };\n const toAttributes: Partial<IArcGraphicAttribute> = { outerRadius: endRadius };\n super(\n animationType === 'in' ? fromAttributes : toAttributes,\n animationType === 'in' ? toAttributes : fromAttributes,\n duration,\n easing,\n { group: params?.group, clipGraphic: arc }\n );\n }\n}\n\nexport class ClipDirectionAnimate extends ClipGraphicAnimate {\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: {\n group: IGroup;\n direction?: 'x' | 'y';\n orient?: 'positive' | 'negative';\n width?: number;\n height?: number;\n animationType?: 'in' | 'out';\n }\n ) {\n const groupAttribute = params?.group?.attribute ?? {};\n const width = params?.width ?? groupAttribute.width ?? 0;\n const height = params?.height ?? groupAttribute.height ?? 0;\n\n const animationType = params?.animationType ?? 'in';\n const direction = params?.direction ?? 'x';\n const orient = params?.orient ?? 'positive';\n\n const rect = application.graphicService.creator.rect({\n x: 0,\n y: 0,\n width: animationType === 'in' && direction === 'x' ? 0 : width,\n height: animationType === 'in' && direction === 'y' ? 0 : height,\n fill: true\n });\n let fromAttributes: Partial<IRectGraphicAttribute> = {};\n let toAttributes: Partial<IRectGraphicAttribute> = {};\n if (direction === 'y') {\n if (orient === 'negative') {\n fromAttributes = { y: height, height: 0 };\n toAttributes = { y: 0, height: height };\n } else {\n fromAttributes = { height: 0 };\n toAttributes = { height: height };\n }\n } else {\n if (orient === 'negative') {\n fromAttributes = { x: width, width: 0 };\n toAttributes = { x: 0, width: width };\n } else {\n fromAttributes = { width: 0 };\n toAttributes = { width: width };\n }\n }\n super(\n animationType === 'in' ? fromAttributes : toAttributes,\n animationType === 'in' ? toAttributes : fromAttributes,\n duration,\n easing,\n { group: params?.group, clipGraphic: rect }\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/custom/clip-graphic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAmB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,OAAO,kBAAmB,SAAQ,cAAmB;IASzD,YACE,IAAS,EACT,EAAO,EACP,QAAgB,EAChB,MAAkB,EAClB,MAAgD;QAEhD,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,CAAC;IAC1C,CAAC;IAED,MAAM;QACJ,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE;YACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;YAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;YAC5C,IAAI,CAAC,MAAM,CAAC,aAAa,CACvB;gBACE,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;aAC1B,EACD,KAAK,EACL,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,GAAmC,EAAE,CAAC;QACtD,IAAI,SAAS,KAAK,GAAG,EAAE;YACrB,IAAI,MAAM,KAAK,UAAU,EAAE;gBACzB,cAAc,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBAC1C,YAAY,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;aACzC;iBAAM;gBACL,cAAc,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBAC/B,YAAY,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;aACnC;SACF;aAAM;YACL,IAAI,MAAM,KAAK,UAAU,EAAE;gBACzB,cAAc,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;gBACxC,YAAY,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;aACvC;iBAAM;gBACL,cAAc,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;gBAC9B,YAAY,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;aACjC;SACF;QACD,KAAK,CACH,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,YAAY,EACtD,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,EACtD,QAAQ,EACR,MAAM,EACN,EAAE,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAC5C,CAAC;IACJ,CAAC;CACF","file":"clip-graphic.js","sourcesContent":["import type { IArcGraphicAttribute, IGraphic, IGroup, IRectGraphicAttribute } from '@visactor/vrender-core';\nimport { AttributeUpdateType, type EasingType, graphicService } from '@visactor/vrender-core';\nimport { ACustomAnimate } from './custom-animate';\n\nexport class ClipGraphicAnimate extends ACustomAnimate<any> {\n private _group?: IGroup;\n private _clipGraphic?: IGraphic;\n protected clipFromAttribute?: any;\n protected clipToAttribute?: any;\n\n private _lastClip?: boolean;\n private _lastPath?: IGraphic[];\n\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: { group: IGroup; clipGraphic: IGraphic }\n ) {\n super(null, {}, duration, easing, params);\n this.clipFromAttribute = from;\n this.clipToAttribute = to;\n this._group = params?.group;\n this._clipGraphic = params?.clipGraphic;\n }\n\n onBind() {\n super.onBind();\n if (this._group && this._clipGraphic) {\n this._lastClip = this._group.attribute.clip;\n this._lastPath = this._group.attribute.path;\n this._group.setAttributes(\n {\n clip: true,\n path: [this._clipGraphic]\n },\n false,\n { type: AttributeUpdateType.ANIMATE_BIND }\n );\n }\n }\n\n onEnd() {\n if (this._group) {\n this._group.setAttributes(\n {\n clip: this._lastClip,\n path: this._lastPath\n },\n false,\n { type: AttributeUpdateType.ANIMATE_END }\n );\n }\n return;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this._clipGraphic) {\n return;\n }\n const res: any = {};\n Object.keys(this.clipFromAttribute).forEach(k => {\n res[k] = this.clipFromAttribute[k] + (this.clipToAttribute[k] - this.clipFromAttribute[k]) * ratio;\n });\n this._clipGraphic.setAttributes(res, false, {\n type: AttributeUpdateType.ANIMATE_UPDATE,\n animationState: { ratio, end }\n });\n }\n}\n\nexport class ClipAngleAnimate extends ClipGraphicAnimate {\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: {\n group: IGroup;\n center?: { x: number; y: number };\n startAngle?: number;\n radius?: number;\n orient?: 'clockwise' | 'anticlockwise';\n animationType?: 'in' | 'out';\n }\n ) {\n const groupAttribute = params?.group?.attribute ?? {};\n const width = groupAttribute.width ?? 0;\n const height = groupAttribute.height ?? 0;\n\n const animationType = params?.animationType ?? 'in';\n const startAngle = params?.startAngle ?? 0;\n const orient = params?.orient ?? 'clockwise';\n\n let arcStartAngle = 0;\n let arcEndAngle = 0;\n if (orient === 'anticlockwise') {\n arcEndAngle = animationType === 'in' ? startAngle + Math.PI * 2 : startAngle;\n arcEndAngle = startAngle + Math.PI * 2;\n } else {\n arcStartAngle = startAngle;\n arcEndAngle = animationType === 'out' ? startAngle + Math.PI * 2 : startAngle;\n }\n const arc = graphicService.creator.arc({\n x: params?.center?.x ?? width / 2,\n y: params?.center?.y ?? height / 2,\n outerRadius: params?.radius ?? (width + height) / 2,\n innerRadius: 0,\n startAngle: arcStartAngle,\n endAngle: arcEndAngle,\n fill: true\n });\n let fromAttributes: Partial<IArcGraphicAttribute>;\n let toAttributes: Partial<IArcGraphicAttribute>;\n if (orient === 'anticlockwise') {\n fromAttributes = { startAngle: startAngle + Math.PI * 2 };\n toAttributes = { startAngle: startAngle };\n } else {\n fromAttributes = { endAngle: startAngle };\n toAttributes = { endAngle: startAngle + Math.PI * 2 };\n }\n super(\n animationType === 'in' ? fromAttributes : toAttributes,\n animationType === 'in' ? toAttributes : fromAttributes,\n duration,\n easing,\n { group: params?.group, clipGraphic: arc }\n );\n }\n}\n\nexport class ClipRadiusAnimate extends ClipGraphicAnimate {\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: {\n group: IGroup;\n center?: { x: number; y: number };\n startRadius?: number;\n endRadius?: number;\n animationType?: 'in' | 'out';\n }\n ) {\n const groupAttribute = params?.group?.attribute ?? {};\n const width = groupAttribute.width ?? 0;\n const height = groupAttribute.height ?? 0;\n\n const animationType = params?.animationType ?? 'in';\n const startRadius = params?.startRadius ?? 0;\n const endRadius = params?.endRadius ?? Math.sqrt((width / 2) ** 2 + (height / 2) ** 2);\n\n const arc = graphicService.creator.arc({\n x: params?.center?.x ?? width / 2,\n y: params?.center?.y ?? height / 2,\n outerRadius: animationType === 'out' ? endRadius : startRadius,\n innerRadius: 0,\n startAngle: 0,\n endAngle: Math.PI * 2,\n fill: true\n });\n const fromAttributes: Partial<IArcGraphicAttribute> = { outerRadius: startRadius };\n const toAttributes: Partial<IArcGraphicAttribute> = { outerRadius: endRadius };\n super(\n animationType === 'in' ? fromAttributes : toAttributes,\n animationType === 'in' ? toAttributes : fromAttributes,\n duration,\n easing,\n { group: params?.group, clipGraphic: arc }\n );\n }\n}\n\nexport class ClipDirectionAnimate extends ClipGraphicAnimate {\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: {\n group: IGroup;\n direction?: 'x' | 'y';\n orient?: 'positive' | 'negative';\n width?: number;\n height?: number;\n animationType?: 'in' | 'out';\n }\n ) {\n const groupAttribute = params?.group?.attribute ?? {};\n const width = params?.width ?? groupAttribute.width ?? 0;\n const height = params?.height ?? groupAttribute.height ?? 0;\n\n const animationType = params?.animationType ?? 'in';\n const direction = params?.direction ?? 'x';\n const orient = params?.orient ?? 'positive';\n\n const rect = graphicService.creator.rect({\n x: 0,\n y: 0,\n width: animationType === 'in' && direction === 'x' ? 0 : width,\n height: animationType === 'in' && direction === 'y' ? 0 : height,\n fill: true\n });\n let fromAttributes: Partial<IRectGraphicAttribute> = {};\n let toAttributes: Partial<IRectGraphicAttribute> = {};\n if (direction === 'y') {\n if (orient === 'negative') {\n fromAttributes = { y: height, height: 0 };\n toAttributes = { y: 0, height: height };\n } else {\n fromAttributes = { height: 0 };\n toAttributes = { height: height };\n }\n } else {\n if (orient === 'negative') {\n fromAttributes = { x: width, width: 0 };\n toAttributes = { x: 0, width: width };\n } else {\n fromAttributes = { width: 0 };\n toAttributes = { width: width };\n }\n }\n super(\n animationType === 'in' ? fromAttributes : toAttributes,\n animationType === 'in' ? toAttributes : fromAttributes,\n duration,\n easing,\n { group: params?.group, clipGraphic: rect }\n );\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentAnimator } from '../component';
|
|
2
|
-
import type
|
|
2
|
+
import { type EasingType, type IAnimateStepType, type ICustomAnimate, type Stage } from '@visactor/vrender-core';
|
|
3
3
|
import { Step } from '../step';
|
|
4
4
|
export declare abstract class ACustomAnimate<T> extends Step implements ICustomAnimate {
|
|
5
5
|
type: IAnimateStepType;
|
|
@@ -20,6 +20,7 @@ export declare abstract class AComponentAnimate<T> extends ACustomAnimate<T> {
|
|
|
20
20
|
export declare abstract class AStageAnimate<T> extends ACustomAnimate<T> {
|
|
21
21
|
willCallBeforeStageRender: boolean;
|
|
22
22
|
willCallAfterStageRender: boolean;
|
|
23
|
+
checkStatusAfterRender: boolean;
|
|
23
24
|
constructor(customFrom: T, customTo: T, duration: number, easing: EasingType, params?: any);
|
|
24
25
|
protected beforeStageRender(stage: Stage, canvas: HTMLCanvasElement): HTMLCanvasElement | void | null | false;
|
|
25
26
|
protected afterStageRender(stage: Stage, canvas: HTMLCanvasElement): HTMLCanvasElement | void | null | false;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AnimateStatus } from "@visactor/vrender-core";
|
|
2
|
+
|
|
1
3
|
import { Step } from "../step";
|
|
2
4
|
|
|
3
5
|
export class ACustomAnimate extends Step {
|
|
@@ -27,7 +29,7 @@ export class AComponentAnimate extends ACustomAnimate {
|
|
|
27
29
|
export class AStageAnimate extends ACustomAnimate {
|
|
28
30
|
constructor(customFrom, customTo, duration, easing, params) {
|
|
29
31
|
super(customFrom, customTo, duration, easing, params), this.willCallBeforeStageRender = !0,
|
|
30
|
-
this.willCallAfterStageRender = !0, this._beforeStageRender = () => {
|
|
32
|
+
this.willCallAfterStageRender = !0, this.checkStatusAfterRender = !0, this._beforeStageRender = () => {
|
|
31
33
|
if (!this.willCallBeforeStageRender) return;
|
|
32
34
|
this.willCallBeforeStageRender = !1;
|
|
33
35
|
const stage = this.target.stage, canvas = stage.window.getContext().canvas.nativeCanvas, outputCanvas = this.beforeStageRender(stage, canvas);
|
|
@@ -36,7 +38,7 @@ export class AStageAnimate extends ACustomAnimate {
|
|
|
36
38
|
if (!this.willCallAfterStageRender) return;
|
|
37
39
|
this.willCallAfterStageRender = !1;
|
|
38
40
|
const stage = this.target.stage, canvas = stage.window.getContext().canvas.nativeCanvas, outputCanvas = this.afterStageRender(stage, canvas);
|
|
39
|
-
outputCanvas && this.renderToStage(stage, outputCanvas);
|
|
41
|
+
outputCanvas && this.renderToStage(stage, outputCanvas), this.checkStatusAfterRender && this.animate.status === AnimateStatus.END && this.animate.timeline.removeAnimate(this.animate);
|
|
40
42
|
}, this.props = {};
|
|
41
43
|
}
|
|
42
44
|
beforeStageRender(stage, canvas) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/custom/custom-animate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/custom/custom-animate.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAKd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,OAAgB,cAAkB,SAAQ,IAAI;IAUlD,YAAY,UAAa,EAAE,QAAW,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAAY;QACxF,KAAK,CAAC,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAVrD,SAAI,GAAqB,eAAe,CAAC;QAWvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAE1D,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACjC,OAAO;SACR;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QACpC,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B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,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC;IACzC,CAAC;IAED,IAAI;QACF,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC9D,CAAC;IACD,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC;IACvC,CAAC;IAgCS,aAAa,CAAC,KAAY,EAAE,MAAyB;QAC7D,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC;QAClE,MAAM,GAAG,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,KAAK,CAAC;SACd;QACD,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3D,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,OAAO,WAAW,CAAC;IACrB,CAAC;CACF","file":"custom-animate.js","sourcesContent":["import type { ComponentAnimator } from '../component';\nimport {\n AnimateStatus,\n type EasingType,\n type IAnimateStepType,\n type ICustomAnimate,\n type Stage\n} from '@visactor/vrender-core';\nimport { Step } from '../step';\n\nexport abstract class ACustomAnimate<T> extends Step implements ICustomAnimate {\n type: IAnimateStepType = 'customAnimate';\n declare customFrom: T;\n declare params?: any;\n declare props?: T;\n declare from?: T;\n declare to?: T;\n\n // 为了兼容旧的api,from和to是可选的,且尽量不需要From,因为为了避免突变,From都应该从当前位置开始\n // 所以From并不会真正设置到fromProps中,而是作为customFrom参数\n constructor(customFrom: T, customTo: T, duration: number, easing: EasingType, params?: any) {\n super('customAnimate', customTo, duration, easing);\n this.customFrom = customFrom;\n this.params = params;\n this.from = customFrom;\n this.to = customTo;\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n // TODO 需要修复,只有在开始的时候才调用\n this.onStart();\n if (!this.props || !this.propKeys) {\n return;\n }\n // 应用缓动函数\n const easedRatio = this.easing(ratio);\n this.onUpdate(end, easedRatio, out);\n this.syncAttributeUpdate();\n }\n\n protected setProps(props: T) {\n this.props = props;\n this.propKeys = Object.keys(props);\n this.animate.reSyncProps();\n }\n}\n\nexport abstract class AComponentAnimate<T> extends ACustomAnimate<T> {\n protected _animator: ComponentAnimator;\n\n completeBind(animator: ComponentAnimator): void {\n this.setStartTime(0);\n this._animator && this._animator.start();\n this.setDuration(animator.getDuration());\n }\n\n stop(): void {\n this._animator && this._animator.stop();\n }\n}\n\nexport abstract class AStageAnimate<T> extends ACustomAnimate<T> {\n willCallBeforeStageRender: boolean = true;\n willCallAfterStageRender: boolean = true;\n checkStatusAfterRender: boolean = true;\n constructor(customFrom: T, customTo: T, duration: number, easing: EasingType, params?: any) {\n super(customFrom, customTo, duration, easing, params);\n this.props = {} as T;\n }\n\n // 用户重载\n protected beforeStageRender(stage: Stage, canvas: HTMLCanvasElement): HTMLCanvasElement | void | null | false {\n return false;\n }\n\n // 用户重载\n protected afterStageRender(stage: Stage, canvas: HTMLCanvasElement): HTMLCanvasElement | void | null | false {\n return false;\n }\n\n onFirstRun(): void {\n super.onFirstRun();\n this.target.stage.setBeforeRender(this._beforeStageRender);\n this.target.stage.setAfterRender(this._afterStageRender);\n // 禁用脏矩形,因为stage动画可能会批量修改整体画面\n this.target.stage.disableDirtyBounds();\n }\n\n stop() {\n super.stop();\n this.target.stage.removeBeforeRender(this._beforeStageRender);\n this.target.stage.removeAfterRender(this._afterStageRender);\n }\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n super.onUpdate(end, ratio, out);\n this.willCallBeforeStageRender = true;\n this.willCallAfterStageRender = true;\n }\n\n protected _beforeStageRender = () => {\n if (!this.willCallBeforeStageRender) {\n return;\n }\n this.willCallBeforeStageRender = false;\n const stage = this.target.stage as any;\n const canvas = stage.window.getContext().canvas.nativeCanvas;\n const outputCanvas = this.beforeStageRender(stage, canvas);\n if (outputCanvas) {\n this.renderToStage(stage, outputCanvas);\n }\n };\n\n protected _afterStageRender = () => {\n if (!this.willCallAfterStageRender) {\n return;\n }\n this.willCallAfterStageRender = false;\n const stage = this.target.stage as any;\n const canvas = stage.window.getContext().canvas.nativeCanvas;\n const outputCanvas = this.afterStageRender(stage, canvas);\n if (outputCanvas) {\n this.renderToStage(stage, outputCanvas);\n }\n // 检查是否需要移除动画\n if (this.checkStatusAfterRender && this.animate.status === AnimateStatus.END) {\n this.animate.timeline.removeAnimate(this.animate);\n }\n };\n\n protected renderToStage(stage: Stage, canvas: HTMLCanvasElement): HTMLCanvasElement | void | null | false {\n const stageCanvas = stage.window.getContext().canvas.nativeCanvas;\n const ctx = stageCanvas.getContext('2d');\n if (!ctx) {\n return false;\n }\n ctx.clearRect(0, 0, stageCanvas.width, stageCanvas.height);\n ctx.drawImage(canvas, 0, 0);\n return stageCanvas;\n }\n}\n"]}
|