@visactor/vrender-animate 1.0.5 → 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.
@@ -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
  }
@@ -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,G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,gBAAgB,EAAE;YAC1B,IAAI,CAAC,gBAAgB,GAAG,IAAI,kCAAe,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;AA9FD,4CA8FC","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,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,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,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC5C,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtC,QAAQ,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SAChD;QAGD,MAAC,IAAY,CA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函数\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"]}
@@ -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,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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AC,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,E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ClF,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QAE/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;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"]}
@@ -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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AAY,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 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,C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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"]}
@@ -56,7 +56,7 @@ export declare const moveIn: (graphic: IGraphic, options: IMoveAnimationOptions,
56
56
  };
57
57
  export declare const moveOut: (graphic: IGraphic, options: IMoveAnimationOptions, animationParameters: IAnimationParameters) => {
58
58
  from: {
59
- x: number;
59
+ x: any;
60
60
  y?: undefined;
61
61
  };
62
62
  to: {
@@ -65,7 +65,7 @@ export declare const moveOut: (graphic: IGraphic, options: IMoveAnimationOptions
65
65
  };
66
66
  } | {
67
67
  from: {
68
- y: number;
68
+ y: any;
69
69
  x?: undefined;
70
70
  };
71
71
  to: {
@@ -74,8 +74,8 @@ export declare const moveOut: (graphic: IGraphic, options: IMoveAnimationOptions
74
74
  };
75
75
  } | {
76
76
  from: {
77
- x: number;
78
- y: number;
77
+ x: any;
78
+ y: any;
79
79
  };
80
80
  to: {
81
81
  x: any;
@@ -11,13 +11,14 @@ const vutils_1 = require("@visactor/vutils"), custom_animate_1 = require("./cust
11
11
  "negative" === orient && (changedX = null !== (_a = layoutRect.width) && void 0 !== _a ? _a : graphic.stage.viewWidth,
12
12
  changedY = null !== (_b = layoutRect.height) && void 0 !== _b ? _b : graphic.stage.viewHeight),
13
13
  changedX += offset, changedY += offset;
14
- const point = (0, vutils_1.isFunction)(pointOpt) ? pointOpt.call(null, null === (_d = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.data) || void 0 === _d ? void 0 : _d[0], graphic, animationParameters) : pointOpt, fromX = point && (0,
15
- vutils_1.isValidNumber)(point.x) ? point.x : changedX, fromY = point && (0, vutils_1.isValidNumber)(point.y) ? point.y : changedY, finalAttrs = graphic.getFinalAttribute(), finalAttrsX = excludeChannels.includes("x") ? graphic.attribute.x : finalAttrs.x, finalAttrsY = excludeChannels.includes("y") ? graphic.attribute.y : finalAttrs.y;
14
+ const point = (0, vutils_1.isFunction)(pointOpt) ? pointOpt.call(null, null === (_d = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.data) || void 0 === _d ? void 0 : _d[0], graphic, animationParameters) : pointOpt, finalAttrsX = graphic.getGraphicAttribute("x"), finalAttrsY = graphic.getGraphicAttribute("y"), fromX = excludeChannels.includes("x") ? finalAttrsX : point && (0,
15
+ vutils_1.isValidNumber)(point.x) ? point.x : changedX, fromY = excludeChannels.includes("y") ? finalAttrsY : point && (0,
16
+ vutils_1.isValidNumber)(point.y) ? point.y : changedY;
16
17
  switch (direction) {
17
18
  case "x":
18
19
  return {
19
20
  from: {
20
- x: fromX
21
+ x: excludeChannels.includes("x") ? finalAttrsX : fromX
21
22
  },
22
23
  to: {
23
24
  x: finalAttrsX
@@ -59,7 +60,7 @@ const moveOut = (graphic, options, animationParameters) => {
59
60
  case "x":
60
61
  return {
61
62
  from: {
62
- x: graphic.attribute.x
63
+ x: graphic.getGraphicAttribute("x")
63
64
  },
64
65
  to: {
65
66
  x: fromX
@@ -69,7 +70,7 @@ const moveOut = (graphic, options, animationParameters) => {
69
70
  case "y":
70
71
  return {
71
72
  from: {
72
- y: graphic.attribute.y
73
+ y: graphic.getGraphicAttribute("y")
73
74
  },
74
75
  to: {
75
76
  y: fromY
@@ -79,8 +80,8 @@ const moveOut = (graphic, options, animationParameters) => {
79
80
  default:
80
81
  return {
81
82
  from: {
82
- x: graphic.attribute.x,
83
- y: graphic.attribute.y
83
+ x: graphic.getGraphicAttribute("x"),
84
+ y: graphic.getGraphicAttribute("y")
84
85
  },
85
86
  to: {
86
87
  x: fromX,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/custom/move.ts"],"names":[],"mappings":";;;AACA,6CAA6D;AAC7D,qDAAkD;AAyB3C,MAAM,MAAM,GAAG,CACpB,OAAiB,EACjB,OAA8B,EAC9B,mBAAyC,EACzC,E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from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\nexport type FunctionCallback<T> = (...args: any[]) => T;\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n excludeChannels?: string[];\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\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [], layoutRect = {} } = options ?? {};\n let changedX = 0;\n let changedY = 0;\n\n if (orient === 'negative') {\n changedX = (layoutRect as any).width ?? graphic.stage.viewWidth;\n changedY = (layoutRect as any).height ?? graphic.stage.viewHeight;\n }\n\n changedX += offset;\n changedY += offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n const finalAttrs = graphic.getFinalAttribute();\n const finalAttrsX = excludeChannels.includes('x') ? graphic.attribute.x : finalAttrs.x;\n const finalAttrsY = excludeChannels.includes('y') ? graphic.attribute.y : finalAttrs.y;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: fromX },\n to: { x: finalAttrsX }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: finalAttrsY }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: finalAttrsX,\n y: finalAttrsY\n }\n };\n }\n};\n\nexport const moveOut = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt } = options ?? {};\n\n const groupBounds = animationParameters.group ? animationParameters.group.AABBBounds : null;\n const groupWidth = groupBounds.width() ?? animationParameters.width;\n const groupHeight = groupBounds.height() ?? animationParameters.height;\n const changedX = (orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: graphic.attribute.x },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: graphic.attribute.y },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: graphic.attribute.x,\n y: graphic.attribute.y\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n\nexport class MoveBase 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 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\n/**\n * 增长渐入\n */\nexport class MoveIn extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveIn(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\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(from);\n }\n }\n}\n\nexport class MoveOut extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/custom/move.ts"],"names":[],"mappings":";;;AACA,6CAA6D;AAC7D,qDAAkD;AAyB3C,MAAM,MAAM,GAAG,CACpB,OAAiB,EACjB,OAA8B,EAC9B,mBAAyC,EACzC,EAAE;;IACF,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IAChH,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,IAAI,MAAM,KAAK,UAAU,EAAE;QACzB,QAAQ,GAAG,MAAC,UAAkB,CAAC,KAAK,mCAAI,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;QAChE,QAAQ,GAAG,MAAC,UAAkB,CAAC,MAAM,mCAAI,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC;KACnE;IAED,QAAQ,IAAI,MAAM,CAAC;IACnB,QAAQ,IAAI,MAAM,CAAC;IACnB,MAAM,KAAK,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC;QAChC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,IAAI,0CAAG,CAAC,CAAC,EAAE,OAAO,EAAE,mBAAmB,CAAC;QAC/E,CAAC,CAAC,QAAQ,CAAC;IACb,MAAM,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,KAAK,GA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CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAE,EAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;CACF;AATD,0BASC","file":"move.js","sourcesContent":["import type { EasingType, IGraphic, IGroup } from '@visactor/vrender-core';\nimport { isFunction, isValidNumber } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\nexport type FunctionCallback<T> = (...args: any[]) => T;\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n excludeChannels?: string[];\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\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [], layoutRect = {} } = options ?? {};\n let changedX = 0;\n let changedY = 0;\n\n if (orient === 'negative') {\n changedX = (layoutRect as any).width ?? graphic.stage.viewWidth;\n changedY = (layoutRect as any).height ?? graphic.stage.viewHeight;\n }\n\n changedX += offset;\n changedY += offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const finalAttrsX = graphic.getGraphicAttribute('x');\n const finalAttrsY = graphic.getGraphicAttribute('y');\n const fromX = excludeChannels.includes('x') ? finalAttrsX : point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = excludeChannels.includes('y') ? finalAttrsY : point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: excludeChannels.includes('x') ? finalAttrsX : fromX },\n to: { x: finalAttrsX }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: finalAttrsY }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: finalAttrsX,\n y: finalAttrsY\n }\n };\n }\n};\n\nexport const moveOut = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt } = options ?? {};\n\n const groupBounds = animationParameters.group ? animationParameters.group.AABBBounds : null;\n const groupWidth = groupBounds.width() ?? animationParameters.width;\n const groupHeight = groupBounds.height() ?? animationParameters.height;\n const changedX = (orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: graphic.getGraphicAttribute('x') },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: graphic.getGraphicAttribute('y') },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: graphic.getGraphicAttribute('x'),\n y: graphic.getGraphicAttribute('y')\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n\nexport class MoveBase 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 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\n/**\n * 增长渐入\n */\nexport class MoveIn extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveIn(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\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(from);\n }\n }\n}\n\nexport class MoveOut extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\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,E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AAqB;QAC5E,IAAI,CAAC,UAAU,CACb,CAAC,uBAAe,CAAC,WAAW,CAAC,EAC7B,CAAC,EAAE,IAAI,EAAE,uBAAe,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;AAxLD,sDAwLC","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":["../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;IACt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C,EAAE,QAAqB;QAC5E,IAAI,CAAC,UAAU,CACb,CAAC,uBAAe,CAAC,WAAW,CAAC,EAC7B,CAAC,EAAE,IAAI,EAAE,uBAAe,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;IAED,YAAY,CAAC,KAAa;;QACxB,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,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>): this;
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":[],"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gBAAgB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QACxG,OAAO,IAAI,CAAC;IACd,CAAC;IAOD,mBAAmB,CAAC,eAAiC,EAAE,QAAqB;QAC1E,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,mBAAmB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAC3G,OAAO,IAAI,CAAC;IACd,CAAC;IAOD,qBAAqB,CAAC,eAAiC,EAAE,QAAqB;QAC5E,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,qBAAqB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QAC7G,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,kBAAkB,CAAC,KAAa,EAAE,IAA4C;QAC5E,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,oBAAoB;QAClB,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,UAAU,EAAE,CAAC;QACzE,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;AArHD,sDAqHC","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>): this {\n this._getAnimationStateManager(this as unknown as IGraphic).stopState(state, type);\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 // /**\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"]}
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,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,yBAAyB,CAAC,IAA2B,CAAC,CAAC,UAAU,C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kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,oBAAoB;QAClB,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,UAAU,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qBAAqB,CAAC,KAAa,EAAE,OAAgB,KAAK;QACxD,IAAI,CAAC,yBAAyB,CAAC,IAA2B,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAChF,IAAI,IAAI,IAAK,IAAY,CAAC,WAAW,EAAE;YACpC,IAAY,CAAC,eAAe,CAAC,CAAC,KAAU,EAAE,EAAE;gBAC3C,KAAK,CAAC,qBAAqB,CAAC,KAAK,EAAE,IAAI,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"]}