@visactor/vrender-animate 1.0.6-alpha.0 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/animate-extension.d.ts +3 -0
- package/cjs/animate-extension.js +15 -0
- package/cjs/animate-extension.js.map +1 -1
- package/cjs/custom/growCenter.js +2 -2
- package/cjs/custom/growCenter.js.map +1 -1
- package/cjs/custom/growHeight.js +2 -2
- package/cjs/custom/growHeight.js.map +1 -1
- package/cjs/state/animation-state.d.ts +1 -0
- package/cjs/state/animation-state.js +5 -0
- package/cjs/state/animation-state.js.map +1 -1
- package/cjs/state/graphic-extension.d.ts +2 -1
- package/cjs/state/graphic-extension.js +9 -2
- package/cjs/state/graphic-extension.js.map +1 -1
- package/dist/index.es.js +55 -5
- package/es/animate-extension.d.ts +3 -0
- package/es/animate-extension.js +15 -0
- package/es/animate-extension.js.map +1 -1
- package/es/custom/growCenter.js +2 -2
- package/es/custom/growCenter.js.map +1 -1
- package/es/custom/growHeight.js +2 -2
- package/es/custom/growHeight.js.map +1 -1
- package/es/state/animation-state.d.ts +1 -0
- package/es/state/animation-state.js +5 -0
- package/es/state/animation-state.js.map +1 -1
- package/es/state/graphic-extension.d.ts +2 -1
- package/es/state/graphic-extension.js +9 -2
- package/es/state/graphic-extension.js.map +1 -1
- package/package.json +4 -4
|
@@ -19,4 +19,7 @@ export declare class AnimateExtension {
|
|
|
19
19
|
executeAnimations(configs: IAnimationConfig[]): this;
|
|
20
20
|
protected getFinalAttribute(): Record<string, any>;
|
|
21
21
|
getGraphicAttribute(key: string, prev?: boolean): any;
|
|
22
|
+
pauseAnimation(deep?: boolean): void;
|
|
23
|
+
resumeAnimation(deep?: boolean): void;
|
|
24
|
+
stopAnimation(deep?: boolean): void;
|
|
22
25
|
}
|
package/cjs/animate-extension.js
CHANGED
|
@@ -49,6 +49,21 @@ class AnimateExtension {
|
|
|
49
49
|
getGraphicAttribute(key, prev = !1) {
|
|
50
50
|
return !prev && this.finalAttribute ? this.finalAttribute[key] : this.attribute[key];
|
|
51
51
|
}
|
|
52
|
+
pauseAnimation(deep = !1) {
|
|
53
|
+
this.animates && this.animates.forEach((animate => animate.pause())), deep && this.isContainer && this.forEachChildren((child => {
|
|
54
|
+
child.pauseAnimation(deep);
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
resumeAnimation(deep = !1) {
|
|
58
|
+
this.animates && this.animates.forEach((animate => animate.resume())), deep && this.isContainer && this.forEachChildren((child => {
|
|
59
|
+
child.resumeAnimation(deep);
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
stopAnimation(deep = !1) {
|
|
63
|
+
this.animates && this.animates.forEach((animate => animate.stop())), deep && this.isContainer && this.forEachChildren((child => {
|
|
64
|
+
child.stopAnimation(deep);
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
52
67
|
}
|
|
53
68
|
|
|
54
69
|
exports.AnimateExtension = AnimateExtension;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/animate-extension.ts"],"names":[],"mappings":";;;AAQA,uCAAoC;AACpC,yCAA8D;AAC9D,4DAAwD;AAExD,kEAA8D;AAG9D,MAAa,gBAAgB;IAM3B,aAAa,CAAC,QAAiB,KAAK;QAClC,IAAI,KAAK,IAAI,IAAI,CAAC,cAAc,EAAE;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC;SAC5B;QACD,OAAQ,IAAY,CAAC,SAAS,CAAC;IACjC,CAAC;IAED,OAAO,CAAC,MAA8B;;QACpC,MAAM,OAAO,GAAG,IAAI,iBAAO,CACzB,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE,EACV,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,mCAAI,CAAE,IAAY,CAAC,KAAK,IAAK,IAAY,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,mCAAI,0BAAe,EACjG,MAAM,aAAN,MAAM,uBAAN,MAAM,C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CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAClE,IAAI,IAAI,IAAK,IAAY,CAAC,WAAW,EAAE;YACpC,IAAY,CAAC,eAAe,CAAC,CAAC,KAAU,EAAE,EAAE;gBAC3C,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;CACF;AAzHD,4CAyHC","file":"animate-extension.js","sourcesContent":["// 1. 支持animate函数\n// 2. 支持animates map\n// 2. 支持animatedAttribute 为所有动画的最终结果(loop为INFINITY的动画不算)\n// 3. 支持finalAttribute 为所有动画的最终结果(animatedAttribute 合并了 graphic.attribute之后的最终结果)\n// 3. 重载Graphic的getAttributes方法,根据参数getAttributes(final = true)返回finalAttribute = {}; merge(finalAttribute, graphic.attribute, animatedAttribute),\n// animatedAttribute为所有动画的最终结果(loop为INFINITY的动画不算)\n\nimport type { IGraphicAnimateParams, IAnimate } from '@visactor/vrender-core';\nimport { Animate } from './animate';\nimport { DefaultTimeline, defaultTimeline } from './timeline';\nimport { DefaultTicker } from './ticker/default-ticker';\nimport type { IAnimationConfig } from './executor/executor';\nimport { AnimateExecutor } from './executor/animate-executor';\n\n// 基于性能考虑,每次调用animate函数,都会设置animatedAttribute为null,每次getAttributes(true)会根据animatedAttribute属性判断是否需要重新计算animatedAttribute。\nexport class AnimateExtension {\n declare finalAttribute: Record<string, any>;\n _animateExecutor: AnimateExecutor | null;\n\n declare animates: Map<string | number, IAnimate>;\n\n getAttributes(final: boolean = false) {\n if (final && this.finalAttribute) {\n return this.finalAttribute;\n }\n return (this as any).attribute;\n }\n\n animate(params?: IGraphicAnimateParams) {\n const animate = new Animate(\n params?.id,\n params?.timeline ?? ((this as any).stage && (this as any).stage.getTimeline()) ?? defaultTimeline,\n params?.slience\n );\n\n animate.bind(this as any);\n if (params) {\n const { onStart, onEnd, onRemove } = params;\n onStart != null && animate.onStart(onStart);\n onEnd != null && animate.onEnd(onEnd);\n onRemove != null && animate.onRemove(onRemove);\n }\n\n // TODO 考虑性能问题\n (this as any).stage?.ticker.start();\n\n return animate;\n }\n\n createTimeline() {\n return new DefaultTimeline();\n }\n\n createTicker(stage: any) {\n return new DefaultTicker(stage);\n }\n\n setFinalAttributes(finalAttribute: Record<string, any>) {\n if (!this.finalAttribute) {\n this.finalAttribute = {};\n }\n Object.assign(this.finalAttribute, finalAttribute);\n }\n\n initFinalAttributes(finalAttribute: Record<string, any>) {\n this.finalAttribute = finalAttribute;\n }\n\n initAnimateExecutor(): void {\n if (!this._animateExecutor) {\n this._animateExecutor = new AnimateExecutor(this as any);\n }\n }\n\n /**\n * Apply animation configuration to the component\n * @param config Animation configuration\n * @returns This component instance\n */\n executeAnimation(config: IAnimationConfig): this {\n this.initAnimateExecutor();\n this._animateExecutor.execute(config);\n return this;\n }\n\n /**\n * Apply animations to multiple components\n * @param configs Animation configurations\n * @returns This component instance\n */\n executeAnimations(configs: IAnimationConfig[]): this {\n this.initAnimateExecutor();\n configs.forEach(config => {\n this._animateExecutor.execute(config);\n });\n return this;\n }\n\n protected getFinalAttribute() {\n return this.finalAttribute;\n }\n\n // TODO prev是兼容原本VGrammar函数的一个参数,用于动画中获取上一次属性,目前的逻辑中应该不需要,直接去当前帧的属性即可\n getGraphicAttribute(key: string, prev: boolean = false) {\n if (!prev && this.finalAttribute) {\n return this.finalAttribute[key];\n }\n return (this as any).attribute[key];\n }\n\n pauseAnimation(deep: boolean = false) {\n this.animates && this.animates.forEach(animate => animate.pause());\n if (deep && (this as any).isContainer) {\n (this as any).forEachChildren((child: any) => {\n child.pauseAnimation(deep);\n });\n }\n }\n\n resumeAnimation(deep: boolean = false) {\n this.animates && this.animates.forEach(animate => animate.resume());\n if (deep && (this as any).isContainer) {\n (this as any).forEachChildren((child: any) => {\n child.resumeAnimation(deep);\n });\n }\n }\n\n stopAnimation(deep: boolean = false) {\n this.animates && this.animates.forEach(animate => animate.stop());\n if (deep && (this as any).isContainer) {\n (this as any).forEachChildren((child: any) => {\n child.stopAnimation(deep);\n });\n }\n }\n}\n"]}
|
package/cjs/custom/growCenter.js
CHANGED
|
@@ -121,13 +121,13 @@ class GrowCenterIn extends custom_animate_1.ACustomAnimate {
|
|
|
121
121
|
super(from, to, duration, easing, params);
|
|
122
122
|
}
|
|
123
123
|
onBind() {
|
|
124
|
-
var _a, _b;
|
|
124
|
+
var _a, _b, _c;
|
|
125
125
|
super.onBind();
|
|
126
126
|
const {from: from, to: to} = growCenterIn(this.target, this.params.options, this.params), fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
|
|
127
127
|
this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
|
|
128
128
|
this.from = fromAttrs, this.to = to;
|
|
129
129
|
const finalAttribute = this.target.getFinalAttribute();
|
|
130
|
-
finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
|
|
130
|
+
finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
|
|
131
131
|
}
|
|
132
132
|
onEnd(cb) {
|
|
133
133
|
super.onEnd(cb);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/custom/growCenter.ts"],"names":[],"mappings":";;;AACA,6CAA2C;AAC3C,qDAAkD;AAuBlD,MAAM,YAAY,GAA4B,CAC5C,OAAiB,EACjB,OAAuC,EACvC,mBAAyC,EACzC,EAAE;IACF,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC1C,QAAQ,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAE;QAC1B,KAAK,GAAG,CAAC,CAAC;YACR,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YAClB,MAAM,EAAE,GAAG,KAAK,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,EAAE,CAAC;IAEf,CAAC;IAED,KAAK,CAAC,EAA6C;QACjD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,MAAM,SAAS,GAAwB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QAC7D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAC5E,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,0BAA0B,EAAE,CAAC;IAC3C,CAAC;CACF;AA9BD,sCA8BC","file":"growCenter.js","sourcesContent":["import type { IGraphic, IGroup, IAnimate, IStep, EasingType } from '@visactor/vrender-core';\nimport { isValid } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ninterface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\ntype TypeAnimation<T extends IGraphic> = (\n graphic: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nconst growCenterIn: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.getFinalAttribute();\n switch (options?.direction) {\n case 'x': {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n\n return {\n from: isValid(width)\n ? {\n x: x + width / 2,\n x1: undefined,\n width: 0\n }\n : {\n x: (x + x1) / 2,\n x1: (x + x1) / 2,\n width: undefined\n },\n to: { x, x1, width }\n };\n }\n case 'y': {\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n return {\n from: isValid(height)\n ? {\n y: y + height / 2,\n y1: undefined,\n height: 0\n }\n : {\n y: (y + y1) / 2,\n y1: (y + y1) / 2,\n height: undefined\n },\n to: { y, y1, height }\n };\n }\n case 'xy':\n default: {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n const from: any = {};\n\n if (isValid(width)) {\n from.x = x + width / 2;\n from.width = 0;\n from.x1 = undefined;\n } else {\n from.x = (x + x1) / 2;\n from.x1 = (x + x1) / 2;\n from.width = undefined;\n }\n\n if (isValid(height)) {\n from.y = y + height / 2;\n from.height = 0;\n from.y1 = undefined;\n } else {\n from.y = (y + y1) / 2;\n from.y1 = (y + y1) / 2;\n from.height = undefined;\n }\n\n return {\n from,\n to: { x, y, x1, y1, width, height }\n };\n }\n }\n};\n\nconst growCenterOut: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.attribute as any;\n switch (options?.direction) {\n case 'x': {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n\n return {\n to: isValid(width)\n ? {\n x: x + width / 2,\n x1: undefined,\n width: 0\n }\n : {\n x: (x + x1) / 2,\n x1: (x + x1) / 2,\n width: undefined\n }\n };\n }\n case 'y': {\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n return {\n to: isValid(height)\n ? {\n y: y + height / 2,\n y1: undefined,\n height: 0\n }\n : {\n y: (y + y1) / 2,\n y1: (y + y1) / 2,\n height: undefined\n }\n };\n }\n case 'xy':\n default: {\n const x = attrs.x;\n const y = attrs.y;\n const x1 = attrs.x1;\n const y1 = attrs.y1;\n const width = attrs.width;\n const height = attrs.height;\n const to: any = {};\n\n if (isValid(width)) {\n to.x = x + width / 2;\n to.width = 0;\n to.x1 = undefined;\n } else {\n to.x = (x + x1) / 2;\n to.x1 = (x + x1) / 2;\n to.width = undefined;\n }\n\n if (isValid(height)) {\n to.y = y + height / 2;\n to.height = 0;\n to.y1 = undefined;\n } else {\n to.y = (y + y1) / 2;\n to.y1 = (y + y1) / 2;\n to.height = undefined;\n }\n\n return {\n to\n };\n }\n }\n};\n\n/**\n * 增长渐入\n */\nexport class GrowCenterIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growCenterIn(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context?.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = fromAttrs;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n this.target.setAttributes(fromAttrs);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\nexport class GrowCenterOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growCenterOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n\n this.from = from ?? (this.target.attribute as any);\n this.to = to;\n // this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/custom/growCenter.ts"],"names":[],"mappings":";;;AACA,6CAA2C;AAC3C,qDAAkD;AAuBlD,MAAM,YAAY,GAA4B,CAC5C,OAAiB,EACjB,OAAuC,EACvC,mBAAyC,EACzC,EAAE;IACF,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC1C,QAAQ,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAE;QAC1B,KAAK,GAAG,CAAC,CAAC;YACR,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YAClB,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YAE1B,OAAO;gBACL,IAAI,EAAE,IAAA,gBAAO,EAAC,KAAK,CAAC;oBAClB,CAAC,CAAC;wBACE,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC;wBAChB,EAAE,EAAE,SAAS;wBACb,KAAK,EAAE,CAAC;qBACT;oBACH,CAAC,CAAC;wBACE,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC;wBACf,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC;wBAChB,KAAK,EAAE,SAAS;qBACjB;gBACL,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE;aACrB,CAAC;SACH;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,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAC5E,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,0BAA0B,EAAE,CAAC;IAC3C,CAAC;CACF;AA9BD,sCA8BC","file":"growCenter.js","sourcesContent":["import type { IGraphic, IGroup, IAnimate, IStep, EasingType } from '@visactor/vrender-core';\nimport { isValid } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ninterface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\ntype TypeAnimation<T extends IGraphic> = (\n graphic: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nconst growCenterIn: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.getFinalAttribute();\n switch (options?.direction) {\n case 'x': {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n\n return {\n from: isValid(width)\n ? {\n x: x + width / 2,\n x1: undefined,\n width: 0\n }\n : {\n x: (x + x1) / 2,\n x1: (x + x1) / 2,\n width: undefined\n },\n to: { x, x1, width }\n };\n }\n case 'y': {\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n return {\n from: isValid(height)\n ? {\n y: y + height / 2,\n y1: undefined,\n height: 0\n }\n : {\n y: (y + y1) / 2,\n y1: (y + y1) / 2,\n height: undefined\n },\n to: { y, y1, height }\n };\n }\n case 'xy':\n default: {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n const from: any = {};\n\n if (isValid(width)) {\n from.x = x + width / 2;\n from.width = 0;\n from.x1 = undefined;\n } else {\n from.x = (x + x1) / 2;\n from.x1 = (x + x1) / 2;\n from.width = undefined;\n }\n\n if (isValid(height)) {\n from.y = y + height / 2;\n from.height = 0;\n from.y1 = undefined;\n } else {\n from.y = (y + y1) / 2;\n from.y1 = (y + y1) / 2;\n from.height = undefined;\n }\n\n return {\n from,\n to: { x, y, x1, y1, width, height }\n };\n }\n }\n};\n\nconst growCenterOut: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.attribute as any;\n switch (options?.direction) {\n case 'x': {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n\n return {\n to: isValid(width)\n ? {\n x: x + width / 2,\n x1: undefined,\n width: 0\n }\n : {\n x: (x + x1) / 2,\n x1: (x + x1) / 2,\n width: undefined\n }\n };\n }\n case 'y': {\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n return {\n to: isValid(height)\n ? {\n y: y + height / 2,\n y1: undefined,\n height: 0\n }\n : {\n y: (y + y1) / 2,\n y1: (y + y1) / 2,\n height: undefined\n }\n };\n }\n case 'xy':\n default: {\n const x = attrs.x;\n const y = attrs.y;\n const x1 = attrs.x1;\n const y1 = attrs.y1;\n const width = attrs.width;\n const height = attrs.height;\n const to: any = {};\n\n if (isValid(width)) {\n to.x = x + width / 2;\n to.width = 0;\n to.x1 = undefined;\n } else {\n to.x = (x + x1) / 2;\n to.x1 = (x + x1) / 2;\n to.width = undefined;\n }\n\n if (isValid(height)) {\n to.y = y + height / 2;\n to.height = 0;\n to.y1 = undefined;\n } else {\n to.y = (y + y1) / 2;\n to.y1 = (y + y1) / 2;\n to.height = undefined;\n }\n\n return {\n to\n };\n }\n }\n};\n\n/**\n * 增长渐入\n */\nexport class GrowCenterIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growCenterIn(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context?.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = fromAttrs;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n if (this.params.controlOptions?.immediatelyApply !== false) {\n this.target.setAttributes(fromAttrs);\n }\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\nexport class GrowCenterOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growCenterOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n\n this.from = from ?? (this.target.attribute as any);\n this.to = to;\n // this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n"]}
|
package/cjs/custom/growHeight.js
CHANGED
|
@@ -69,13 +69,13 @@ class GrowHeightIn extends custom_animate_1.ACustomAnimate {
|
|
|
69
69
|
super(from, to, duration, easing, params);
|
|
70
70
|
}
|
|
71
71
|
onBind() {
|
|
72
|
-
var _a, _b;
|
|
72
|
+
var _a, _b, _c;
|
|
73
73
|
super.onBind();
|
|
74
74
|
const {from: from, to: to} = growHeightIn(this.target, this.params.options, this.params), fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
|
|
75
75
|
this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
|
|
76
76
|
this.from = fromAttrs, this.to = to;
|
|
77
77
|
const finalAttribute = this.target.getFinalAttribute();
|
|
78
|
-
finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
|
|
78
|
+
finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
|
|
79
79
|
}
|
|
80
80
|
onEnd(cb) {
|
|
81
81
|
super.onEnd(cb);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/custom/growHeight.ts"],"names":[],"mappings":";;;AACA,6CAA4D;AAC5D,qDAAkD;AAwBlD,SAAS,sBAAsB,CAC7B,OAAiB,EACjB,OAAuC,EACvC,mBAAyC;IAEzC,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC1C,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAClB,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IACpB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAE5B,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE;QAC5C,MAAM,UAAU,GAAG,IAAA,gBAAO,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CA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isValid } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ninterface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n layoutRect?: { width: number; height: number };\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\ntype TypeAnimation<T extends IGraphic> = (\n graphic: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nfunction growHeightInIndividual(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n if (options && options.orient === 'negative') {\n const computedY1 = isValid(height) ? Math.max(y, y + height) : Math.max(y, y1);\n return {\n from: { y: computedY1, y1: isNil(y1) ? undefined : computedY1, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n }\n\n const computedY = isValid(height) ? Math.min(y, y + height) : Math.min(y, y1);\n return {\n from: { y: computedY, y1: isNil(y1) ? undefined : computedY, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n}\n\nfunction growHeightInOverall(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n let overallValue: number;\n if (options && options.orient === 'negative') {\n if (isNumber(options.overall)) {\n overallValue = options.overall;\n } else if (animationParameters.group) {\n overallValue =\n (animationParameters as any).groupHeight ??\n options.layoutRect?.height ??\n animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = overallValue;\n } else {\n overallValue = animationParameters.height;\n }\n } else {\n overallValue = isNumber(options?.overall) ? options.overall : 0;\n }\n return {\n from: { y: overallValue, y1: isNil(y1) ? undefined : overallValue, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n}\n\nconst growHeightIn: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growHeightInOverall(graphic, options, animationParameters)\n : growHeightInIndividual(graphic, options, animationParameters);\n};\n\n/**\n * 增长渐入\n */\nexport class GrowHeightIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growHeightIn(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context?.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = fromAttrs;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n this.target.setAttributes(fromAttrs);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\nfunction growHeightOutIndividual(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n if (options && options.orient === 'negative') {\n const computedY1 = isValid(height) ? Math.max(y, y + height) : Math.max(y, y1);\n\n return {\n to: { y: computedY1, y1: isNil(y1) ? undefined : computedY1, height: isNil(height) ? undefined : 0 }\n };\n }\n\n const computedY = isValid(height) ? Math.min(y, y + height) : Math.min(y, y1);\n return {\n to: { y: computedY, y1: isNil(y1) ? undefined : computedY, height: isNil(height) ? undefined : 0 }\n };\n}\n\nfunction growHeightOutOverall(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y1 = attrs.y1;\n const height = attrs.height;\n\n let overallValue: number;\n if (options && options.orient === 'negative') {\n if (isNumber(options.overall)) {\n overallValue = options.overall;\n } else if (animationParameters.group) {\n overallValue =\n (animationParameters as any).groupHeight ??\n options.layoutRect?.height ??\n animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = overallValue;\n } else {\n overallValue = animationParameters.height;\n }\n } else {\n overallValue = isNumber(options?.overall) ? options.overall : 0;\n }\n return {\n to: { y: overallValue, y1: isNil(y1) ? undefined : overallValue, height: isNil(height) ? undefined : 0 }\n };\n}\n\n/**\n * 增长渐出\n */\nexport const growHeightOut: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growHeightOutOverall(graphic, options, animationParameters)\n : growHeightOutIndividual(graphic, options, animationParameters);\n};\n\nexport class GrowHeightOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growHeightOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = from ?? (this.target.attribute as any);\n this.to = to;\n // this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/custom/growHeight.ts"],"names":[],"mappings":";;;AACA,6CAA4D;AAC5D,qDAAkD;AAwBlD,SAAS,sBAAsB,CAC7B,OAAiB,EACjB,OAAuC,EACvC,mBAAyC;IAEzC,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC1C,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAClB,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IACpB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAE5B,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE;QAC5C,MAAM,UAAU,GAAG,IAAA,gBAAO,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/E,OAAO;YACL,IAAI,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,IAAA,cAAK,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,IAAA,cAAK,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE;YACtG,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;SACrC,CAAC;KACH;IAED,MAAM,SAAS,GAAG,IAAA,gBAAO,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CA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E,CAAC;IAEf,CAAC;IAED,KAAK,CAAC,EAA6C;QACjD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,MAAM,SAAS,GAAwB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QAC7D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAC5E,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,0BAA0B,EAAE,CAAC;IAC3C,CAAC;CACF;AA7BD,sCA6BC","file":"growHeight.js","sourcesContent":["import type { IGraphic, IGroup, IAnimate, IStep, EasingType } from '@visactor/vrender-core';\nimport { isNil, isNumber, isValid } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ninterface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n layoutRect?: { width: number; height: number };\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\ntype TypeAnimation<T extends IGraphic> = (\n graphic: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nfunction growHeightInIndividual(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n if (options && options.orient === 'negative') {\n const computedY1 = isValid(height) ? Math.max(y, y + height) : Math.max(y, y1);\n return {\n from: { y: computedY1, y1: isNil(y1) ? undefined : computedY1, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n }\n\n const computedY = isValid(height) ? Math.min(y, y + height) : Math.min(y, y1);\n return {\n from: { y: computedY, y1: isNil(y1) ? undefined : computedY, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n}\n\nfunction growHeightInOverall(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n let overallValue: number;\n if (options && options.orient === 'negative') {\n if (isNumber(options.overall)) {\n overallValue = options.overall;\n } else if (animationParameters.group) {\n overallValue =\n (animationParameters as any).groupHeight ??\n options.layoutRect?.height ??\n animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = overallValue;\n } else {\n overallValue = animationParameters.height;\n }\n } else {\n overallValue = isNumber(options?.overall) ? options.overall : 0;\n }\n return {\n from: { y: overallValue, y1: isNil(y1) ? undefined : overallValue, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n}\n\nconst growHeightIn: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growHeightInOverall(graphic, options, animationParameters)\n : growHeightInIndividual(graphic, options, animationParameters);\n};\n\n/**\n * 增长渐入\n */\nexport class GrowHeightIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growHeightIn(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context?.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = fromAttrs;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n if (this.params.controlOptions?.immediatelyApply !== false) {\n this.target.setAttributes(fromAttrs);\n }\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\nfunction growHeightOutIndividual(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n if (options && options.orient === 'negative') {\n const computedY1 = isValid(height) ? Math.max(y, y + height) : Math.max(y, y1);\n\n return {\n to: { y: computedY1, y1: isNil(y1) ? undefined : computedY1, height: isNil(height) ? undefined : 0 }\n };\n }\n\n const computedY = isValid(height) ? Math.min(y, y + height) : Math.min(y, y1);\n return {\n to: { y: computedY, y1: isNil(y1) ? undefined : computedY, height: isNil(height) ? undefined : 0 }\n };\n}\n\nfunction growHeightOutOverall(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y1 = attrs.y1;\n const height = attrs.height;\n\n let overallValue: number;\n if (options && options.orient === 'negative') {\n if (isNumber(options.overall)) {\n overallValue = options.overall;\n } else if (animationParameters.group) {\n overallValue =\n (animationParameters as any).groupHeight ??\n options.layoutRect?.height ??\n animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = overallValue;\n } else {\n overallValue = animationParameters.height;\n }\n } else {\n overallValue = isNumber(options?.overall) ? options.overall : 0;\n }\n return {\n to: { y: overallValue, y1: isNil(y1) ? undefined : overallValue, height: isNil(height) ? undefined : 0 }\n };\n}\n\n/**\n * 增长渐出\n */\nexport const growHeightOut: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growHeightOutOverall(graphic, options, animationParameters)\n : growHeightOutIndividual(graphic, options, animationParameters);\n};\n\nexport class GrowHeightOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growHeightOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = from ?? (this.target.attribute as any);\n this.to = to;\n // this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n"]}
|
|
@@ -39,5 +39,6 @@ export declare class AnimationStateManager {
|
|
|
39
39
|
applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): void;
|
|
40
40
|
stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void;
|
|
41
41
|
clearState(): void;
|
|
42
|
+
reApplyState(state: string): void;
|
|
42
43
|
}
|
|
43
44
|
export {};
|
|
@@ -118,6 +118,11 @@ class AnimationStateManager {
|
|
|
118
118
|
state.executor.stop();
|
|
119
119
|
})), this.stateList = null;
|
|
120
120
|
}
|
|
121
|
+
reApplyState(state) {
|
|
122
|
+
var _a;
|
|
123
|
+
const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find((stateInfo => stateInfo.state === state));
|
|
124
|
+
stateInfo && (stateInfo.executor.stop(), stateInfo.executor.execute(stateInfo.animationConfig));
|
|
125
|
+
}
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
exports.AnimationStateManager = AnimationStateManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/animation-state.ts"],"names":[],"mappings":";;;AAEA,2EAA0E;AAE1E,mEAA+D;AAC/D,6CAA2C;AAG9B,QAAA,eAAe,GAAG;IAC7B,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,aAAa;IAC1B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAa,mBAAmB;IAG9B,YAAY,OAAiB;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAMD,aAAa,CAAC,KAAsB;QAClC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,WAAW;;QACT,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AArBD,kDAqBC;AASD,MAAa,qBAAqB;IAOhC,YAAY,OAAiB;QAF7B,cAAS,GAAwB,IAAI,CAAC;QAGpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IASD,UAAU,CACR,SAAmB,EACnB,eAAw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nimationState } from './types';\nimport { AnimationTransitionRegistry } from './animation-states-registry';\nimport type { IAnimationConfig } from '../executor/executor';\nimport { AnimateExecutor } from '../executor/animate-executor';\nimport { isArray } from '@visactor/vutils';\n\n// Standard animation state names\nexport const AnimationStates = {\n APPEAR: 'appear',\n DISAPPEAR: 'disappear',\n UPDATE: 'update',\n HIGHLIGHT: 'highlight',\n UNHIGHLIGHT: 'unhighlight',\n SELECT: 'select',\n UNSELECT: 'unselect',\n HOVER: 'hover',\n UNHOVER: 'unhover',\n ACTIVE: 'active',\n INACTIVE: 'inactive'\n};\n\nexport class AnimationStateStore {\n graphic: IGraphic;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // 动画状态配置\n // 并不是所有图元都有(只有mark才有),所以在应用状态的时候,需要额外传入\n states?: Map<string, IAnimationState>;\n\n registerState(state: IAnimationState): void {\n if (!this.states) {\n this.states = new Map();\n }\n this.states.set(state.name, state);\n }\n\n clearStates(): void {\n this.states?.clear();\n }\n}\n\n// 一个状态对应一个执行器,每个图元都有一一对应\ninterface IStateInfo {\n state: string;\n animationConfig: IAnimationConfig | IAnimationConfig[];\n executor: AnimateExecutor;\n}\n\nexport class AnimationStateManager {\n protected graphic: IGraphic;\n\n // 当前状态\n // TODO(注意,这里无法了解动画的顺序,既有串行也有并行,具体在执行的时候确定,执行之后就无法获取串行或并行配置了)\n stateList: IStateInfo[] | null = null;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // TODO 这里因为只有状态变更才会调用,所以代码写的比较宽松,如果有性能问题需要优化\n /**\n * 应用状态\n * @param nextState 下一个状态数组,如果传入数组,那么状态是串行的。但是每次applyState都会立即执行动画,也就是applyState和applyState之间是并行\n * @param animationConfig 动画配置\n * @param callback 动画结束后的回调函数,参数empty为true表示没有动画需要执行直接调的回调\n */\n applyState(\n nextState: string[],\n animationConfig: (IAnimationState | IAnimationState[])[],\n callback?: (empty?: boolean) => void\n ): void {\n const registry = AnimationTransitionRegistry.getInstance();\n\n // TODO 这里指判断第一个状态,后续如果需要的话要循环判断\n // 检查是否需要停止当前状态,以及下一个状态是否需要应用\n const shouldStopState: IStateInfo[] = [];\n const shouldApplyState: IStateInfo[] = [];\n if (!(this.stateList && this.stateList.length)) {\n nextState.forEach((state, index) => {\n shouldApplyState.push({\n state,\n animationConfig: isArray(animationConfig[index])\n ? (animationConfig[index] as IAnimationState[]).map(item => item.animation)\n : (animationConfig[index] as IAnimationState).animation,\n executor: new AnimateExecutor(this.graphic)\n });\n });\n } else {\n // const _stateList = this.stateList[0];\n nextState.forEach((state, index) => {\n // 遍历this.stateList,获取result,只要有一个是false,那这个result就是false\n const result: { allowTransition: boolean; stopOriginalTransition: boolean } = {\n allowTransition: true,\n stopOriginalTransition: true\n };\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n result.allowTransition = result.allowTransition && _result.allowTransition;\n });\n // 所有状态都允许过渡,则添加到shouldApplyState\n if (result.allowTransition) {\n shouldApplyState.push({\n state,\n animationConfig: isArray(animationConfig[index])\n ? (animationConfig[index] as IAnimationState[]).map(item => item.animation)\n : (animationConfig[index] as IAnimationState).animation,\n executor: new AnimateExecutor(this.graphic)\n });\n // 允许过渡的话,需要重新遍历this.stateList,获取stopOriginalTransition\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n if (_result.stopOriginalTransition) {\n shouldStopState.push(currState);\n }\n });\n }\n });\n }\n\n // 停止动画\n shouldStopState.forEach(state => {\n state.executor.stop();\n });\n\n // 立即应用动画,串行的应用\n if (shouldApplyState.length) {\n shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);\n // 如果下一个状态存在,那么下一个状态的动画在当前状态动画结束后立即执行\n for (let i = 0; i < shouldApplyState.length; i++) {\n const nextState = shouldApplyState[i + 1];\n const currentState = shouldApplyState[i];\n currentState.executor.onEnd(() => {\n if (nextState) {\n nextState.executor.execute(nextState.animationConfig);\n }\n // 删除这个状态\n this.stateList = this.stateList.filter(state => state !== currentState);\n\n // 如果是最后一个状态且有回调,则调用回调\n if (i === shouldApplyState.length - 1 && callback) {\n callback(false);\n }\n });\n }\n } else if (callback) {\n // 如果没有需要应用的动画状态,直接调用回调\n callback(true);\n }\n\n if (this.stateList) {\n this.stateList = this.stateList.filter(state => !shouldStopState.includes(state));\n } else {\n this.stateList = [];\n }\n this.stateList.push(...shouldApplyState);\n }\n\n /**\n * Apply a standard appear animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyAppearState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState([AnimationStates.APPEAR], [{ name: AnimationStates.APPEAR, animation: animationConfig }], callback);\n }\n\n /**\n * Apply a standard disappear animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyDisappearState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.DISAPPEAR],\n [{ name: AnimationStates.DISAPPEAR, animation: animationConfig }],\n callback\n );\n }\n\n /**\n * Apply a standard update animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState([AnimationStates.UPDATE], [{ name: AnimationStates.UPDATE, animation: animationConfig }], callback);\n }\n\n /**\n * Apply a standard highlight animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.HIGHLIGHT],\n [{ name: AnimationStates.HIGHLIGHT, animation: animationConfig }],\n callback\n );\n }\n\n /**\n * Apply a standard unhighlight animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.UNHIGHLIGHT],\n [{ name: AnimationStates.UNHIGHLIGHT, animation: animationConfig }],\n callback\n );\n }\n\n stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void {\n const stateInfo = this.stateList?.find(stateInfo => stateInfo.state === state);\n if (stateInfo) {\n stateInfo.executor.stop(type);\n }\n }\n\n clearState(): void {\n // 清空状态\n this.stateList?.forEach(state => {\n state.executor.stop();\n });\n this.stateList = null;\n }\n\n // getstateList(): string[] | null {\n // return this.stateList;\n // }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/state/animation-state.ts"],"names":[],"mappings":";;;AAEA,2EAA0E;AAE1E,mEAA+D;AAC/D,6CAA2C;AAG9B,QAAA,eAAe,GAAG;IAC7B,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,aAAa;IAC1B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAa,mBAAmB;IAG9B,YAAY,OAAiB;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAMD,aAAa,CAAC,KAAsB;QAClC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,WAAW;;QACT,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AArBD,kDAqBC;AASD,MAAa,qBAAqB;IAOhC,YAAY,OAAiB;QAF7B,cAAS,GAAwB,IAAI,CAAC;QAGpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IASD,UAAU,CACR,S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AC,SAAS,0CAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAC/E,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC1B,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;SACvD;IACH,CAAC;CAKF;AAhMD,sDAgMC","file":"animation-state.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationTransitionRegistry } from './animation-states-registry';\nimport type { IAnimationConfig } from '../executor/executor';\nimport { AnimateExecutor } from '../executor/animate-executor';\nimport { isArray } from '@visactor/vutils';\n\n// Standard animation state names\nexport const AnimationStates = {\n APPEAR: 'appear',\n DISAPPEAR: 'disappear',\n UPDATE: 'update',\n HIGHLIGHT: 'highlight',\n UNHIGHLIGHT: 'unhighlight',\n SELECT: 'select',\n UNSELECT: 'unselect',\n HOVER: 'hover',\n UNHOVER: 'unhover',\n ACTIVE: 'active',\n INACTIVE: 'inactive'\n};\n\nexport class AnimationStateStore {\n graphic: IGraphic;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // 动画状态配置\n // 并不是所有图元都有(只有mark才有),所以在应用状态的时候,需要额外传入\n states?: Map<string, IAnimationState>;\n\n registerState(state: IAnimationState): void {\n if (!this.states) {\n this.states = new Map();\n }\n this.states.set(state.name, state);\n }\n\n clearStates(): void {\n this.states?.clear();\n }\n}\n\n// 一个状态对应一个执行器,每个图元都有一一对应\ninterface IStateInfo {\n state: string;\n animationConfig: IAnimationConfig | IAnimationConfig[];\n executor: AnimateExecutor;\n}\n\nexport class AnimationStateManager {\n protected graphic: IGraphic;\n\n // 当前状态\n // TODO(注意,这里无法了解动画的顺序,既有串行也有并行,具体在执行的时候确定,执行之后就无法获取串行或并行配置了)\n stateList: IStateInfo[] | null = null;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // TODO 这里因为只有状态变更才会调用,所以代码写的比较宽松,如果有性能问题需要优化\n /**\n * 应用状态\n * @param nextState 下一个状态数组,如果传入数组,那么状态是串行的。但是每次applyState都会立即执行动画,也就是applyState和applyState之间是并行\n * @param animationConfig 动画配置\n * @param callback 动画结束后的回调函数,参数empty为true表示没有动画需要执行直接调的回调\n */\n applyState(\n nextState: string[],\n animationConfig: (IAnimationState | IAnimationState[])[],\n callback?: (empty?: boolean) => void\n ): void {\n const registry = AnimationTransitionRegistry.getInstance();\n\n // TODO 这里指判断第一个状态,后续如果需要的话要循环判断\n // 检查是否需要停止当前状态,以及下一个状态是否需要应用\n const shouldStopState: IStateInfo[] = [];\n const shouldApplyState: IStateInfo[] = [];\n if (!(this.stateList && this.stateList.length)) {\n nextState.forEach((state, index) => {\n shouldApplyState.push({\n state,\n animationConfig: isArray(animationConfig[index])\n ? (animationConfig[index] as IAnimationState[]).map(item => item.animation)\n : (animationConfig[index] as IAnimationState).animation,\n executor: new AnimateExecutor(this.graphic)\n });\n });\n } else {\n // const _stateList = this.stateList[0];\n nextState.forEach((state, index) => {\n // 遍历this.stateList,获取result,只要有一个是false,那这个result就是false\n const result: { allowTransition: boolean; stopOriginalTransition: boolean } = {\n allowTransition: true,\n stopOriginalTransition: true\n };\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n result.allowTransition = result.allowTransition && _result.allowTransition;\n });\n // 所有状态都允许过渡,则添加到shouldApplyState\n if (result.allowTransition) {\n shouldApplyState.push({\n state,\n animationConfig: isArray(animationConfig[index])\n ? (animationConfig[index] as IAnimationState[]).map(item => item.animation)\n : (animationConfig[index] as IAnimationState).animation,\n executor: new AnimateExecutor(this.graphic)\n });\n // 允许过渡的话,需要重新遍历this.stateList,获取stopOriginalTransition\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n if (_result.stopOriginalTransition) {\n shouldStopState.push(currState);\n }\n });\n }\n });\n }\n\n // 停止动画\n shouldStopState.forEach(state => {\n state.executor.stop();\n });\n\n // 立即应用动画,串行的应用\n if (shouldApplyState.length) {\n shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);\n // 如果下一个状态存在,那么下一个状态的动画在当前状态动画结束后立即执行\n for (let i = 0; i < shouldApplyState.length; i++) {\n const nextState = shouldApplyState[i + 1];\n const currentState = shouldApplyState[i];\n currentState.executor.onEnd(() => {\n if (nextState) {\n nextState.executor.execute(nextState.animationConfig);\n }\n // 删除这个状态\n this.stateList = this.stateList.filter(state => state !== currentState);\n\n // 如果是最后一个状态且有回调,则调用回调\n if (i === shouldApplyState.length - 1 && callback) {\n callback(false);\n }\n });\n }\n } else if (callback) {\n // 如果没有需要应用的动画状态,直接调用回调\n callback(true);\n }\n\n if (this.stateList) {\n this.stateList = this.stateList.filter(state => !shouldStopState.includes(state));\n } else {\n this.stateList = [];\n }\n this.stateList.push(...shouldApplyState);\n }\n\n /**\n * Apply a standard appear animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyAppearState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState([AnimationStates.APPEAR], [{ name: AnimationStates.APPEAR, animation: animationConfig }], callback);\n }\n\n /**\n * Apply a standard disappear animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyDisappearState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.DISAPPEAR],\n [{ name: AnimationStates.DISAPPEAR, animation: animationConfig }],\n callback\n );\n }\n\n /**\n * Apply a standard update animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState([AnimationStates.UPDATE], [{ name: AnimationStates.UPDATE, animation: animationConfig }], callback);\n }\n\n /**\n * Apply a standard highlight animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.HIGHLIGHT],\n [{ name: AnimationStates.HIGHLIGHT, animation: animationConfig }],\n callback\n );\n }\n\n /**\n * Apply a standard unhighlight animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.UNHIGHLIGHT],\n [{ name: AnimationStates.UNHIGHLIGHT, animation: animationConfig }],\n callback\n );\n }\n\n stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void {\n const stateInfo = this.stateList?.find(stateInfo => stateInfo.state === state);\n if (stateInfo) {\n stateInfo.executor.stop(type);\n }\n }\n\n clearState(): void {\n // 清空状态\n this.stateList?.forEach(state => {\n state.executor.stop();\n });\n this.stateList = null;\n }\n\n reApplyState(state: string): void {\n const stateInfo = this.stateList?.find(stateInfo => stateInfo.state === state);\n if (stateInfo) {\n stateInfo.executor.stop();\n stateInfo.executor.execute(stateInfo.animationConfig);\n }\n }\n\n // getstateList(): string[] | null {\n // return this.stateList;\n // }\n}\n"]}
|
|
@@ -12,7 +12,8 @@ export declare class GraphicStateExtension {
|
|
|
12
12
|
applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): this;
|
|
13
13
|
applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): this;
|
|
14
14
|
applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): this;
|
|
15
|
-
stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any
|
|
15
|
+
stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any>, deep?: boolean): this;
|
|
16
16
|
clearAnimationStates(): this;
|
|
17
|
+
reApplyAnimationState(state: string, deep?: boolean): this;
|
|
17
18
|
static extend(graphic: IGraphic): IGraphic;
|
|
18
19
|
}
|
|
@@ -42,12 +42,19 @@ class GraphicStateExtension {
|
|
|
42
42
|
return this._getAnimationStateManager(this).applyUnhighlightState(animationConfig, callback),
|
|
43
43
|
this;
|
|
44
44
|
}
|
|
45
|
-
stopAnimationState(state, type) {
|
|
46
|
-
return this._getAnimationStateManager(this).stopState(state, type), this
|
|
45
|
+
stopAnimationState(state, type, deep = !1) {
|
|
46
|
+
return this._getAnimationStateManager(this).stopState(state, type), deep && this.isContainer && this.forEachChildren((child => {
|
|
47
|
+
child.stopAnimationState(state, type, deep);
|
|
48
|
+
})), this;
|
|
47
49
|
}
|
|
48
50
|
clearAnimationStates() {
|
|
49
51
|
return this._getAnimationStateManager(this).clearState(), this;
|
|
50
52
|
}
|
|
53
|
+
reApplyAnimationState(state, deep = !1) {
|
|
54
|
+
return this._getAnimationStateManager(this).reApplyState(state), deep && this.isContainer && this.forEachChildren((child => {
|
|
55
|
+
child.reApplyAnimationState(state, deep);
|
|
56
|
+
})), this;
|
|
57
|
+
}
|
|
51
58
|
static extend(graphic) {
|
|
52
59
|
return (new GraphicStateExtension)._getAnimationStateManager(graphic), graphic;
|
|
53
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/graphic-extension.ts"],"names":[],"mappings":";;;AAEA,uDAA+E;AAM/E,MAAa,qBAAqB;IAChC,yBAAyB,CAAC,OAAiB;QACzC,IAAI,CAAE,OAAe,CAAC,sBAAsB,EAAE;YAE3C,OAAe,CAAC,sBAAsB,GAAG,IAAI,uCAAqB,CAAC,OAAO,CAAC,CAAC;SAC9E;QACD,OAAQ,OAAe,CAAC,sBAAsB,CAAC;IACjD,CAAC;IACD,uBAAuB,CAAC,OAAiB;QACvC,IAAI,CAAE,OAAe,CAAC,oBAAoB,EAAE;YAEzC,OAAe,CAAC,oBAAoB,GAAG,IAAI,qCAAmB,CAAC,OAAO,CAAC,CAAC;SAC1E;QACD,OAAQ,OAAe,CAAC,oBAAoB,CAAC;IAC/C,CAAC;IAKD,sBAAsB,CAAC,KAAsB;QAC3C,IAAI,CAAC,uBAAuB,CAAC,IAA2B,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AAI,CAAC,CAAC;YAC3C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAYD,MAAM,CAAC,MAAM,CAAC,OAAiB;QAC7B,MAAM,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAC9C,SAAS,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AApID,sDAoIC","file":"graphic-extension.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationStateManager, AnimationStateStore } from './animation-state';\nimport type { IAnimationConfig } from '../executor/executor';\n\n/**\n * 将动画状态方法作为混入扩展 Graphic 的类\n */\nexport class GraphicStateExtension {\n _getAnimationStateManager(graphic: IGraphic): AnimationStateManager {\n if (!(graphic as any)._animationStateManager) {\n // Create the appropriate manager type based on whether this is a group\n (graphic as any)._animationStateManager = new AnimationStateManager(graphic);\n }\n return (graphic as any)._animationStateManager;\n }\n _getAnimationStateStore(graphic: IGraphic): AnimationStateStore {\n if (!(graphic as any)._animationStateStore) {\n // Create the appropriate manager type based on whether this is a group\n (graphic as any)._animationStateStore = new AnimationStateStore(graphic);\n }\n return (graphic as any)._animationStateStore;\n }\n\n /**\n * 注册一个动画状态\n */\n registerAnimationState(state: IAnimationState): this {\n this._getAnimationStateStore(this as unknown as IGraphic).registerState(state);\n return this;\n }\n\n /**\n * 应用一个动画状态到图形\n */\n applyAnimationState(\n state: string[],\n animationConfig: (IAnimationState | IAnimationState[])[],\n callback?: (empty?: boolean) => void\n ): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyState(state, animationConfig, callback);\n return this;\n }\n\n /**\n * 应用出现动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyAppearState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyAppearState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用消失动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyDisappearState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyDisappearState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用更新动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyUpdateState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用高亮动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyHighlightState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用取消高亮动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyUnhighlightState(animationConfig, callback);\n return this;\n }\n\n /**\n * 停止一个动画状态\n */\n stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any>, deep: boolean = false): this {\n this._getAnimationStateManager(this as unknown as IGraphic).stopState(state, type);\n if (deep && (this as any).isContainer) {\n (this as any).forEachChildren((child: any) => {\n child.stopAnimationState(state, type, deep);\n });\n }\n return this;\n }\n\n /**\n * 清除图形上的所有动画状态\n */\n clearAnimationStates(): this {\n this._getAnimationStateManager(this as unknown as IGraphic).clearState();\n return this;\n }\n\n reApplyAnimationState(state: string, deep: boolean = false): this {\n this._getAnimationStateManager(this as unknown as IGraphic).reApplyState(state);\n if (deep && (this as any).isContainer) {\n (this as any).forEachChildren((child: any) => {\n child.reApplyAnimationState(state, deep);\n });\n }\n return this;\n }\n\n // /**\n // * 获取图形当前的动画状态\n // */\n // getCurrentAnimationState(): string[] | null {\n // return this._getAnimationStateManager(this as unknown as IGraphic).getCurrentState();\n // }\n\n /**\n * 继承\n */\n static extend(graphic: IGraphic): IGraphic {\n const extension = new GraphicStateExtension();\n extension._getAnimationStateManager(graphic);\n return graphic;\n }\n}\n"]}
|
package/dist/index.es.js
CHANGED
|
@@ -2117,6 +2117,14 @@ class AnimationStateManager {
|
|
|
2117
2117
|
});
|
|
2118
2118
|
this.stateList = null;
|
|
2119
2119
|
}
|
|
2120
|
+
reApplyState(state) {
|
|
2121
|
+
var _a;
|
|
2122
|
+
const stateInfo = (_a = this.stateList) === null || _a === void 0 ? void 0 : _a.find(stateInfo => stateInfo.state === state);
|
|
2123
|
+
if (stateInfo) {
|
|
2124
|
+
stateInfo.executor.stop();
|
|
2125
|
+
stateInfo.executor.execute(stateInfo.animationConfig);
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2120
2128
|
}
|
|
2121
2129
|
|
|
2122
2130
|
class GraphicStateExtension {
|
|
@@ -2160,14 +2168,28 @@ class GraphicStateExtension {
|
|
|
2160
2168
|
this._getAnimationStateManager(this).applyUnhighlightState(animationConfig, callback);
|
|
2161
2169
|
return this;
|
|
2162
2170
|
}
|
|
2163
|
-
stopAnimationState(state, type) {
|
|
2171
|
+
stopAnimationState(state, type, deep = false) {
|
|
2164
2172
|
this._getAnimationStateManager(this).stopState(state, type);
|
|
2173
|
+
if (deep && this.isContainer) {
|
|
2174
|
+
this.forEachChildren((child) => {
|
|
2175
|
+
child.stopAnimationState(state, type, deep);
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2165
2178
|
return this;
|
|
2166
2179
|
}
|
|
2167
2180
|
clearAnimationStates() {
|
|
2168
2181
|
this._getAnimationStateManager(this).clearState();
|
|
2169
2182
|
return this;
|
|
2170
2183
|
}
|
|
2184
|
+
reApplyAnimationState(state, deep = false) {
|
|
2185
|
+
this._getAnimationStateManager(this).reApplyState(state);
|
|
2186
|
+
if (deep && this.isContainer) {
|
|
2187
|
+
this.forEachChildren((child) => {
|
|
2188
|
+
child.reApplyAnimationState(state, deep);
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
return this;
|
|
2192
|
+
}
|
|
2171
2193
|
static extend(graphic) {
|
|
2172
2194
|
const extension = new GraphicStateExtension();
|
|
2173
2195
|
extension._getAnimationStateManager(graphic);
|
|
@@ -2236,6 +2258,30 @@ class AnimateExtension {
|
|
|
2236
2258
|
}
|
|
2237
2259
|
return this.attribute[key];
|
|
2238
2260
|
}
|
|
2261
|
+
pauseAnimation(deep = false) {
|
|
2262
|
+
this.animates && this.animates.forEach(animate => animate.pause());
|
|
2263
|
+
if (deep && this.isContainer) {
|
|
2264
|
+
this.forEachChildren((child) => {
|
|
2265
|
+
child.pauseAnimation(deep);
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
resumeAnimation(deep = false) {
|
|
2270
|
+
this.animates && this.animates.forEach(animate => animate.resume());
|
|
2271
|
+
if (deep && this.isContainer) {
|
|
2272
|
+
this.forEachChildren((child) => {
|
|
2273
|
+
child.resumeAnimation(deep);
|
|
2274
|
+
});
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
stopAnimation(deep = false) {
|
|
2278
|
+
this.animates && this.animates.forEach(animate => animate.stop());
|
|
2279
|
+
if (deep && this.isContainer) {
|
|
2280
|
+
this.forEachChildren((child) => {
|
|
2281
|
+
child.stopAnimation(deep);
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2239
2285
|
}
|
|
2240
2286
|
|
|
2241
2287
|
function registerAnimate() {
|
|
@@ -3925,7 +3971,7 @@ class GrowCenterIn extends ACustomAnimate {
|
|
|
3925
3971
|
super(from, to, duration, easing, params);
|
|
3926
3972
|
}
|
|
3927
3973
|
onBind() {
|
|
3928
|
-
var _a, _b;
|
|
3974
|
+
var _a, _b, _c;
|
|
3929
3975
|
super.onBind();
|
|
3930
3976
|
const { from, to } = growCenterIn(this.target, this.params.options, this.params);
|
|
3931
3977
|
const fromAttrs = (_b = (_a = this.target.context) === null || _a === void 0 ? void 0 : _a.lastAttrs) !== null && _b !== void 0 ? _b : from;
|
|
@@ -3937,7 +3983,9 @@ class GrowCenterIn extends ACustomAnimate {
|
|
|
3937
3983
|
if (finalAttribute) {
|
|
3938
3984
|
this.target.setAttributes(finalAttribute);
|
|
3939
3985
|
}
|
|
3940
|
-
this.
|
|
3986
|
+
if (((_c = this.params.controlOptions) === null || _c === void 0 ? void 0 : _c.immediatelyApply) !== false) {
|
|
3987
|
+
this.target.setAttributes(fromAttrs);
|
|
3988
|
+
}
|
|
3941
3989
|
}
|
|
3942
3990
|
onEnd(cb) {
|
|
3943
3991
|
super.onEnd(cb);
|
|
@@ -4033,7 +4081,7 @@ class GrowHeightIn extends ACustomAnimate {
|
|
|
4033
4081
|
super(from, to, duration, easing, params);
|
|
4034
4082
|
}
|
|
4035
4083
|
onBind() {
|
|
4036
|
-
var _a, _b;
|
|
4084
|
+
var _a, _b, _c;
|
|
4037
4085
|
super.onBind();
|
|
4038
4086
|
const { from, to } = growHeightIn(this.target, this.params.options, this.params);
|
|
4039
4087
|
const fromAttrs = (_b = (_a = this.target.context) === null || _a === void 0 ? void 0 : _a.lastAttrs) !== null && _b !== void 0 ? _b : from;
|
|
@@ -4045,7 +4093,9 @@ class GrowHeightIn extends ACustomAnimate {
|
|
|
4045
4093
|
if (finalAttribute) {
|
|
4046
4094
|
this.target.setAttributes(finalAttribute);
|
|
4047
4095
|
}
|
|
4048
|
-
this.
|
|
4096
|
+
if (((_c = this.params.controlOptions) === null || _c === void 0 ? void 0 : _c.immediatelyApply) !== false) {
|
|
4097
|
+
this.target.setAttributes(fromAttrs);
|
|
4098
|
+
}
|
|
4049
4099
|
}
|
|
4050
4100
|
onEnd(cb) {
|
|
4051
4101
|
super.onEnd(cb);
|
|
@@ -19,4 +19,7 @@ export declare class AnimateExtension {
|
|
|
19
19
|
executeAnimations(configs: IAnimationConfig[]): this;
|
|
20
20
|
protected getFinalAttribute(): Record<string, any>;
|
|
21
21
|
getGraphicAttribute(key: string, prev?: boolean): any;
|
|
22
|
+
pauseAnimation(deep?: boolean): void;
|
|
23
|
+
resumeAnimation(deep?: boolean): void;
|
|
24
|
+
stopAnimation(deep?: boolean): void;
|
|
22
25
|
}
|
package/es/animate-extension.js
CHANGED
|
@@ -49,4 +49,19 @@ export class AnimateExtension {
|
|
|
49
49
|
getGraphicAttribute(key, prev = !1) {
|
|
50
50
|
return !prev && this.finalAttribute ? this.finalAttribute[key] : this.attribute[key];
|
|
51
51
|
}
|
|
52
|
+
pauseAnimation(deep = !1) {
|
|
53
|
+
this.animates && this.animates.forEach((animate => animate.pause())), deep && this.isContainer && this.forEachChildren((child => {
|
|
54
|
+
child.pauseAnimation(deep);
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
resumeAnimation(deep = !1) {
|
|
58
|
+
this.animates && this.animates.forEach((animate => animate.resume())), deep && this.isContainer && this.forEachChildren((child => {
|
|
59
|
+
child.resumeAnimation(deep);
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
stopAnimation(deep = !1) {
|
|
63
|
+
this.animates && this.animates.forEach((animate => animate.stop())), deep && this.isContainer && this.forEachChildren((child => {
|
|
64
|
+
child.stopAnimation(deep);
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
52
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/animate-extension.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,MAAM,OAAO,gBAAgB;IAM3B,aAAa,CAAC,QAAiB,KAAK;QAClC,IAAI,KAAK,IAAI,IAAI,CAAC,cAAc,EAAE;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC;SAC5B;QACD,OAAQ,IAAY,CAA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cAAc,CAAC;IACvC,CAAC;IAED,mBAAmB;QACjB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YAC1B,IAAI,CAAC,gBAAgB,GAAG,IAAI,eAAe,CAAC,IAAW,CAAC,CAAC;SAC1D;IACH,CAAC;IAOD,gBAAgB,CAAC,MAAwB;QACvC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAOD,iBAAiB,CAAC,OAA2B;QAC3C,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACvB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAES,iBAAiB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAGD,mBAAmB,CAAC,GAAW,EAAE,OAAgB,KAAK;QACpD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,cAAc,EAAE;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;SACjC;QACD,OAAQ,IAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;CACF","file":"animate-extension.js","sourcesContent":["// 1. 支持animate函数\n// 2. 支持animates map\n// 2. 支持animatedAttribute 为所有动画的最终结果(loop为INFINITY的动画不算)\n// 3. 支持finalAttribute 为所有动画的最终结果(animatedAttribute 合并了 graphic.attribute之后的最终结果)\n// 3. 重载Graphic的getAttributes方法,根据参数getAttributes(final = true)返回finalAttribute = {}; merge(finalAttribute, graphic.attribute, animatedAttribute),\n// animatedAttribute为所有动画的最终结果(loop为INFINITY的动画不算)\n\nimport type { IGraphicAnimateParams, IAnimate } from '@visactor/vrender-core';\nimport { Animate } from './animate';\nimport { DefaultTimeline, defaultTimeline } from './timeline';\nimport { DefaultTicker } from './ticker/default-ticker';\nimport type { IAnimationConfig } from './executor/executor';\nimport { AnimateExecutor } from './executor/animate-executor';\n\n// 基于性能考虑,每次调用animate函数,都会设置animatedAttribute为null,每次getAttributes(true)会根据animatedAttribute属性判断是否需要重新计算animatedAttribute。\nexport class AnimateExtension {\n declare finalAttribute: Record<string, any>;\n _animateExecutor: AnimateExecutor | null;\n\n declare animates: Map<string | number, IAnimate>;\n\n getAttributes(final: boolean = false) {\n if (final && this.finalAttribute) {\n return this.finalAttribute;\n }\n return (this as any).attribute;\n }\n\n animate(params?: IGraphicAnimateParams) {\n const animate = new Animate(\n params?.id,\n params?.timeline ?? ((this as any).stage && (this as any).stage.getTimeline()) ?? defaultTimeline,\n params?.slience\n );\n\n animate.bind(this as any);\n if (params) {\n const { onStart, onEnd, onRemove } = params;\n onStart != null && animate.onStart(onStart);\n onEnd != null && animate.onEnd(onEnd);\n onRemove != null && animate.onRemove(onRemove);\n }\n\n // TODO 考虑性能问题\n (this as any).stage?.ticker.start();\n\n return animate;\n }\n\n createTimeline() {\n return new DefaultTimeline();\n }\n\n createTicker(stage: any) {\n return new DefaultTicker(stage);\n }\n\n setFinalAttributes(finalAttribute: Record<string, any>) {\n if (!this.finalAttribute) {\n this.finalAttribute = {};\n }\n Object.assign(this.finalAttribute, finalAttribute);\n }\n\n initFinalAttributes(finalAttribute: Record<string, any>) {\n this.finalAttribute = finalAttribute;\n }\n\n initAnimateExecutor(): void {\n if (!this._animateExecutor) {\n this._animateExecutor = new AnimateExecutor(this as any);\n }\n }\n\n /**\n * Apply animation configuration to the component\n * @param config Animation configuration\n * @returns This component instance\n */\n executeAnimation(config: IAnimationConfig): this {\n this.initAnimateExecutor();\n this._animateExecutor.execute(config);\n return this;\n }\n\n /**\n * Apply animations to multiple components\n * @param configs Animation configurations\n * @returns This component instance\n */\n executeAnimations(configs: IAnimationConfig[]): this {\n this.initAnimateExecutor();\n configs.forEach(config => {\n this._animateExecutor.execute(config);\n });\n return this;\n }\n\n protected getFinalAttribute() {\n return this.finalAttribute;\n }\n\n // TODO prev是兼容原本VGrammar函数的一个参数,用于动画中获取上一次属性,目前的逻辑中应该不需要,直接去当前帧的属性即可\n getGraphicAttribute(key: string, prev: boolean = false) {\n if (!prev && this.finalAttribute) {\n return this.finalAttribute[key];\n }\n return (this as any).attribute[key];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/animate-extension.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,MAAM,OAAO,gBAAgB;IAM3B,aAAa,CAAC,QAAiB,KAAK;QAClC,IAAI,KAAK,IAAI,IAAI,CAAC,cAAc,EAAE;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC;SAC5B;QACD,OAAQ,IAAY,CAAC,SAAS,CAAC;IACjC,CAAC;IAED,OAAO,CAAC,MAA8B;;QACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE,EACV,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,mCAAI,CAAE,IAAY,CAAC,KAAK,IAAK,IAAY,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,mCAAI,eAAe,EACjG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAChB,CAAC;QAEF,OAAO,CAAC,IAAI,CAAC,IAAW,CAAC,CAAC;QAC1B,IAAI,MAAM,EAAE;YACV,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;YAC5C,OAAO,IAAI,IAAI,IAAI,OAAO,CA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AAE;YACpC,IAAY,CAAC,eAAe,CAAC,CAAC,KAAU,EAAE,EAAE;gBAC3C,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;CACF","file":"animate-extension.js","sourcesContent":["// 1. 支持animate函数\n// 2. 支持animates map\n// 2. 支持animatedAttribute 为所有动画的最终结果(loop为INFINITY的动画不算)\n// 3. 支持finalAttribute 为所有动画的最终结果(animatedAttribute 合并了 graphic.attribute之后的最终结果)\n// 3. 重载Graphic的getAttributes方法,根据参数getAttributes(final = true)返回finalAttribute = {}; merge(finalAttribute, graphic.attribute, animatedAttribute),\n// animatedAttribute为所有动画的最终结果(loop为INFINITY的动画不算)\n\nimport type { IGraphicAnimateParams, IAnimate } from '@visactor/vrender-core';\nimport { Animate } from './animate';\nimport { DefaultTimeline, defaultTimeline } from './timeline';\nimport { DefaultTicker } from './ticker/default-ticker';\nimport type { IAnimationConfig } from './executor/executor';\nimport { AnimateExecutor } from './executor/animate-executor';\n\n// 基于性能考虑,每次调用animate函数,都会设置animatedAttribute为null,每次getAttributes(true)会根据animatedAttribute属性判断是否需要重新计算animatedAttribute。\nexport class AnimateExtension {\n declare finalAttribute: Record<string, any>;\n _animateExecutor: AnimateExecutor | null;\n\n declare animates: Map<string | number, IAnimate>;\n\n getAttributes(final: boolean = false) {\n if (final && this.finalAttribute) {\n return this.finalAttribute;\n }\n return (this as any).attribute;\n }\n\n animate(params?: IGraphicAnimateParams) {\n const animate = new Animate(\n params?.id,\n params?.timeline ?? ((this as any).stage && (this as any).stage.getTimeline()) ?? defaultTimeline,\n params?.slience\n );\n\n animate.bind(this as any);\n if (params) {\n const { onStart, onEnd, onRemove } = params;\n onStart != null && animate.onStart(onStart);\n onEnd != null && animate.onEnd(onEnd);\n onRemove != null && animate.onRemove(onRemove);\n }\n\n // TODO 考虑性能问题\n (this as any).stage?.ticker.start();\n\n return animate;\n }\n\n createTimeline() {\n return new DefaultTimeline();\n }\n\n createTicker(stage: any) {\n return new DefaultTicker(stage);\n }\n\n setFinalAttributes(finalAttribute: Record<string, any>) {\n if (!this.finalAttribute) {\n this.finalAttribute = {};\n }\n Object.assign(this.finalAttribute, finalAttribute);\n }\n\n initFinalAttributes(finalAttribute: Record<string, any>) {\n this.finalAttribute = finalAttribute;\n }\n\n initAnimateExecutor(): void {\n if (!this._animateExecutor) {\n this._animateExecutor = new AnimateExecutor(this as any);\n }\n }\n\n /**\n * Apply animation configuration to the component\n * @param config Animation configuration\n * @returns This component instance\n */\n executeAnimation(config: IAnimationConfig): this {\n this.initAnimateExecutor();\n this._animateExecutor.execute(config);\n return this;\n }\n\n /**\n * Apply animations to multiple components\n * @param configs Animation configurations\n * @returns This component instance\n */\n executeAnimations(configs: IAnimationConfig[]): this {\n this.initAnimateExecutor();\n configs.forEach(config => {\n this._animateExecutor.execute(config);\n });\n return this;\n }\n\n protected getFinalAttribute() {\n return this.finalAttribute;\n }\n\n // TODO prev是兼容原本VGrammar函数的一个参数,用于动画中获取上一次属性,目前的逻辑中应该不需要,直接去当前帧的属性即可\n getGraphicAttribute(key: string, prev: boolean = false) {\n if (!prev && this.finalAttribute) {\n return this.finalAttribute[key];\n }\n return (this as any).attribute[key];\n }\n\n pauseAnimation(deep: boolean = false) {\n this.animates && this.animates.forEach(animate => animate.pause());\n if (deep && (this as any).isContainer) {\n (this as any).forEachChildren((child: any) => {\n child.pauseAnimation(deep);\n });\n }\n }\n\n resumeAnimation(deep: boolean = false) {\n this.animates && this.animates.forEach(animate => animate.resume());\n if (deep && (this as any).isContainer) {\n (this as any).forEachChildren((child: any) => {\n child.resumeAnimation(deep);\n });\n }\n }\n\n stopAnimation(deep: boolean = false) {\n this.animates && this.animates.forEach(animate => animate.stop());\n if (deep && (this as any).isContainer) {\n (this as any).forEachChildren((child: any) => {\n child.stopAnimation(deep);\n });\n }\n }\n}\n"]}
|
package/es/custom/growCenter.js
CHANGED
|
@@ -119,13 +119,13 @@ export class GrowCenterIn extends ACustomAnimate {
|
|
|
119
119
|
super(from, to, duration, easing, params);
|
|
120
120
|
}
|
|
121
121
|
onBind() {
|
|
122
|
-
var _a, _b;
|
|
122
|
+
var _a, _b, _c;
|
|
123
123
|
super.onBind();
|
|
124
124
|
const {from: from, to: to} = growCenterIn(this.target, this.params.options, this.params), fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
|
|
125
125
|
this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
|
|
126
126
|
this.from = fromAttrs, this.to = to;
|
|
127
127
|
const finalAttribute = this.target.getFinalAttribute();
|
|
128
|
-
finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
|
|
128
|
+
finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
|
|
129
129
|
}
|
|
130
130
|
onEnd(cb) {
|
|
131
131
|
super.onEnd(cb);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/custom/growCenter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAuBlD,MAAM,YAAY,GAA4B,CAC5C,OAAiB,EACjB,OAAuC,EACvC,mBAAyC,EACzC,EAAE;IACF,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC1C,QAAQ,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAE;QAC1B,KAAK,GAAG,CAAC,CAAC;YACR,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YAClB,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YAE1B,OAAO;gBACL,IAAI,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AwB;QAC5D,MAAM,SAAS,GAAwB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QAC7D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAC5E,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,0BAA0B,EAAE,CAAC;IAC3C,CAAC;CACF","file":"growCenter.js","sourcesContent":["import type { IGraphic, IGroup, IAnimate, IStep, EasingType } from '@visactor/vrender-core';\nimport { isValid } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ninterface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\ntype TypeAnimation<T extends IGraphic> = (\n graphic: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nconst growCenterIn: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.getFinalAttribute();\n switch (options?.direction) {\n case 'x': {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n\n return {\n from: isValid(width)\n ? {\n x: x + width / 2,\n x1: undefined,\n width: 0\n }\n : {\n x: (x + x1) / 2,\n x1: (x + x1) / 2,\n width: undefined\n },\n to: { x, x1, width }\n };\n }\n case 'y': {\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n return {\n from: isValid(height)\n ? {\n y: y + height / 2,\n y1: undefined,\n height: 0\n }\n : {\n y: (y + y1) / 2,\n y1: (y + y1) / 2,\n height: undefined\n },\n to: { y, y1, height }\n };\n }\n case 'xy':\n default: {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n const from: any = {};\n\n if (isValid(width)) {\n from.x = x + width / 2;\n from.width = 0;\n from.x1 = undefined;\n } else {\n from.x = (x + x1) / 2;\n from.x1 = (x + x1) / 2;\n from.width = undefined;\n }\n\n if (isValid(height)) {\n from.y = y + height / 2;\n from.height = 0;\n from.y1 = undefined;\n } else {\n from.y = (y + y1) / 2;\n from.y1 = (y + y1) / 2;\n from.height = undefined;\n }\n\n return {\n from,\n to: { x, y, x1, y1, width, height }\n };\n }\n }\n};\n\nconst growCenterOut: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.attribute as any;\n switch (options?.direction) {\n case 'x': {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n\n return {\n to: isValid(width)\n ? {\n x: x + width / 2,\n x1: undefined,\n width: 0\n }\n : {\n x: (x + x1) / 2,\n x1: (x + x1) / 2,\n width: undefined\n }\n };\n }\n case 'y': {\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n return {\n to: isValid(height)\n ? {\n y: y + height / 2,\n y1: undefined,\n height: 0\n }\n : {\n y: (y + y1) / 2,\n y1: (y + y1) / 2,\n height: undefined\n }\n };\n }\n case 'xy':\n default: {\n const x = attrs.x;\n const y = attrs.y;\n const x1 = attrs.x1;\n const y1 = attrs.y1;\n const width = attrs.width;\n const height = attrs.height;\n const to: any = {};\n\n if (isValid(width)) {\n to.x = x + width / 2;\n to.width = 0;\n to.x1 = undefined;\n } else {\n to.x = (x + x1) / 2;\n to.x1 = (x + x1) / 2;\n to.width = undefined;\n }\n\n if (isValid(height)) {\n to.y = y + height / 2;\n to.height = 0;\n to.y1 = undefined;\n } else {\n to.y = (y + y1) / 2;\n to.y1 = (y + y1) / 2;\n to.height = undefined;\n }\n\n return {\n to\n };\n }\n }\n};\n\n/**\n * 增长渐入\n */\nexport class GrowCenterIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growCenterIn(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context?.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = fromAttrs;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n this.target.setAttributes(fromAttrs);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\nexport class GrowCenterOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growCenterOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n\n this.from = from ?? (this.target.attribute as any);\n this.to = to;\n // this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/custom/growCenter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAuBlD,MAAM,YAAY,GAA4B,CAC5C,OAAiB,EACjB,OAAuC,EACvC,mBAAyC,EACzC,EAAE;IACF,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC1C,QAAQ,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAE;QAC1B,KAAK,GAAG,CAAC,CAAC;YACR,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YAClB,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YAE1B,OAAO;gBACL,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC;oBAClB,CAAC,CAAC;wBACE,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC;wBAChB,EAAE,EAAE,SAAS;wBACb,KAAK,EAAE,CAAC;qBACT;oBACH,CAAC,CAAC;wBACE,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC;wBACf,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC;wBAChB,KAAK,EAAE,SAAS;qBACjB;gBACL,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE;aACrB,CAAC;SACH;QACD,KAAK,GAAG,CAAC,CAAC;YACR,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YAClB,MAAM,EAAE,GAAG,KAAK,C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M,CAAC,0BAA0B,EAAE,CAAC;IAC3C,CAAC;CACF","file":"growCenter.js","sourcesContent":["import type { IGraphic, IGroup, IAnimate, IStep, EasingType } from '@visactor/vrender-core';\nimport { isValid } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ninterface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\ntype TypeAnimation<T extends IGraphic> = (\n graphic: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nconst growCenterIn: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.getFinalAttribute();\n switch (options?.direction) {\n case 'x': {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n\n return {\n from: isValid(width)\n ? {\n x: x + width / 2,\n x1: undefined,\n width: 0\n }\n : {\n x: (x + x1) / 2,\n x1: (x + x1) / 2,\n width: undefined\n },\n to: { x, x1, width }\n };\n }\n case 'y': {\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n return {\n from: isValid(height)\n ? {\n y: y + height / 2,\n y1: undefined,\n height: 0\n }\n : {\n y: (y + y1) / 2,\n y1: (y + y1) / 2,\n height: undefined\n },\n to: { y, y1, height }\n };\n }\n case 'xy':\n default: {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n const from: any = {};\n\n if (isValid(width)) {\n from.x = x + width / 2;\n from.width = 0;\n from.x1 = undefined;\n } else {\n from.x = (x + x1) / 2;\n from.x1 = (x + x1) / 2;\n from.width = undefined;\n }\n\n if (isValid(height)) {\n from.y = y + height / 2;\n from.height = 0;\n from.y1 = undefined;\n } else {\n from.y = (y + y1) / 2;\n from.y1 = (y + y1) / 2;\n from.height = undefined;\n }\n\n return {\n from,\n to: { x, y, x1, y1, width, height }\n };\n }\n }\n};\n\nconst growCenterOut: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const attrs = graphic.attribute as any;\n switch (options?.direction) {\n case 'x': {\n const x = attrs.x;\n const x1 = attrs.x1;\n const width = attrs.width;\n\n return {\n to: isValid(width)\n ? {\n x: x + width / 2,\n x1: undefined,\n width: 0\n }\n : {\n x: (x + x1) / 2,\n x1: (x + x1) / 2,\n width: undefined\n }\n };\n }\n case 'y': {\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n return {\n to: isValid(height)\n ? {\n y: y + height / 2,\n y1: undefined,\n height: 0\n }\n : {\n y: (y + y1) / 2,\n y1: (y + y1) / 2,\n height: undefined\n }\n };\n }\n case 'xy':\n default: {\n const x = attrs.x;\n const y = attrs.y;\n const x1 = attrs.x1;\n const y1 = attrs.y1;\n const width = attrs.width;\n const height = attrs.height;\n const to: any = {};\n\n if (isValid(width)) {\n to.x = x + width / 2;\n to.width = 0;\n to.x1 = undefined;\n } else {\n to.x = (x + x1) / 2;\n to.x1 = (x + x1) / 2;\n to.width = undefined;\n }\n\n if (isValid(height)) {\n to.y = y + height / 2;\n to.height = 0;\n to.y1 = undefined;\n } else {\n to.y = (y + y1) / 2;\n to.y1 = (y + y1) / 2;\n to.height = undefined;\n }\n\n return {\n to\n };\n }\n }\n};\n\n/**\n * 增长渐入\n */\nexport class GrowCenterIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growCenterIn(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context?.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = fromAttrs;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n if (this.params.controlOptions?.immediatelyApply !== false) {\n this.target.setAttributes(fromAttrs);\n }\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\nexport class GrowCenterOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growCenterOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n\n this.from = from ?? (this.target.attribute as any);\n this.to = to;\n // this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n"]}
|
package/es/custom/growHeight.js
CHANGED
|
@@ -64,13 +64,13 @@ export class GrowHeightIn extends ACustomAnimate {
|
|
|
64
64
|
super(from, to, duration, easing, params);
|
|
65
65
|
}
|
|
66
66
|
onBind() {
|
|
67
|
-
var _a, _b;
|
|
67
|
+
var _a, _b, _c;
|
|
68
68
|
super.onBind();
|
|
69
69
|
const {from: from, to: to} = growHeightIn(this.target, this.params.options, this.params), fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
|
|
70
70
|
this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
|
|
71
71
|
this.from = fromAttrs, this.to = to;
|
|
72
72
|
const finalAttribute = this.target.getFinalAttribute();
|
|
73
|
-
finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
|
|
73
|
+
finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
|
|
74
74
|
}
|
|
75
75
|
onEnd(cb) {
|
|
76
76
|
super.onEnd(cb);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/custom/growHeight.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAwBlD,SAAS,sBAAsB,CAC7B,OAAiB,EACjB,OAAuC,EACvC,mBAAyC;IAEzC,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC1C,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAClB,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IACpB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAE5B,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE;QAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CA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MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAK,IAAI,CAAC,MAAM,CAAC,SAAiB,CAAC;QACnD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IAEf,CAAC;IAED,KAAK,CAAC,EAA6C;QACjD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,MAAM,SAAS,GAAwB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QAC7D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAC5E,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,0BAA0B,EAAE,CAAC;IAC3C,CAAC;CACF","file":"growHeight.js","sourcesContent":["import type { IGraphic, IGroup, IAnimate, IStep, EasingType } from '@visactor/vrender-core';\nimport { isNil, isNumber, isValid } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ninterface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n layoutRect?: { width: number; height: number };\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\ntype TypeAnimation<T extends IGraphic> = (\n graphic: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nfunction growHeightInIndividual(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n if (options && options.orient === 'negative') {\n const computedY1 = isValid(height) ? Math.max(y, y + height) : Math.max(y, y1);\n return {\n from: { y: computedY1, y1: isNil(y1) ? undefined : computedY1, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n }\n\n const computedY = isValid(height) ? Math.min(y, y + height) : Math.min(y, y1);\n return {\n from: { y: computedY, y1: isNil(y1) ? undefined : computedY, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n}\n\nfunction growHeightInOverall(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n let overallValue: number;\n if (options && options.orient === 'negative') {\n if (isNumber(options.overall)) {\n overallValue = options.overall;\n } else if (animationParameters.group) {\n overallValue =\n (animationParameters as any).groupHeight ??\n options.layoutRect?.height ??\n animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = overallValue;\n } else {\n overallValue = animationParameters.height;\n }\n } else {\n overallValue = isNumber(options?.overall) ? options.overall : 0;\n }\n return {\n from: { y: overallValue, y1: isNil(y1) ? undefined : overallValue, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n}\n\nconst growHeightIn: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growHeightInOverall(graphic, options, animationParameters)\n : growHeightInIndividual(graphic, options, animationParameters);\n};\n\n/**\n * 增长渐入\n */\nexport class GrowHeightIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growHeightIn(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context?.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = fromAttrs;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n this.target.setAttributes(fromAttrs);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\nfunction growHeightOutIndividual(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n if (options && options.orient === 'negative') {\n const computedY1 = isValid(height) ? Math.max(y, y + height) : Math.max(y, y1);\n\n return {\n to: { y: computedY1, y1: isNil(y1) ? undefined : computedY1, height: isNil(height) ? undefined : 0 }\n };\n }\n\n const computedY = isValid(height) ? Math.min(y, y + height) : Math.min(y, y1);\n return {\n to: { y: computedY, y1: isNil(y1) ? undefined : computedY, height: isNil(height) ? undefined : 0 }\n };\n}\n\nfunction growHeightOutOverall(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y1 = attrs.y1;\n const height = attrs.height;\n\n let overallValue: number;\n if (options && options.orient === 'negative') {\n if (isNumber(options.overall)) {\n overallValue = options.overall;\n } else if (animationParameters.group) {\n overallValue =\n (animationParameters as any).groupHeight ??\n options.layoutRect?.height ??\n animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = overallValue;\n } else {\n overallValue = animationParameters.height;\n }\n } else {\n overallValue = isNumber(options?.overall) ? options.overall : 0;\n }\n return {\n to: { y: overallValue, y1: isNil(y1) ? undefined : overallValue, height: isNil(height) ? undefined : 0 }\n };\n}\n\n/**\n * 增长渐出\n */\nexport const growHeightOut: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growHeightOutOverall(graphic, options, animationParameters)\n : growHeightOutIndividual(graphic, options, animationParameters);\n};\n\nexport class GrowHeightOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growHeightOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = from ?? (this.target.attribute as any);\n this.to = to;\n // this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/custom/growHeight.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MA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,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAC5E,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,0BAA0B,EAAE,CAAC;IAC3C,CAAC;CACF","file":"growHeight.js","sourcesContent":["import type { IGraphic, IGroup, IAnimate, IStep, EasingType } from '@visactor/vrender-core';\nimport { isNil, isNumber, isValid } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ninterface IGrowCartesianAnimationOptions {\n orient?: 'positive' | 'negative';\n overall?: boolean | number;\n direction?: 'x' | 'y' | 'xy';\n layoutRect?: { width: number; height: number };\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\ntype TypeAnimation<T extends IGraphic> = (\n graphic: T,\n options: any,\n animationParameters: IAnimationParameters\n) => { from?: { [channel: string]: any }; to?: { [channel: string]: any } };\n\nfunction growHeightInIndividual(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n if (options && options.orient === 'negative') {\n const computedY1 = isValid(height) ? Math.max(y, y + height) : Math.max(y, y1);\n return {\n from: { y: computedY1, y1: isNil(y1) ? undefined : computedY1, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n }\n\n const computedY = isValid(height) ? Math.min(y, y + height) : Math.min(y, y1);\n return {\n from: { y: computedY, y1: isNil(y1) ? undefined : computedY, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n}\n\nfunction growHeightInOverall(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n let overallValue: number;\n if (options && options.orient === 'negative') {\n if (isNumber(options.overall)) {\n overallValue = options.overall;\n } else if (animationParameters.group) {\n overallValue =\n (animationParameters as any).groupHeight ??\n options.layoutRect?.height ??\n animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = overallValue;\n } else {\n overallValue = animationParameters.height;\n }\n } else {\n overallValue = isNumber(options?.overall) ? options.overall : 0;\n }\n return {\n from: { y: overallValue, y1: isNil(y1) ? undefined : overallValue, height: isNil(height) ? undefined : 0 },\n to: { y: y, y1: y1, height: height }\n };\n}\n\nconst growHeightIn: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growHeightInOverall(graphic, options, animationParameters)\n : growHeightInIndividual(graphic, options, animationParameters);\n};\n\n/**\n * 增长渐入\n */\nexport class GrowHeightIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growHeightIn(this.target, this.params.options, this.params);\n const fromAttrs = this.target.context?.lastAttrs ?? from;\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = fromAttrs;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n if (this.params.controlOptions?.immediatelyApply !== false) {\n this.target.setAttributes(fromAttrs);\n }\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\nfunction growHeightOutIndividual(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y = attrs.y;\n const y1 = attrs.y1;\n const height = attrs.height;\n\n if (options && options.orient === 'negative') {\n const computedY1 = isValid(height) ? Math.max(y, y + height) : Math.max(y, y1);\n\n return {\n to: { y: computedY1, y1: isNil(y1) ? undefined : computedY1, height: isNil(height) ? undefined : 0 }\n };\n }\n\n const computedY = isValid(height) ? Math.min(y, y + height) : Math.min(y, y1);\n return {\n to: { y: computedY, y1: isNil(y1) ? undefined : computedY, height: isNil(height) ? undefined : 0 }\n };\n}\n\nfunction growHeightOutOverall(\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) {\n const attrs = graphic.getFinalAttribute();\n const y1 = attrs.y1;\n const height = attrs.height;\n\n let overallValue: number;\n if (options && options.orient === 'negative') {\n if (isNumber(options.overall)) {\n overallValue = options.overall;\n } else if (animationParameters.group) {\n overallValue =\n (animationParameters as any).groupHeight ??\n options.layoutRect?.height ??\n animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = overallValue;\n } else {\n overallValue = animationParameters.height;\n }\n } else {\n overallValue = isNumber(options?.overall) ? options.overall : 0;\n }\n return {\n to: { y: overallValue, y1: isNil(y1) ? undefined : overallValue, height: isNil(height) ? undefined : 0 }\n };\n}\n\n/**\n * 增长渐出\n */\nexport const growHeightOut: TypeAnimation<IGraphic> = (\n graphic: IGraphic,\n options: IGrowCartesianAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return (options?.overall ?? false) !== false\n ? growHeightOutOverall(graphic, options, animationParameters)\n : growHeightOutIndividual(graphic, options, animationParameters);\n};\n\nexport class GrowHeightOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n super.onBind();\n const { from, to } = growHeightOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => to[key] != null);\n this.from = from ?? (this.target.attribute as any);\n this.to = to;\n // this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n"]}
|
|
@@ -39,5 +39,6 @@ export declare class AnimationStateManager {
|
|
|
39
39
|
applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): void;
|
|
40
40
|
stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void;
|
|
41
41
|
clearState(): void;
|
|
42
|
+
reApplyState(state: string): void;
|
|
42
43
|
}
|
|
43
44
|
export {};
|
|
@@ -114,5 +114,10 @@ export class AnimationStateManager {
|
|
|
114
114
|
state.executor.stop();
|
|
115
115
|
})), this.stateList = null;
|
|
116
116
|
}
|
|
117
|
+
reApplyState(state) {
|
|
118
|
+
var _a;
|
|
119
|
+
const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find((stateInfo => stateInfo.state === state));
|
|
120
|
+
stateInfo && (stateInfo.executor.stop(), stateInfo.executor.execute(stateInfo.animationConfig));
|
|
121
|
+
}
|
|
117
122
|
}
|
|
118
123
|
//# sourceMappingURL=animation-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/animation-state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAE1E,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;QAC1E,IAAI,CAAC,UAAU,CACb,CAAC,eAAe,CAAC,SAAS,CAAC,EAC3B,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,EACjE,QAAQ,CACT,CAAC;IACJ,CAAC;IAOD,qBAAqB,CAAC,eAAiC,EAAE,QAAqB;QAC5E,IAAI,CAAC,UAAU,CACb,CAAC,eAAe,CAAC,WAAW,CAAC,EAC7B,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,EACnE,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,KAAa,EAAE,IAA4C;;QACnE,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAC/E,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC/B;IACH,CAAC;IAED,UAAU;;QAER,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO,CAAC,KAAK,CAAC,EAAE;YAC9B,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CAKF","file":"animation-state.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationTransitionRegistry } from './animation-states-registry';\nimport type { IAnimationConfig } from '../executor/executor';\nimport { AnimateExecutor } from '../executor/animate-executor';\nimport { isArray } from '@visactor/vutils';\n\n// Standard animation state names\nexport const AnimationStates = {\n APPEAR: 'appear',\n DISAPPEAR: 'disappear',\n UPDATE: 'update',\n HIGHLIGHT: 'highlight',\n UNHIGHLIGHT: 'unhighlight',\n SELECT: 'select',\n UNSELECT: 'unselect',\n HOVER: 'hover',\n UNHOVER: 'unhover',\n ACTIVE: 'active',\n INACTIVE: 'inactive'\n};\n\nexport class AnimationStateStore {\n graphic: IGraphic;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // 动画状态配置\n // 并不是所有图元都有(只有mark才有),所以在应用状态的时候,需要额外传入\n states?: Map<string, IAnimationState>;\n\n registerState(state: IAnimationState): void {\n if (!this.states) {\n this.states = new Map();\n }\n this.states.set(state.name, state);\n }\n\n clearStates(): void {\n this.states?.clear();\n }\n}\n\n// 一个状态对应一个执行器,每个图元都有一一对应\ninterface IStateInfo {\n state: string;\n animationConfig: IAnimationConfig | IAnimationConfig[];\n executor: AnimateExecutor;\n}\n\nexport class AnimationStateManager {\n protected graphic: IGraphic;\n\n // 当前状态\n // TODO(注意,这里无法了解动画的顺序,既有串行也有并行,具体在执行的时候确定,执行之后就无法获取串行或并行配置了)\n stateList: IStateInfo[] | null = null;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // TODO 这里因为只有状态变更才会调用,所以代码写的比较宽松,如果有性能问题需要优化\n /**\n * 应用状态\n * @param nextState 下一个状态数组,如果传入数组,那么状态是串行的。但是每次applyState都会立即执行动画,也就是applyState和applyState之间是并行\n * @param animationConfig 动画配置\n * @param callback 动画结束后的回调函数,参数empty为true表示没有动画需要执行直接调的回调\n */\n applyState(\n nextState: string[],\n animationConfig: (IAnimationState | IAnimationState[])[],\n callback?: (empty?: boolean) => void\n ): void {\n const registry = AnimationTransitionRegistry.getInstance();\n\n // TODO 这里指判断第一个状态,后续如果需要的话要循环判断\n // 检查是否需要停止当前状态,以及下一个状态是否需要应用\n const shouldStopState: IStateInfo[] = [];\n const shouldApplyState: IStateInfo[] = [];\n if (!(this.stateList && this.stateList.length)) {\n nextState.forEach((state, index) => {\n shouldApplyState.push({\n state,\n animationConfig: isArray(animationConfig[index])\n ? (animationConfig[index] as IAnimationState[]).map(item => item.animation)\n : (animationConfig[index] as IAnimationState).animation,\n executor: new AnimateExecutor(this.graphic)\n });\n });\n } else {\n // const _stateList = this.stateList[0];\n nextState.forEach((state, index) => {\n // 遍历this.stateList,获取result,只要有一个是false,那这个result就是false\n const result: { allowTransition: boolean; stopOriginalTransition: boolean } = {\n allowTransition: true,\n stopOriginalTransition: true\n };\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n result.allowTransition = result.allowTransition && _result.allowTransition;\n });\n // 所有状态都允许过渡,则添加到shouldApplyState\n if (result.allowTransition) {\n shouldApplyState.push({\n state,\n animationConfig: isArray(animationConfig[index])\n ? (animationConfig[index] as IAnimationState[]).map(item => item.animation)\n : (animationConfig[index] as IAnimationState).animation,\n executor: new AnimateExecutor(this.graphic)\n });\n // 允许过渡的话,需要重新遍历this.stateList,获取stopOriginalTransition\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n if (_result.stopOriginalTransition) {\n shouldStopState.push(currState);\n }\n });\n }\n });\n }\n\n // 停止动画\n shouldStopState.forEach(state => {\n state.executor.stop();\n });\n\n // 立即应用动画,串行的应用\n if (shouldApplyState.length) {\n shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);\n // 如果下一个状态存在,那么下一个状态的动画在当前状态动画结束后立即执行\n for (let i = 0; i < shouldApplyState.length; i++) {\n const nextState = shouldApplyState[i + 1];\n const currentState = shouldApplyState[i];\n currentState.executor.onEnd(() => {\n if (nextState) {\n nextState.executor.execute(nextState.animationConfig);\n }\n // 删除这个状态\n this.stateList = this.stateList.filter(state => state !== currentState);\n\n // 如果是最后一个状态且有回调,则调用回调\n if (i === shouldApplyState.length - 1 && callback) {\n callback(false);\n }\n });\n }\n } else if (callback) {\n // 如果没有需要应用的动画状态,直接调用回调\n callback(true);\n }\n\n if (this.stateList) {\n this.stateList = this.stateList.filter(state => !shouldStopState.includes(state));\n } else {\n this.stateList = [];\n }\n this.stateList.push(...shouldApplyState);\n }\n\n /**\n * Apply a standard appear animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyAppearState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState([AnimationStates.APPEAR], [{ name: AnimationStates.APPEAR, animation: animationConfig }], callback);\n }\n\n /**\n * Apply a standard disappear animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyDisappearState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.DISAPPEAR],\n [{ name: AnimationStates.DISAPPEAR, animation: animationConfig }],\n callback\n );\n }\n\n /**\n * Apply a standard update animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState([AnimationStates.UPDATE], [{ name: AnimationStates.UPDATE, animation: animationConfig }], callback);\n }\n\n /**\n * Apply a standard highlight animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.HIGHLIGHT],\n [{ name: AnimationStates.HIGHLIGHT, animation: animationConfig }],\n callback\n );\n }\n\n /**\n * Apply a standard unhighlight animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.UNHIGHLIGHT],\n [{ name: AnimationStates.UNHIGHLIGHT, animation: animationConfig }],\n callback\n );\n }\n\n stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void {\n const stateInfo = this.stateList?.find(stateInfo => stateInfo.state === state);\n if (stateInfo) {\n stateInfo.executor.stop(type);\n }\n }\n\n clearState(): void {\n // 清空状态\n this.stateList?.forEach(state => {\n state.executor.stop();\n });\n this.stateList = null;\n }\n\n // getstateList(): string[] | null {\n // return this.stateList;\n // }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["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,CAAC,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;SACvD;IACH,CAAC;CAKF","file":"animation-state.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationTransitionRegistry } from './animation-states-registry';\nimport type { IAnimationConfig } from '../executor/executor';\nimport { AnimateExecutor } from '../executor/animate-executor';\nimport { isArray } from '@visactor/vutils';\n\n// Standard animation state names\nexport const AnimationStates = {\n APPEAR: 'appear',\n DISAPPEAR: 'disappear',\n UPDATE: 'update',\n HIGHLIGHT: 'highlight',\n UNHIGHLIGHT: 'unhighlight',\n SELECT: 'select',\n UNSELECT: 'unselect',\n HOVER: 'hover',\n UNHOVER: 'unhover',\n ACTIVE: 'active',\n INACTIVE: 'inactive'\n};\n\nexport class AnimationStateStore {\n graphic: IGraphic;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // 动画状态配置\n // 并不是所有图元都有(只有mark才有),所以在应用状态的时候,需要额外传入\n states?: Map<string, IAnimationState>;\n\n registerState(state: IAnimationState): void {\n if (!this.states) {\n this.states = new Map();\n }\n this.states.set(state.name, state);\n }\n\n clearStates(): void {\n this.states?.clear();\n }\n}\n\n// 一个状态对应一个执行器,每个图元都有一一对应\ninterface IStateInfo {\n state: string;\n animationConfig: IAnimationConfig | IAnimationConfig[];\n executor: AnimateExecutor;\n}\n\nexport class AnimationStateManager {\n protected graphic: IGraphic;\n\n // 当前状态\n // TODO(注意,这里无法了解动画的顺序,既有串行也有并行,具体在执行的时候确定,执行之后就无法获取串行或并行配置了)\n stateList: IStateInfo[] | null = null;\n\n constructor(graphic: IGraphic) {\n this.graphic = graphic;\n }\n\n // TODO 这里因为只有状态变更才会调用,所以代码写的比较宽松,如果有性能问题需要优化\n /**\n * 应用状态\n * @param nextState 下一个状态数组,如果传入数组,那么状态是串行的。但是每次applyState都会立即执行动画,也就是applyState和applyState之间是并行\n * @param animationConfig 动画配置\n * @param callback 动画结束后的回调函数,参数empty为true表示没有动画需要执行直接调的回调\n */\n applyState(\n nextState: string[],\n animationConfig: (IAnimationState | IAnimationState[])[],\n callback?: (empty?: boolean) => void\n ): void {\n const registry = AnimationTransitionRegistry.getInstance();\n\n // TODO 这里指判断第一个状态,后续如果需要的话要循环判断\n // 检查是否需要停止当前状态,以及下一个状态是否需要应用\n const shouldStopState: IStateInfo[] = [];\n const shouldApplyState: IStateInfo[] = [];\n if (!(this.stateList && this.stateList.length)) {\n nextState.forEach((state, index) => {\n shouldApplyState.push({\n state,\n animationConfig: isArray(animationConfig[index])\n ? (animationConfig[index] as IAnimationState[]).map(item => item.animation)\n : (animationConfig[index] as IAnimationState).animation,\n executor: new AnimateExecutor(this.graphic)\n });\n });\n } else {\n // const _stateList = this.stateList[0];\n nextState.forEach((state, index) => {\n // 遍历this.stateList,获取result,只要有一个是false,那这个result就是false\n const result: { allowTransition: boolean; stopOriginalTransition: boolean } = {\n allowTransition: true,\n stopOriginalTransition: true\n };\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n result.allowTransition = result.allowTransition && _result.allowTransition;\n });\n // 所有状态都允许过渡,则添加到shouldApplyState\n if (result.allowTransition) {\n shouldApplyState.push({\n state,\n animationConfig: isArray(animationConfig[index])\n ? (animationConfig[index] as IAnimationState[]).map(item => item.animation)\n : (animationConfig[index] as IAnimationState).animation,\n executor: new AnimateExecutor(this.graphic)\n });\n // 允许过渡的话,需要重新遍历this.stateList,获取stopOriginalTransition\n this.stateList.forEach(currState => {\n const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);\n if (_result.stopOriginalTransition) {\n shouldStopState.push(currState);\n }\n });\n }\n });\n }\n\n // 停止动画\n shouldStopState.forEach(state => {\n state.executor.stop();\n });\n\n // 立即应用动画,串行的应用\n if (shouldApplyState.length) {\n shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);\n // 如果下一个状态存在,那么下一个状态的动画在当前状态动画结束后立即执行\n for (let i = 0; i < shouldApplyState.length; i++) {\n const nextState = shouldApplyState[i + 1];\n const currentState = shouldApplyState[i];\n currentState.executor.onEnd(() => {\n if (nextState) {\n nextState.executor.execute(nextState.animationConfig);\n }\n // 删除这个状态\n this.stateList = this.stateList.filter(state => state !== currentState);\n\n // 如果是最后一个状态且有回调,则调用回调\n if (i === shouldApplyState.length - 1 && callback) {\n callback(false);\n }\n });\n }\n } else if (callback) {\n // 如果没有需要应用的动画状态,直接调用回调\n callback(true);\n }\n\n if (this.stateList) {\n this.stateList = this.stateList.filter(state => !shouldStopState.includes(state));\n } else {\n this.stateList = [];\n }\n this.stateList.push(...shouldApplyState);\n }\n\n /**\n * Apply a standard appear animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyAppearState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState([AnimationStates.APPEAR], [{ name: AnimationStates.APPEAR, animation: animationConfig }], callback);\n }\n\n /**\n * Apply a standard disappear animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyDisappearState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.DISAPPEAR],\n [{ name: AnimationStates.DISAPPEAR, animation: animationConfig }],\n callback\n );\n }\n\n /**\n * Apply a standard update animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState([AnimationStates.UPDATE], [{ name: AnimationStates.UPDATE, animation: animationConfig }], callback);\n }\n\n /**\n * Apply a standard highlight animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.HIGHLIGHT],\n [{ name: AnimationStates.HIGHLIGHT, animation: animationConfig }],\n callback\n );\n }\n\n /**\n * Apply a standard unhighlight animation to the graphic\n * @param animationConfig Animation configuration\n * @param callback Callback to be called when animation ends\n */\n applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): void {\n this.applyState(\n [AnimationStates.UNHIGHLIGHT],\n [{ name: AnimationStates.UNHIGHLIGHT, animation: animationConfig }],\n callback\n );\n }\n\n stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void {\n const stateInfo = this.stateList?.find(stateInfo => stateInfo.state === state);\n if (stateInfo) {\n stateInfo.executor.stop(type);\n }\n }\n\n clearState(): void {\n // 清空状态\n this.stateList?.forEach(state => {\n state.executor.stop();\n });\n this.stateList = null;\n }\n\n reApplyState(state: string): void {\n const stateInfo = this.stateList?.find(stateInfo => stateInfo.state === state);\n if (stateInfo) {\n stateInfo.executor.stop();\n stateInfo.executor.execute(stateInfo.animationConfig);\n }\n }\n\n // getstateList(): string[] | null {\n // return this.stateList;\n // }\n}\n"]}
|
|
@@ -12,7 +12,8 @@ export declare class GraphicStateExtension {
|
|
|
12
12
|
applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): this;
|
|
13
13
|
applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): this;
|
|
14
14
|
applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): this;
|
|
15
|
-
stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any
|
|
15
|
+
stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any>, deep?: boolean): this;
|
|
16
16
|
clearAnimationStates(): this;
|
|
17
|
+
reApplyAnimationState(state: string, deep?: boolean): this;
|
|
17
18
|
static extend(graphic: IGraphic): IGraphic;
|
|
18
19
|
}
|
|
@@ -36,12 +36,19 @@ export class GraphicStateExtension {
|
|
|
36
36
|
return this._getAnimationStateManager(this).applyUnhighlightState(animationConfig, callback),
|
|
37
37
|
this;
|
|
38
38
|
}
|
|
39
|
-
stopAnimationState(state, type) {
|
|
40
|
-
return this._getAnimationStateManager(this).stopState(state, type), this
|
|
39
|
+
stopAnimationState(state, type, deep = !1) {
|
|
40
|
+
return this._getAnimationStateManager(this).stopState(state, type), deep && this.isContainer && this.forEachChildren((child => {
|
|
41
|
+
child.stopAnimationState(state, type, deep);
|
|
42
|
+
})), this;
|
|
41
43
|
}
|
|
42
44
|
clearAnimationStates() {
|
|
43
45
|
return this._getAnimationStateManager(this).clearState(), this;
|
|
44
46
|
}
|
|
47
|
+
reApplyAnimationState(state, deep = !1) {
|
|
48
|
+
return this._getAnimationStateManager(this).reApplyState(state), deep && this.isContainer && this.forEachChildren((child => {
|
|
49
|
+
child.reApplyAnimationState(state, deep);
|
|
50
|
+
})), this;
|
|
51
|
+
}
|
|
45
52
|
static extend(graphic) {
|
|
46
53
|
return (new GraphicStateExtension)._getAnimationStateManager(graphic), graphic;
|
|
47
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/state/graphic-extension.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAM/E,MAAM,OAAO,qBAAqB;IAChC,yBAAyB,CAAC,OAAiB;QACzC,IAAI,CAAE,OAAe,CAAC,sBAAsB,EAAE;YAE3C,OAAe,CAAC,sBAAsB,GAAG,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC;SAC9E;QACD,OAAQ,OAAe,CAAC,sBAAsB,CAAC;IACjD,CAAC;IACD,uBAAuB,CAAC,OAAiB;QACvC,IAAI,CAAE,OAAe,CAAC,oBAAoB,EAAE;YAEzC,OAAe,CAAC,oBAAoB,GAAG,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;SAC1E;QACD,OAAQ,OAAe,CAAC,oBAAoB,CAAC;IAC/C,CAAC;IAKD,sBAAsB,CAAC,KAAsB;QAC3C,IAAI,CAAC,uBAAuB,CAAC,IAA2B,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,mBAAmB,CACjB,KAAe,EACf,eAAwD,EACxD,QAAoC;QAEpC,IAAI,CAAC,yB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AAC,MAAM,CAAC,OAAiB;QAC7B,MAAM,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAC9C,SAAS,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","file":"graphic-extension.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { IAnimationState } from './types';\nimport { AnimationStateManager, AnimationStateStore } from './animation-state';\nimport type { IAnimationConfig } from '../executor/executor';\n\n/**\n * 将动画状态方法作为混入扩展 Graphic 的类\n */\nexport class GraphicStateExtension {\n _getAnimationStateManager(graphic: IGraphic): AnimationStateManager {\n if (!(graphic as any)._animationStateManager) {\n // Create the appropriate manager type based on whether this is a group\n (graphic as any)._animationStateManager = new AnimationStateManager(graphic);\n }\n return (graphic as any)._animationStateManager;\n }\n _getAnimationStateStore(graphic: IGraphic): AnimationStateStore {\n if (!(graphic as any)._animationStateStore) {\n // Create the appropriate manager type based on whether this is a group\n (graphic as any)._animationStateStore = new AnimationStateStore(graphic);\n }\n return (graphic as any)._animationStateStore;\n }\n\n /**\n * 注册一个动画状态\n */\n registerAnimationState(state: IAnimationState): this {\n this._getAnimationStateStore(this as unknown as IGraphic).registerState(state);\n return this;\n }\n\n /**\n * 应用一个动画状态到图形\n */\n applyAnimationState(\n state: string[],\n animationConfig: (IAnimationState | IAnimationState[])[],\n callback?: (empty?: boolean) => void\n ): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyState(state, animationConfig, callback);\n return this;\n }\n\n /**\n * 应用出现动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyAppearState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyAppearState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用消失动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyDisappearState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyDisappearState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用更新动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyUpdateState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyUpdateState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用高亮动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyHighlightState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyHighlightState(animationConfig, callback);\n return this;\n }\n\n /**\n * 应用取消高亮动画状态\n * @param animationConfig 动画配置\n * @param callback 动画结束回调\n */\n applyUnhighlightState(animationConfig: IAnimationConfig, callback?: () => void): this {\n this._getAnimationStateManager(this as unknown as IGraphic).applyUnhighlightState(animationConfig, callback);\n return this;\n }\n\n /**\n * 停止一个动画状态\n */\n stopAnimationState(state: string, type?: 'start' | 'end' | Record<string, any>, deep: boolean = false): this {\n this._getAnimationStateManager(this as unknown as IGraphic).stopState(state, type);\n if (deep && (this as any).isContainer) {\n (this as any).forEachChildren((child: any) => {\n child.stopAnimationState(state, type, deep);\n });\n }\n return this;\n }\n\n /**\n * 清除图形上的所有动画状态\n */\n clearAnimationStates(): this {\n this._getAnimationStateManager(this as unknown as IGraphic).clearState();\n return this;\n }\n\n reApplyAnimationState(state: string, deep: boolean = false): this {\n this._getAnimationStateManager(this as unknown as IGraphic).reApplyState(state);\n if (deep && (this as any).isContainer) {\n (this as any).forEachChildren((child: any) => {\n child.reApplyAnimationState(state, deep);\n });\n }\n return this;\n }\n\n // /**\n // * 获取图形当前的动画状态\n // */\n // getCurrentAnimationState(): string[] | null {\n // return this._getAnimationStateManager(this as unknown as IGraphic).getCurrentState();\n // }\n\n /**\n * 继承\n */\n static extend(graphic: IGraphic): IGraphic {\n const extension = new GraphicStateExtension();\n extension._getAnimationStateManager(graphic);\n return graphic;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vrender-animate",
|
|
3
|
-
"version": "1.0.6
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@visactor/vutils": "1.0.6",
|
|
16
|
-
"@visactor/vrender-core": "1.0.6
|
|
16
|
+
"@visactor/vrender-core": "1.0.6"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@rushstack/eslint-patch": "~1.1.4",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"vite": "3.2.6",
|
|
30
30
|
"typescript": "4.9.5",
|
|
31
31
|
"cross-env": "^7.0.3",
|
|
32
|
-
"@internal/
|
|
32
|
+
"@internal/eslint-config": "0.0.1",
|
|
33
33
|
"@internal/ts-config": "0.0.1",
|
|
34
|
-
"@internal/
|
|
34
|
+
"@internal/bundler": "0.0.1"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
37
|
"VisActor",
|