@visactor/vgrammar-core 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/cjs/component/title.d.ts +4 -3
  2. package/cjs/component/title.js.map +1 -1
  3. package/cjs/graph/animation/animate.js +5 -3
  4. package/cjs/graph/animation/animate.js.map +1 -1
  5. package/cjs/graph/animation/animator.js +2 -1
  6. package/cjs/graph/animation/animator.js.map +1 -1
  7. package/cjs/graph/animation/config.js +9 -7
  8. package/cjs/graph/animation/config.js.map +1 -1
  9. package/cjs/graph/attributes/transform.js +1 -1
  10. package/cjs/graph/attributes/transform.js.map +1 -1
  11. package/cjs/graph/constants.d.ts +1 -0
  12. package/cjs/graph/constants.js +3 -3
  13. package/cjs/graph/constants.js.map +1 -1
  14. package/cjs/graph/element.d.ts +1 -1
  15. package/cjs/graph/element.js +13 -15
  16. package/cjs/graph/element.js.map +1 -1
  17. package/cjs/graph/glyph-element.js +2 -3
  18. package/cjs/graph/glyph-element.js.map +1 -1
  19. package/cjs/index.d.ts +1 -1
  20. package/cjs/index.js +1 -1
  21. package/cjs/index.js.map +1 -1
  22. package/cjs/parse/scale.js +1 -1
  23. package/cjs/parse/scale.js.map +1 -1
  24. package/cjs/semantic-marks/interval.js +4 -2
  25. package/cjs/semantic-marks/interval.js.map +1 -1
  26. package/cjs/transforms/data/contour.js +2 -1
  27. package/cjs/transforms/data/contour.js.map +1 -1
  28. package/cjs/transforms/data/sampling.js +3 -3
  29. package/cjs/transforms/data/sampling.js.map +1 -1
  30. package/cjs/transforms/data/unfold.js +2 -2
  31. package/cjs/transforms/data/unfold.js.map +1 -1
  32. package/cjs/transforms/mark/symmetry.js +2 -1
  33. package/cjs/transforms/mark/symmetry.js.map +1 -1
  34. package/cjs/transforms/util/util.d.ts +0 -2
  35. package/cjs/transforms/util/util.js +2 -11
  36. package/cjs/transforms/util/util.js.map +1 -1
  37. package/cjs/types/animate.d.ts +2 -0
  38. package/cjs/types/animate.js.map +1 -1
  39. package/cjs/types/component.d.ts +5 -5
  40. package/cjs/types/component.js.map +1 -1
  41. package/cjs/types/grammar.d.ts +2 -1
  42. package/cjs/types/grammar.js.map +1 -1
  43. package/cjs/types/mark.d.ts +1 -0
  44. package/cjs/types/mark.js.map +1 -1
  45. package/cjs/view/mark.d.ts +3 -1
  46. package/cjs/view/mark.js +9 -3
  47. package/cjs/view/mark.js.map +1 -1
  48. package/es/component/title.d.ts +4 -3
  49. package/es/component/title.js.map +1 -1
  50. package/es/graph/animation/animate.js +4 -3
  51. package/es/graph/animation/animate.js.map +1 -1
  52. package/es/graph/animation/animator.js +2 -1
  53. package/es/graph/animation/animator.js.map +1 -1
  54. package/es/graph/animation/config.js +10 -8
  55. package/es/graph/animation/config.js.map +1 -1
  56. package/es/graph/attributes/transform.js +1 -1
  57. package/es/graph/attributes/transform.js.map +1 -1
  58. package/es/graph/constants.d.ts +1 -0
  59. package/es/graph/constants.js +2 -0
  60. package/es/graph/constants.js.map +1 -1
  61. package/es/graph/element.d.ts +1 -1
  62. package/es/graph/element.js +13 -15
  63. package/es/graph/element.js.map +1 -1
  64. package/es/graph/glyph-element.js +2 -3
  65. package/es/graph/glyph-element.js.map +1 -1
  66. package/es/index.d.ts +1 -1
  67. package/es/index.js +1 -1
  68. package/es/index.js.map +1 -1
  69. package/es/interactions/brush-filter.js +2 -1
  70. package/es/interactions/element-highlight-by-group.js +1 -2
  71. package/es/interactions/index.js +2 -1
  72. package/es/interactions/legend-filter.js +1 -1
  73. package/es/interactions/player-filter.js +1 -1
  74. package/es/interactions/roll-up.js +1 -1
  75. package/es/interactions/scrollbar-filter.js +1 -1
  76. package/es/interactions/slider-filter.js +1 -1
  77. package/es/interactions/tooltip.js +1 -1
  78. package/es/interactions/view-drag-mixin.js +1 -1
  79. package/es/parse/coordinate.js +1 -1
  80. package/es/parse/event.js +1 -1
  81. package/es/parse/mark.js +1 -1
  82. package/es/parse/option.js +1 -1
  83. package/es/parse/scale.js +3 -4
  84. package/es/parse/scale.js.map +1 -1
  85. package/es/parse/transform.js +1 -1
  86. package/es/parse/util.js +1 -1
  87. package/es/parse/view.js +1 -1
  88. package/es/semantic-marks/interval.js +3 -3
  89. package/es/semantic-marks/interval.js.map +1 -1
  90. package/es/transforms/data/contour.js +2 -2
  91. package/es/transforms/data/contour.js.map +1 -1
  92. package/es/transforms/data/sampling.js +5 -3
  93. package/es/transforms/data/sampling.js.map +1 -1
  94. package/es/transforms/data/unfold.js +3 -3
  95. package/es/transforms/data/unfold.js.map +1 -1
  96. package/es/transforms/mark/symmetry.js +2 -2
  97. package/es/transforms/mark/symmetry.js.map +1 -1
  98. package/es/transforms/util/util.d.ts +0 -2
  99. package/es/transforms/util/util.js +0 -8
  100. package/es/transforms/util/util.js.map +1 -1
  101. package/es/types/animate.d.ts +2 -0
  102. package/es/types/animate.js.map +1 -1
  103. package/es/types/component.d.ts +5 -5
  104. package/es/types/component.js.map +1 -1
  105. package/es/types/grammar.d.ts +2 -1
  106. package/es/types/grammar.js.map +1 -1
  107. package/es/types/mark.d.ts +1 -0
  108. package/es/types/mark.js.map +1 -1
  109. package/es/view/mark.d.ts +3 -1
  110. package/es/view/mark.js +9 -3
  111. package/es/view/mark.js.map +1 -1
  112. package/package.json +10 -10
@@ -1,15 +1,16 @@
1
+ import type { IRichTextCharacter } from '@visactor/vrender-core';
1
2
  import type { TitleAttrs } from '@visactor/vrender-components';
2
3
  import type { IGroupMark, ITheme, IView, MarkFunctionType, Nil, RecursivePartial } from '../types';
3
4
  import type { ITitle, TitleSpec } from '../types/component';
4
5
  import { Component } from '../view/component';
5
- export declare const generateTitleAttributes: (title?: string | number | number[] | string[], subTitle?: string | number | number[] | string[], theme?: ITheme, addition?: RecursivePartial<TitleAttrs>) => TitleAttrs;
6
+ export declare const generateTitleAttributes: (title?: string | number | number[] | string[] | IRichTextCharacter[], subTitle?: string | number | number[] | string[] | IRichTextCharacter[], theme?: ITheme, addition?: RecursivePartial<TitleAttrs>) => TitleAttrs;
6
7
  export declare class Title extends Component implements ITitle {
7
8
  static readonly componentType: string;
8
9
  protected spec: TitleSpec;
9
10
  constructor(view: IView, group?: IGroupMark);
10
11
  protected parseAddition(spec: TitleSpec): this;
11
- title(text: MarkFunctionType<string | number | number[] | string[]> | Nil): this;
12
- subTitle(text: MarkFunctionType<string | number | number[] | string[]> | Nil): this;
12
+ title(text: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]> | Nil): this;
13
+ subTitle(text: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]> | Nil): this;
13
14
  protected _updateComponentEncoders(): void;
14
15
  }
15
16
  export declare const registerTitle: () => void;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/title.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAIlD,qEAAuE;AAYvE,0CAA+C;AAE/C,iDAA8C;AAC9C,iDAAqD;AACrD,wCAAmD;AACnD,6CAA0C;AAEnC,MAAM,uBAAuB,GAAG,CACrC,KAA6C,EAC7C,QAAgD,EAChD,KAAc,EACd,QAAuC,EAC3B,EAAE;;IACd,MAAM,UAAU,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,KAAK,CAAC;IAC5C,MAAM,UAAU,GAAiC,EAAE,CAAC;IACpD,IAAI,IAAA,gBAAO,EAAC,KAAK,CAAC,EAAE;QAClB,UAAU,CAAC,IAAI,GAAG,KAAK,CAAC;KACzB;IACD,IAAI,IAAA,gBAAO,EAAC,QAAQ,CAAC,EAAE;QACrB,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC;KAC/B;IACD,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC;AAC3D,CAAC,CAAC;AAfW,QAAA,uBAAuB,2BAelC;AAEF,MAAa,KAAM,SAAQ,qBAAS;IAIlC,YAAY,IAAW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AAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;wBAC9E,MAAM,QAAQ,GAAG,IAAA,yBAAkB,EAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;wBACpF,MAAM,QAAQ,GAAG,IAAA,sBAAa,EAAC,OAA+B,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;wBAC5F,OAAO,IAAA,+BAAuB,EAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;oBACnE,CAAC;iBACF,CAAC;aACH;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,IAAI,CAAC,SAAS,GAAG,iBAAiB,CAAC;IACrC,CAAC;;AA1CH,sBA2CC;AA1CiB,mBAAa,GAAW,qBAAa,CAAC,KAAK,CAAC;AA4CvD,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,iBAAO,CAAC,wBAAwB,CAC9B,qBAAa,CAAC,KAAK,EACnB,CAAC,KAAiB,EAAE,EAAE,CAAC,IAAI,0BAAc,CAAC,KAAK,CAAwB,CACxE,CAAC;IAEF,iBAAO,CAAC,iBAAiB,CAAC,qBAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC,CAAC;AAPW,QAAA,aAAa,iBAOxB","file":"title.js","sourcesContent":["import { isValid, merge } from '@visactor/vutils';\nimport type { IGraphic } from '@visactor/vrender-core';\nimport type { TitleAttrs } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { Title as TitleComponent } from '@visactor/vrender-components';\nimport type {\n BaseSignleEncodeSpec,\n IElement,\n IGroupMark,\n ITheme,\n IView,\n MarkFunctionType,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport { ComponentEnum } from '../graph/enums';\nimport type { ITitle, TitleSpec } from '../types/component';\nimport { Component } from '../view/component';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { invokeFunctionType } from '../parse/util';\nimport { Factory } from '../core/factory';\n\nexport const generateTitleAttributes = (\n title?: string | number | number[] | string[],\n subTitle?: string | number | number[] | string[],\n theme?: ITheme,\n addition?: RecursivePartial<TitleAttrs>\n): TitleAttrs => {\n const titleTheme = theme?.components?.title;\n const attributes: RecursivePartial<TitleAttrs> = {};\n if (isValid(title)) {\n attributes.text = title;\n }\n if (isValid(subTitle)) {\n attributes.subtext = subTitle;\n }\n return merge({}, titleTheme, attributes, addition ?? {});\n};\n\nexport class Title extends Component implements ITitle {\n static readonly componentType: string = ComponentEnum.title;\n protected declare spec: TitleSpec;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.title, group);\n this.spec.componentType = ComponentEnum.title;\n }\n\n protected parseAddition(spec: TitleSpec) {\n super.parseAddition(spec);\n this.title(spec.title);\n this.subTitle(spec.subTitle);\n return this;\n }\n\n title(text: MarkFunctionType<string | number | number[] | string[]> | Nil) {\n return this.setFunctionSpec(text, 'title');\n }\n\n subTitle(text: MarkFunctionType<string | number | number[] | string[]> | Nil) {\n return this.setFunctionSpec(text, 'subTitle');\n }\n\n protected _updateComponentEncoders() {\n const encoders = Object.assign({ update: {} }, this.spec.encode);\n const componentEncoders: StateEncodeSpec = Object.keys(encoders).reduce((res, state) => {\n const encoder = encoders[state];\n if (encoder) {\n res[state] = {\n callback: (datum: any, element: IElement, parameters: any) => {\n const theme = this.spec.skipTheme ? null : this.view.getCurrentTheme();\n const title = invokeFunctionType(this.spec.title, parameters, datum, element);\n const subTitle = invokeFunctionType(this.spec.subTitle, parameters, datum, element);\n const addition = invokeEncoder(encoder as BaseSignleEncodeSpec, datum, element, parameters);\n return generateTitleAttributes(title, subTitle, theme, addition);\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n}\n\nexport const registerTitle = () => {\n Factory.registerGraphicComponent(\n ComponentEnum.title,\n (attrs: TitleAttrs) => new TitleComponent(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.title, Title);\n};\n"]}
1
+ {"version":3,"sources":["../src/component/title.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAIlD,qEAAuE;AAYvE,0CAA+C;AAE/C,iDAA8C;AAC9C,iDAAqD;AACrD,wCAAmD;AACnD,6CAA0C;AAEnC,MAAM,uBAAuB,GAAG,CACrC,KAAoE,EACpE,QAAuE,EACvE,KAAc,EACd,QAAuC,EAC3B,EAAE;;IACd,MAAM,UAAU,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,KAAK,CAAC;IAC5C,MAAM,UAAU,GAAwB,EAAE,CAAC;IAC3C,IAAI,IAAA,gBAAO,EAAC,KAAK,CAAC,EAAE;QAClB,UAAU,CAAC,IAAI,GAAG,KAAK,CAAC;KACzB;IACD,IAAI,IAAA,gBAAO,EAAC,QAAQ,CAAC,EAAE;QACrB,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC;KAC/B;IACD,OAAO,IAAA,cAAK,EAAC,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,CAAC;AAC3D,CAAC,CAAC;AAfW,QAAA,uBAAuB,2BAelC;AAEF,MAAa,KAAM,SAAQ,qBAAS;IAIlC,YAAY,IAAW,EAAE,KAAkB;QACzC,KAAK,CAAC,IAAI,EAAE,qBAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,CAAC,aAAa,GAAG,qBAAa,CAAC,KAAK,CAAC;IAChD,CAAC;IAES,aAAa,CAAC,IAAe;QACrC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,Q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C,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;oBACnE,CAAC;iBACF,CAAC;aACH;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,IAAI,CAAC,SAAS,GAAG,iBAAiB,CAAC;IACrC,CAAC;;AA1CH,sBA2CC;AA1CiB,mBAAa,GAAW,qBAAa,CAAC,KAAK,CAAC;AA4CvD,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,iBAAO,CAAC,wBAAwB,CAC9B,qBAAa,CAAC,KAAK,EACnB,CAAC,KAAiB,EAAE,EAAE,CAAC,IAAI,0BAAc,CAAC,KAAK,CAAwB,CACxE,CAAC;IAEF,iBAAO,CAAC,iBAAiB,CAAC,qBAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC,CAAC;AAPW,QAAA,aAAa,iBAOxB","file":"title.js","sourcesContent":["import { isValid, merge } from '@visactor/vutils';\nimport type { IGraphic, IRichTextCharacter } from '@visactor/vrender-core';\nimport type { TitleAttrs } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport { Title as TitleComponent } from '@visactor/vrender-components';\nimport type {\n BaseSignleEncodeSpec,\n IElement,\n IGroupMark,\n ITheme,\n IView,\n MarkFunctionType,\n Nil,\n RecursivePartial,\n StateEncodeSpec\n} from '../types';\nimport { ComponentEnum } from '../graph/enums';\nimport type { ITitle, TitleSpec } from '../types/component';\nimport { Component } from '../view/component';\nimport { invokeEncoder } from '../graph/mark/encode';\nimport { invokeFunctionType } from '../parse/util';\nimport { Factory } from '../core/factory';\n\nexport const generateTitleAttributes = (\n title?: string | number | number[] | string[] | IRichTextCharacter[],\n subTitle?: string | number | number[] | string[] | IRichTextCharacter[],\n theme?: ITheme,\n addition?: RecursivePartial<TitleAttrs>\n): TitleAttrs => {\n const titleTheme = theme?.components?.title;\n const attributes: Partial<TitleAttrs> = {};\n if (isValid(title)) {\n attributes.text = title;\n }\n if (isValid(subTitle)) {\n attributes.subtext = subTitle;\n }\n return merge({}, titleTheme, attributes, addition ?? {});\n};\n\nexport class Title extends Component implements ITitle {\n static readonly componentType: string = ComponentEnum.title;\n protected declare spec: TitleSpec;\n\n constructor(view: IView, group?: IGroupMark) {\n super(view, ComponentEnum.title, group);\n this.spec.componentType = ComponentEnum.title;\n }\n\n protected parseAddition(spec: TitleSpec) {\n super.parseAddition(spec);\n this.title(spec.title);\n this.subTitle(spec.subTitle);\n return this;\n }\n\n title(text: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]> | Nil) {\n return this.setFunctionSpec(text, 'title');\n }\n\n subTitle(text: MarkFunctionType<string | number | number[] | string[] | IRichTextCharacter[]> | Nil) {\n return this.setFunctionSpec(text, 'subTitle');\n }\n\n protected _updateComponentEncoders() {\n const encoders = Object.assign({ update: {} }, this.spec.encode);\n const componentEncoders: StateEncodeSpec = Object.keys(encoders).reduce((res, state) => {\n const encoder = encoders[state];\n if (encoder) {\n res[state] = {\n callback: (datum: any, element: IElement, parameters: any) => {\n const theme = this.spec.skipTheme ? null : this.view.getCurrentTheme();\n const title = invokeFunctionType(this.spec.title, parameters, datum, element);\n const subTitle = invokeFunctionType(this.spec.subTitle, parameters, datum, element);\n const addition = invokeEncoder(encoder as BaseSignleEncodeSpec, datum, element, parameters);\n return generateTitleAttributes(title, subTitle, theme, addition);\n }\n };\n }\n return res;\n }, {});\n this._encoders = componentEncoders;\n }\n}\n\nexport const registerTitle = () => {\n Factory.registerGraphicComponent(\n ComponentEnum.title,\n (attrs: TitleAttrs) => new TitleComponent(attrs) as unknown as IGraphic\n );\n\n Factory.registerComponent(ComponentEnum.title, Title);\n};\n"]}
@@ -197,7 +197,8 @@ class Animate {
197
197
  let loopTime = 0;
198
198
  timeline.timeSlices.forEach((timeSlice => {
199
199
  var _a;
200
- const delay = (0, config_1.invokeAnimateSpec)(timeSlice.delay, element, parameters), duration = null !== (_a = (0,
200
+ const delay = (0, config_1.invokeAnimateSpec)(timeSlice.delay, element, parameters), delayAfter = (0,
201
+ config_1.invokeAnimateSpec)(timeSlice.delayAfter, element, parameters), duration = null !== (_a = (0,
201
202
  config_1.invokeAnimateSpec)(timeSlice.duration, element, parameters)) && void 0 !== _a ? _a : totalTime / elementCount, effects = (0,
202
203
  vutils_1.array)(timeSlice.effects).map((effect => Object.assign({}, effect, {
203
204
  customParameters: (0, config_1.invokeAnimateSpec)(effect.customParameters, element, parameters)
@@ -205,8 +206,9 @@ class Animate {
205
206
  timeSlices.push({
206
207
  effects: effects,
207
208
  duration: duration,
208
- delay: delay
209
- }), loopTime += delay + duration;
209
+ delay: delay,
210
+ delayAfter: delayAfter
211
+ }), loopTime += delay + duration + delayAfter;
210
212
  }));
211
213
  const oneByOneDelay = (0, vutils_1.isNumber)(oneByOne) ? oneByOne : !0 === oneByOne ? loopTime : 0;
212
214
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graph/animation/animate.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAW1D,yCAAsC;AACtC,qCAAsG;AACtG,4CAAmF;AAEnF,2CAAsD;AACtD,yCAAsC;AACtC,oCAAiD;AAEjD,MAAa,OAAO;IAqBlB,YAAY,IAAW,EAAE,MAA6D;QAnBtF,UAAK,GAAoC,IAAI,CAAC;QAE9C,qBAAgB,GAAkC,EAAE,CAAC;QAE7C,cAAS,GAAY,IAAI,CAAC;QAC1B,mBAAc,GAAa,EAAE,CAAC;QAE9B,cAAS,GAA6B,IAAI,GAAG,EAAE,CAAC;QAEhD,oBAAe,GAMnB,IAAI,OAAO,EAAE,CAAC;QACV,kBAAa,GAA2B,EAAE,CAAC;QAIjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,IAAA,iCAAwB,EAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,mBAAmB,CAAC,cAAsB;;QACxC,IAAI,CAAC,IAAI,CAA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AAc,EAAE;YAClB,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;YAE/C,IAAI,oBAAoB,EAAE;gBACxB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,gBAAgB,CAAC,EAAE,CAAC,CAAC;aACnG;SACF;QAED,IAAI,YAAY,EAAE;YAChB,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;gBAChD,IAAI,CAAC,gBAAgB,EAAE,CAAC;aACzB;iBAAM,IAAI,cAAc,KAAK,iBAAS,CAAC,IAAI,IAAI,oBAAoB,CAAC,iBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBAE1F,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;aAC5B;SACF;QAGD,MAAM,cAAc,GAAmB;YACrC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,cAAc;YACd,eAAe,EAAE,qBAAqB;SACvC,CAAC;QACF,IAAI,cAAc,EAAE;YAClB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAU,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;SAC1D;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAU,CAAC,qBAAqB,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;CACF;AAnfD,0BAmfC","file":"animate.js","sourcesContent":["import { array, isNil, isNumber } from '@visactor/vutils';\nimport type {\n IAnimate,\n IAnimationConfig,\n IAnimationParameters,\n IAnimationTimeline,\n IAnimationTimeSlice,\n IAnimationUnit,\n IAnimator,\n IParsedAnimationConfig\n} from '../../types/animate';\nimport { Animator } from './animator';\nimport { invokeAnimateSpec, normalizeAnimationConfig, normalizeStateAnimationConfig } from './config';\nimport { DefaultAnimationParameters, ImmediateAnimationState } from '../constants';\nimport type { AnimationEvent, IElement, IMark, MarkFunctionType } from '../../types';\nimport { invokeFunctionType } from '../../parse/util';\nimport { Arranger } from './arranger';\nimport { DiffState, HOOK_EVENT } from '../enums';\n\nexport class Animate implements IAnimate {\n mark: IMark;\n state: MarkFunctionType<string> | null = null;\n configs: Array<IParsedAnimationConfig>;\n immediateConfigs: Array<IParsedAnimationConfig> = [];\n\n private isEnabled: boolean = true;\n private disabledStates: string[] = [];\n // store animator by animation state\n private animators: Map<string, IAnimator[]> = new Map();\n // count animation for each elements\n private elementRecorder: WeakMap<\n IElement,\n {\n prevState: string;\n count: { [state: string]: number };\n }\n > = new WeakMap();\n private timelineCount: Record<string, number> = {};\n // record: IAnimationRecord;\n\n constructor(mark: IMark, config: Record<string, IAnimationConfig | IAnimationConfig[]>) {\n this.mark = mark;\n this.configs = normalizeAnimationConfig(config ?? {});\n }\n\n getAnimationConfigs(animationState: string) {\n if (!this.isEnabled) {\n return [];\n }\n return (this.configs ?? []).filter(config => config.state === animationState);\n }\n\n updateConfig(config: Record<string, IAnimationConfig | IAnimationConfig[]>) {\n this.configs = normalizeAnimationConfig(config ?? {});\n }\n\n updateState(state: MarkFunctionType<string> | null) {\n this.state = state;\n }\n\n animate() {\n if (!this.isEnabled || !this.configs || !this.configs.length) {\n return;\n }\n\n const elements = this.mark.getAllElements();\n const parameters = this.mark.parameters();\n\n elements.forEach(element => {\n // TODO: if element is restored, clear isReserved flag\n if (element.isReserved && element.diffState !== DiffState.exit) {\n element.isReserved = false;\n }\n // clear previous animation when animation state changed\n const prevElementState = this.elementRecorder.get(element)?.prevState;\n const needStopAnimation = this.configs.some(config => {\n return (\n prevElementState !== element.diffState &&\n config.state === prevElementState &&\n config.timeline.controlOptions.stopWhenStateChange\n );\n });\n if (needStopAnimation) {\n // do not clear exit element in case it will animate\n this.clearElementAnimation(element, false);\n }\n });\n\n this.configs.forEach(config => {\n this.animateByTimeline(config, elements, parameters);\n });\n\n this.mark.cleanExitElements();\n\n return this;\n }\n\n runAnimationByState(animationState: string) {\n if (!this.isEnabled) {\n return;\n }\n\n // FIXME: maybe do nothing if state animation is already running\n // if (this.animators.get(animationState)?.length > 0) { return; }\n\n const stateConfigs = this.configs.filter(config => config.state === animationState);\n const elements = this.mark.getAllElements();\n const parameters = this.mark.parameters();\n\n const animators = stateConfigs.reduce((animators, config) => {\n return animators.concat(this.animateByTimeline(config, elements, parameters, true));\n }, [] as IAnimator[]);\n\n return new Arranger(animators);\n }\n stopAnimationByState(animationState: string) {\n const animators = this.animators.get(animationState);\n if (animators) {\n animators.forEach(animator => animator.stop());\n }\n return this;\n }\n pauseAnimationByState(animationState: string) {\n const animators = this.animators.get(animationState);\n if (animators) {\n animators.forEach(animator => animator.pause());\n }\n return this;\n }\n resumeAnimationByState(animationState: string) {\n const animators = this.animators.get(animationState);\n if (animators) {\n animators.forEach(animator => animator.resume());\n }\n return this;\n }\n\n run(config: IAnimationConfig | IAnimationConfig[]) {\n if (!this.isEnabled) {\n return;\n }\n\n const parsedConfigs = normalizeStateAnimationConfig(ImmediateAnimationState, config, this.immediateConfigs.length);\n this.immediateConfigs = this.immediateConfigs.concat(parsedConfigs);\n const elements = this.mark.getAllElements();\n const parameters = this.mark.parameters();\n\n const animators = parsedConfigs.reduce((animators, config) => {\n return animators.concat(this.animateByTimeline(config, elements, parameters, true));\n }, [] as IAnimator[]);\n\n return new Arranger(animators);\n }\n stop() {\n // map will be cleared in animator callback\n this.animators.forEach(animators => {\n animators.forEach(animator => animator.stop());\n });\n return this;\n }\n pause() {\n this.animators.forEach(stateAnimators => stateAnimators.forEach(animator => animator.pause()));\n return this;\n }\n resume() {\n this.animators.forEach(stateAnimators => stateAnimators.forEach(animator => animator.resume()));\n return this;\n }\n reverse() {\n /** Animation scheduler api, resume the recorded animations */\n return this;\n }\n restart() {\n /** Animation scheduler api, resume current animations */\n return this;\n }\n record() {\n /** Animation scheduler api, start to record a timestamp */\n return this;\n }\n recordEnd() {\n /** Animation scheduler api, end to record a timestamp */\n return this;\n }\n\n isAnimating() {\n let isAnimating = false;\n this.animators.forEach(animators => {\n isAnimating = isAnimating || animators.some(animator => animator.isAnimating);\n });\n return isAnimating;\n }\n\n isElementAnimating(element: IElement) {\n const stateAnimationCounts = this.elementRecorder.get(element)?.count;\n return isNil(stateAnimationCounts) || Object.values(stateAnimationCounts).every(count => count === 0);\n }\n\n getAnimatorCount() {\n let count = 0;\n this.animators.forEach(animators => (count += animators.length));\n return count;\n }\n\n getAllAnimators() {\n const allAnimators: IAnimator[] = [];\n this.animators.forEach(animators => {\n allAnimators.push(...animators);\n });\n return allAnimators;\n }\n\n getElementAnimators(element: IElement | IElement[], animationState?: string) {\n const elements = array(element);\n let animators: IAnimator[] = [];\n if (animationState) {\n animators = this.animators.get(animationState) ?? [];\n } else {\n this.animators.forEach(stateAnimators => {\n animators = animators.concat(stateAnimators);\n });\n }\n return animators.filter(animator => elements.includes(animator.element));\n }\n\n enable() {\n this.isEnabled = true;\n return this;\n }\n disable() {\n this.isEnabled = false;\n this.stop();\n this.animators.clear();\n return this;\n }\n enableAnimationState(state: string | string[]) {\n const states = array(state);\n this.disabledStates = this.disabledStates.filter(state => !states.includes(state));\n return this;\n }\n disableAnimationState(state: string | string[]) {\n const states = array(state);\n this.disabledStates = this.disabledStates.concat(states);\n return this;\n }\n\n release() {\n this.stop();\n // we need to clear map\n this.animators.clear();\n\n this.configs = null;\n this.animators = null;\n this.elementRecorder = null;\n this.timelineCount = null;\n }\n\n private animateByTimeline(\n config: IParsedAnimationConfig,\n elements: IElement[],\n parameters: any,\n forceState: boolean = false\n ) {\n const animators: IAnimator[] = [];\n const animatedElements = elements.filter(element => {\n // do not animate on element which is running exit animation\n // if an element is reserved, it should be set for exit animation and will be removed\n const checkExit = !(element.isReserved && element.diffState === DiffState.exit);\n // do not check animation state if forceState is set\n const state = this.getAnimationState(element);\n const checkDisabled = !this.disabledStates.includes(state);\n const checkState = forceState || state === config.state;\n // filter elements by partitioner config\n const checkPartitioner =\n !config.timeline.partitioner || config.timeline.partitioner(element.getDatum(), element, parameters);\n return checkExit && checkDisabled && checkState && checkPartitioner;\n });\n\n if (animatedElements.length) {\n if (isNil(this.timelineCount[config.id])) {\n this.timelineCount[config.id] = 0;\n }\n\n if (config.timeline.sort) {\n animatedElements.sort((elementA, elementB) => {\n return config.timeline.sort(elementA.getDatum(), elementB.getDatum(), elementA, elementB, parameters);\n });\n }\n const width = this.mark.view.width();\n const height = this.mark.view.height();\n animatedElements.forEach((element, index) => {\n const animationParameters: IAnimationParameters = {\n width,\n height,\n group: this.mark.group ?? null,\n mark: this.mark,\n view: this.mark.view,\n elementCount: animatedElements.length,\n elementIndex: index\n };\n // add animation parameter into parameters\n const mergedParameters = Object.assign({ [DefaultAnimationParameters]: animationParameters }, parameters);\n const animationUnit = this.getAnimationUnit(\n config.timeline,\n element,\n index,\n animatedElements.length,\n mergedParameters\n );\n animators.push(this.animateElement(config, animationUnit, element, animationParameters, mergedParameters));\n });\n }\n return animators;\n }\n\n private animateElement(\n config: IParsedAnimationConfig,\n animationUnit: IAnimationUnit,\n element: IElement,\n animationParameters: IAnimationParameters,\n parameters: any\n ) {\n // create animator\n const animator = new Animator(element, animationUnit, config);\n\n // start animating\n animator.animate(animationParameters, parameters);\n // return when animator has no valid animation\n if (!animator.isAnimating) {\n return;\n }\n if (element.diffState === DiffState.exit) {\n element.isReserved = true;\n }\n\n const isFirstAnimator = this.timelineCount[config.id] === 0;\n\n this.timelineCount[config.id] += 1;\n const elementRecord = this.elementRecorder.get(element) ?? { prevState: config.state, count: {} };\n elementRecord.prevState = config.state;\n elementRecord.count[config.state] = (elementRecord.count[config.state] ?? 0) + 1;\n this.elementRecorder.set(element, elementRecord);\n const stateData = this.animators.get(config.state);\n if (!stateData) {\n this.animators.set(config.state, [animator]);\n } else {\n stateData.push(animator);\n }\n // this.animators.set(config.state, (this.animators.get(config.state) ?? []).concat(animator));\n // invoke callback when animation finish\n animator.callback(() => {\n this.handleAnimatorEnd(animator);\n });\n\n // FIXME: handle multiple timelines with same animation state\n // emit animation start event\n const animationEvent: AnimationEvent = {\n mark: this.mark,\n animationState: config.state,\n animationConfig: config.originConfig\n };\n if (isFirstAnimator) {\n this.mark.emit(HOOK_EVENT.ANIMATION_START, animationEvent);\n }\n this.mark.emit(HOOK_EVENT.ELEMENT_ANIMATION_START, animationEvent, element);\n\n return animator;\n }\n\n private getAnimationState(element: IElement): string {\n const customState = invokeFunctionType(this.state, this.mark.parameters(), element.getDatum(), element);\n return customState ?? element.diffState;\n }\n\n private getAnimationUnit(\n timeline: IAnimationTimeline,\n element: IElement,\n index: number,\n elementCount: number,\n parameters: any\n ): IAnimationUnit {\n const timeSlices: IAnimationTimeSlice[] = [];\n const startTime = invokeAnimateSpec(timeline.startTime, element, parameters);\n const totalTime = invokeAnimateSpec(timeline.totalTime, element, parameters);\n const oneByOne = invokeAnimateSpec(timeline.oneByOne, element, parameters);\n const loop = invokeAnimateSpec(timeline.loop, element, parameters);\n\n let loopTime = 0;\n (timeline.timeSlices as IAnimationTimeSlice[]).forEach(timeSlice => {\n const delay = invokeAnimateSpec(timeSlice.delay, element, parameters);\n const duration = invokeAnimateSpec(timeSlice.duration, element, parameters) ?? totalTime / elementCount;\n const effects = array(timeSlice.effects).map(effect =>\n Object.assign({}, effect, {\n customParameters: invokeAnimateSpec(effect.customParameters, element, parameters)\n })\n );\n timeSlices.push({\n effects,\n duration,\n delay\n });\n loopTime += delay + duration;\n });\n\n const oneByOneDelay = isNumber(oneByOne) ? oneByOne : oneByOne === true ? loopTime : 0;\n return {\n initialDelay: startTime,\n loopCount: isNumber(loop) ? loop : loop === true ? Infinity : 1,\n loopDelay: oneByOneDelay * index,\n loopDelayAfter: oneByOneDelay * (elementCount - index - 1),\n loopAnimateDuration: loopTime,\n loopDuration: loopTime + oneByOneDelay * (elementCount - 1),\n totalTime,\n timeSlices\n };\n }\n\n private clearElementAnimation(element: IElement, clearElement: boolean = true) {\n this.animators.forEach(animators => {\n animators.forEach(animator => {\n if (animator.element === element) {\n // if previous animation state is exit, modify graphic item channel to start\n if (animator.animationOptions.state === DiffState.exit) {\n animator.stop('start', false);\n } else {\n animator.stop('end', false);\n }\n this.handleAnimatorEnd(animator, clearElement);\n }\n });\n });\n this.elementRecorder.delete(element);\n }\n\n private clearAllElements() {\n const elements = this.mark.getAllElements();\n if (elements) {\n elements.forEach((element, i) => {\n // only update mark in previous invocation\n this.clearElement(element, i === elements.length - 1);\n });\n }\n }\n\n private clearElement(element: IElement, updateMark: boolean = true) {\n this.clearElementAnimation(element);\n // element might already be released\n if (element.getGraphicItem()) {\n // if element stops animating or needs to be removed, clear all cached attributes\n element.clearGraphicAttributes();\n // remove element from mark if exit animation is finished\n if (element.diffState === DiffState.exit) {\n element.isReserved = false;\n }\n if (updateMark) {\n this.mark.cleanExitElements();\n }\n // TODO: waiting for vRender to optimize bound cache logic, otherwise this line\n // will cause huge performance waste in multiple animation like appear & disappear.\n // if (updateMark) mark.updateBounds();\n }\n }\n\n private handleAnimatorEnd(animator: IAnimator, clearElement: boolean = true) {\n const element = animator.element;\n const animationOptions = animator.animationOptions;\n const animationState = animationOptions.state;\n const isImmediateAnimation = animationState === ImmediateAnimationState;\n\n // sub element animation count\n const stateAnimationCounts = this.elementRecorder.get(element).count;\n stateAnimationCounts[animationState] -= 1;\n // FIXME: maybe delete zero animationState\n // if (stateAnimationCounts[animationState] === 0) {\n // delete stateAnimationCounts[animationState];\n // }\n\n this.animators.set(\n animationState,\n this.animators.get(animationState).filter(ani => ani !== animator)\n );\n if (this.animators.get(animationState).length === 0) {\n this.animators.delete(animationState);\n }\n this.timelineCount[animationOptions.id] -= 1;\n const isLastAnimator = this.timelineCount[animationOptions.id] === 0;\n\n const originAnimationConfig = isImmediateAnimation\n ? this.immediateConfigs.find(config => config.id === animationOptions.id).originConfig\n : this.configs.find(config => config.id === animationOptions.id).originConfig;\n if (isLastAnimator) {\n delete this.timelineCount[animationOptions.id];\n // delete config when immediate executed animation is finished\n if (isImmediateAnimation) {\n this.immediateConfigs = this.immediateConfigs.filter(config => config.id !== animationOptions.id);\n }\n }\n\n if (clearElement) {\n if (Object.keys(this.timelineCount).length === 0) {\n this.clearAllElements();\n } else if (animationState === DiffState.exit && stateAnimationCounts[DiffState.exit] === 0) {\n // if all exit animations are finished\n this.clearElement(element);\n }\n }\n\n // emit animation end event\n const animationEvent: AnimationEvent = {\n mark: this.mark,\n animationState,\n animationConfig: originAnimationConfig\n };\n if (isLastAnimator) {\n this.mark.emit(HOOK_EVENT.ANIMATION_END, animationEvent);\n }\n this.mark.emit(HOOK_EVENT.ELEMENT_ANIMATION_END, animationEvent, element);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/graph/animation/animate.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAW1D,yCAAsC;AACtC,qCAAsG;AACtG,4CAAmF;AAEnF,2CAAsD;AACtD,yCAAsC;AACtC,oCAAiD;AAEjD,MAAa,OAAO;IAqBlB,YAAY,IAAW,EAAE,MAA6D;QAnBtF,UAAK,GAAoC,IAAI,CAAC;QAE9C,qBAAgB,GAAkC,EAAE,CAAC;QAE7C,cAAS,GAAY,IAAI,CAAC;QAC1B,mBAAc,GAAa,EAAE,CAAC;QAE9B,cAAS,GAA6B,IAAI,GAAG,EAAE,CAAC;QAEhD,oBAAe,GAMnB,IAAI,OAAO,EAAE,CAAC;QACV,kBAAa,GAA2B,EAAE,CAAC;QAIjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,IAAA,iCAAwB,EAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,mBAAmB,CAAC,cAAsB;;QACxC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,OAAO,EAAE,CAAC;SACX;QACD,OAAO,CAAC,MAAA,IAAI,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CA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AO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;YAE/C,IAAI,oBAAoB,EAAE;gBACxB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,gBAAgB,CAAC,EAAE,CAAC,CAAC;aACnG;SACF;QAED,IAAI,YAAY,EAAE;YAChB,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;gBAChD,IAAI,CAAC,gBAAgB,EAAE,CAAC;aACzB;iBAAM,IAAI,cAAc,KAAK,iBAAS,CAAC,IAAI,IAAI,oBAAoB,CAAC,iBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBAE1F,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;aAC5B;SACF;QAGD,MAAM,cAAc,GAAmB;YACrC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,cAAc;YACd,eAAe,EAAE,qBAAqB;SACvC,CAAC;QACF,IAAI,cAAc,EAAE;YAClB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAU,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;SAC1D;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAU,CAAC,qBAAqB,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;CACF;AArfD,0BAqfC","file":"animate.js","sourcesContent":["import { array, isNil, isNumber } from '@visactor/vutils';\nimport type {\n IAnimate,\n IAnimationConfig,\n IAnimationParameters,\n IAnimationTimeline,\n IAnimationTimeSlice,\n IAnimationUnit,\n IAnimator,\n IParsedAnimationConfig\n} from '../../types/animate';\nimport { Animator } from './animator';\nimport { invokeAnimateSpec, normalizeAnimationConfig, normalizeStateAnimationConfig } from './config';\nimport { DefaultAnimationParameters, ImmediateAnimationState } from '../constants';\nimport type { AnimationEvent, IElement, IMark, MarkFunctionType } from '../../types';\nimport { invokeFunctionType } from '../../parse/util';\nimport { Arranger } from './arranger';\nimport { DiffState, HOOK_EVENT } from '../enums';\n\nexport class Animate implements IAnimate {\n mark: IMark;\n state: MarkFunctionType<string> | null = null;\n configs: Array<IParsedAnimationConfig>;\n immediateConfigs: Array<IParsedAnimationConfig> = [];\n\n private isEnabled: boolean = true;\n private disabledStates: string[] = [];\n // store animator by animation state\n private animators: Map<string, IAnimator[]> = new Map();\n // count animation for each elements\n private elementRecorder: WeakMap<\n IElement,\n {\n prevState: string;\n count: { [state: string]: number };\n }\n > = new WeakMap();\n private timelineCount: Record<string, number> = {};\n // record: IAnimationRecord;\n\n constructor(mark: IMark, config: Record<string, IAnimationConfig | IAnimationConfig[]>) {\n this.mark = mark;\n this.configs = normalizeAnimationConfig(config ?? {});\n }\n\n getAnimationConfigs(animationState: string) {\n if (!this.isEnabled) {\n return [];\n }\n return (this.configs ?? []).filter(config => config.state === animationState);\n }\n\n updateConfig(config: Record<string, IAnimationConfig | IAnimationConfig[]>) {\n this.configs = normalizeAnimationConfig(config ?? {});\n }\n\n updateState(state: MarkFunctionType<string> | null) {\n this.state = state;\n }\n\n animate() {\n if (!this.isEnabled || !this.configs || !this.configs.length) {\n return;\n }\n\n const elements = this.mark.getAllElements();\n const parameters = this.mark.parameters();\n\n elements.forEach(element => {\n // TODO: if element is restored, clear isReserved flag\n if (element.isReserved && element.diffState !== DiffState.exit) {\n element.isReserved = false;\n }\n // clear previous animation when animation state changed\n const prevElementState = this.elementRecorder.get(element)?.prevState;\n const needStopAnimation = this.configs.some(config => {\n return (\n prevElementState !== element.diffState &&\n config.state === prevElementState &&\n config.timeline.controlOptions.stopWhenStateChange\n );\n });\n if (needStopAnimation) {\n // do not clear exit element in case it will animate\n this.clearElementAnimation(element, false);\n }\n });\n\n this.configs.forEach(config => {\n this.animateByTimeline(config, elements, parameters);\n });\n\n this.mark.cleanExitElements();\n\n return this;\n }\n\n runAnimationByState(animationState: string) {\n if (!this.isEnabled) {\n return;\n }\n\n // FIXME: maybe do nothing if state animation is already running\n // if (this.animators.get(animationState)?.length > 0) { return; }\n\n const stateConfigs = this.configs.filter(config => config.state === animationState);\n const elements = this.mark.getAllElements();\n const parameters = this.mark.parameters();\n\n const animators = stateConfigs.reduce((animators, config) => {\n return animators.concat(this.animateByTimeline(config, elements, parameters, true));\n }, [] as IAnimator[]);\n\n return new Arranger(animators);\n }\n stopAnimationByState(animationState: string) {\n const animators = this.animators.get(animationState);\n if (animators) {\n animators.forEach(animator => animator.stop());\n }\n return this;\n }\n pauseAnimationByState(animationState: string) {\n const animators = this.animators.get(animationState);\n if (animators) {\n animators.forEach(animator => animator.pause());\n }\n return this;\n }\n resumeAnimationByState(animationState: string) {\n const animators = this.animators.get(animationState);\n if (animators) {\n animators.forEach(animator => animator.resume());\n }\n return this;\n }\n\n run(config: IAnimationConfig | IAnimationConfig[]) {\n if (!this.isEnabled) {\n return;\n }\n\n const parsedConfigs = normalizeStateAnimationConfig(ImmediateAnimationState, config, this.immediateConfigs.length);\n this.immediateConfigs = this.immediateConfigs.concat(parsedConfigs);\n const elements = this.mark.getAllElements();\n const parameters = this.mark.parameters();\n\n const animators = parsedConfigs.reduce((animators, config) => {\n return animators.concat(this.animateByTimeline(config, elements, parameters, true));\n }, [] as IAnimator[]);\n\n return new Arranger(animators);\n }\n stop() {\n // map will be cleared in animator callback\n this.animators.forEach(animators => {\n animators.forEach(animator => animator.stop());\n });\n return this;\n }\n pause() {\n this.animators.forEach(stateAnimators => stateAnimators.forEach(animator => animator.pause()));\n return this;\n }\n resume() {\n this.animators.forEach(stateAnimators => stateAnimators.forEach(animator => animator.resume()));\n return this;\n }\n reverse() {\n /** Animation scheduler api, resume the recorded animations */\n return this;\n }\n restart() {\n /** Animation scheduler api, resume current animations */\n return this;\n }\n record() {\n /** Animation scheduler api, start to record a timestamp */\n return this;\n }\n recordEnd() {\n /** Animation scheduler api, end to record a timestamp */\n return this;\n }\n\n isAnimating() {\n let isAnimating = false;\n this.animators.forEach(animators => {\n isAnimating = isAnimating || animators.some(animator => animator.isAnimating);\n });\n return isAnimating;\n }\n\n isElementAnimating(element: IElement) {\n const stateAnimationCounts = this.elementRecorder.get(element)?.count;\n return isNil(stateAnimationCounts) || Object.values(stateAnimationCounts).every(count => count === 0);\n }\n\n getAnimatorCount() {\n let count = 0;\n this.animators.forEach(animators => (count += animators.length));\n return count;\n }\n\n getAllAnimators() {\n const allAnimators: IAnimator[] = [];\n this.animators.forEach(animators => {\n allAnimators.push(...animators);\n });\n return allAnimators;\n }\n\n getElementAnimators(element: IElement | IElement[], animationState?: string) {\n const elements = array(element);\n let animators: IAnimator[] = [];\n if (animationState) {\n animators = this.animators.get(animationState) ?? [];\n } else {\n this.animators.forEach(stateAnimators => {\n animators = animators.concat(stateAnimators);\n });\n }\n return animators.filter(animator => elements.includes(animator.element));\n }\n\n enable() {\n this.isEnabled = true;\n return this;\n }\n disable() {\n this.isEnabled = false;\n this.stop();\n this.animators.clear();\n return this;\n }\n enableAnimationState(state: string | string[]) {\n const states = array(state);\n this.disabledStates = this.disabledStates.filter(state => !states.includes(state));\n return this;\n }\n disableAnimationState(state: string | string[]) {\n const states = array(state);\n this.disabledStates = this.disabledStates.concat(states);\n return this;\n }\n\n release() {\n this.stop();\n // we need to clear map\n this.animators.clear();\n\n this.configs = null;\n this.animators = null;\n this.elementRecorder = null;\n this.timelineCount = null;\n }\n\n private animateByTimeline(\n config: IParsedAnimationConfig,\n elements: IElement[],\n parameters: any,\n forceState: boolean = false\n ) {\n const animators: IAnimator[] = [];\n const animatedElements = elements.filter(element => {\n // do not animate on element which is running exit animation\n // if an element is reserved, it should be set for exit animation and will be removed\n const checkExit = !(element.isReserved && element.diffState === DiffState.exit);\n // do not check animation state if forceState is set\n const state = this.getAnimationState(element);\n const checkDisabled = !this.disabledStates.includes(state);\n const checkState = forceState || state === config.state;\n // filter elements by partitioner config\n const checkPartitioner =\n !config.timeline.partitioner || config.timeline.partitioner(element.getDatum(), element, parameters);\n return checkExit && checkDisabled && checkState && checkPartitioner;\n });\n\n if (animatedElements.length) {\n if (isNil(this.timelineCount[config.id])) {\n this.timelineCount[config.id] = 0;\n }\n\n if (config.timeline.sort) {\n animatedElements.sort((elementA, elementB) => {\n return config.timeline.sort(elementA.getDatum(), elementB.getDatum(), elementA, elementB, parameters);\n });\n }\n const width = this.mark.view.width();\n const height = this.mark.view.height();\n animatedElements.forEach((element, index) => {\n const animationParameters: IAnimationParameters = {\n width,\n height,\n group: this.mark.group ?? null,\n mark: this.mark,\n view: this.mark.view,\n elementCount: animatedElements.length,\n elementIndex: index\n };\n // add animation parameter into parameters\n const mergedParameters = Object.assign({ [DefaultAnimationParameters]: animationParameters }, parameters);\n const animationUnit = this.getAnimationUnit(\n config.timeline,\n element,\n index,\n animatedElements.length,\n mergedParameters\n );\n animators.push(this.animateElement(config, animationUnit, element, animationParameters, mergedParameters));\n });\n }\n return animators;\n }\n\n private animateElement(\n config: IParsedAnimationConfig,\n animationUnit: IAnimationUnit,\n element: IElement,\n animationParameters: IAnimationParameters,\n parameters: any\n ) {\n // create animator\n const animator = new Animator(element, animationUnit, config);\n\n // start animating\n animator.animate(animationParameters, parameters);\n // return when animator has no valid animation\n if (!animator.isAnimating) {\n return;\n }\n if (element.diffState === DiffState.exit) {\n element.isReserved = true;\n }\n\n const isFirstAnimator = this.timelineCount[config.id] === 0;\n\n this.timelineCount[config.id] += 1;\n const elementRecord = this.elementRecorder.get(element) ?? { prevState: config.state, count: {} };\n elementRecord.prevState = config.state;\n elementRecord.count[config.state] = (elementRecord.count[config.state] ?? 0) + 1;\n this.elementRecorder.set(element, elementRecord);\n const stateData = this.animators.get(config.state);\n if (!stateData) {\n this.animators.set(config.state, [animator]);\n } else {\n stateData.push(animator);\n }\n // this.animators.set(config.state, (this.animators.get(config.state) ?? []).concat(animator));\n // invoke callback when animation finish\n animator.callback(() => {\n this.handleAnimatorEnd(animator);\n });\n\n // FIXME: handle multiple timelines with same animation state\n // emit animation start event\n const animationEvent: AnimationEvent = {\n mark: this.mark,\n animationState: config.state,\n animationConfig: config.originConfig\n };\n if (isFirstAnimator) {\n this.mark.emit(HOOK_EVENT.ANIMATION_START, animationEvent);\n }\n this.mark.emit(HOOK_EVENT.ELEMENT_ANIMATION_START, animationEvent, element);\n\n return animator;\n }\n\n private getAnimationState(element: IElement): string {\n const customState = invokeFunctionType(this.state, this.mark.parameters(), element.getDatum(), element);\n return customState ?? element.diffState;\n }\n\n private getAnimationUnit(\n timeline: IAnimationTimeline,\n element: IElement,\n index: number,\n elementCount: number,\n parameters: any\n ): IAnimationUnit {\n const timeSlices: IAnimationTimeSlice[] = [];\n const startTime = invokeAnimateSpec(timeline.startTime, element, parameters);\n const totalTime = invokeAnimateSpec(timeline.totalTime, element, parameters);\n const oneByOne = invokeAnimateSpec(timeline.oneByOne, element, parameters);\n const loop = invokeAnimateSpec(timeline.loop, element, parameters);\n\n let loopTime = 0;\n (timeline.timeSlices as IAnimationTimeSlice[]).forEach(timeSlice => {\n const delay = invokeAnimateSpec(timeSlice.delay, element, parameters);\n const delayAfter = invokeAnimateSpec(timeSlice.delayAfter, element, parameters);\n const duration = invokeAnimateSpec(timeSlice.duration, element, parameters) ?? totalTime / elementCount;\n const effects = array(timeSlice.effects).map(effect =>\n Object.assign({}, effect, {\n customParameters: invokeAnimateSpec(effect.customParameters, element, parameters)\n })\n );\n timeSlices.push({\n effects,\n duration,\n delay,\n delayAfter\n });\n loopTime += delay + duration + delayAfter;\n });\n\n const oneByOneDelay = isNumber(oneByOne) ? oneByOne : oneByOne === true ? loopTime : 0;\n return {\n initialDelay: startTime,\n loopCount: isNumber(loop) ? loop : loop === true ? Infinity : 1,\n loopDelay: oneByOneDelay * index,\n loopDelayAfter: oneByOneDelay * (elementCount - index - 1),\n loopAnimateDuration: loopTime,\n loopDuration: loopTime + oneByOneDelay * (elementCount - 1),\n totalTime,\n timeSlices\n };\n }\n\n private clearElementAnimation(element: IElement, clearElement: boolean = true) {\n this.animators.forEach(animators => {\n animators.forEach(animator => {\n if (animator.element === element) {\n // if previous animation state is exit, modify graphic item channel to start\n if (animator.animationOptions.state === DiffState.exit) {\n animator.stop('start', false);\n } else {\n animator.stop('end', false);\n }\n this.handleAnimatorEnd(animator, clearElement);\n }\n });\n });\n this.elementRecorder.delete(element);\n }\n\n private clearAllElements() {\n const elements = this.mark.getAllElements();\n if (elements) {\n elements.forEach((element, i) => {\n // only update mark in previous invocation\n this.clearElement(element, i === elements.length - 1);\n });\n }\n }\n\n private clearElement(element: IElement, updateMark: boolean = true) {\n this.clearElementAnimation(element);\n // element might already be released\n if (element.getGraphicItem()) {\n // if element stops animating or needs to be removed, clear all cached attributes\n element.clearGraphicAttributes();\n // remove element from mark if exit animation is finished\n if (element.diffState === DiffState.exit) {\n element.isReserved = false;\n }\n if (updateMark) {\n this.mark.cleanExitElements();\n }\n // TODO: waiting for vRender to optimize bound cache logic, otherwise this line\n // will cause huge performance waste in multiple animation like appear & disappear.\n // if (updateMark) mark.updateBounds();\n }\n }\n\n private handleAnimatorEnd(animator: IAnimator, clearElement: boolean = true) {\n const element = animator.element;\n const animationOptions = animator.animationOptions;\n const animationState = animationOptions.state;\n const isImmediateAnimation = animationState === ImmediateAnimationState;\n\n // sub element animation count\n const stateAnimationCounts = this.elementRecorder.get(element).count;\n stateAnimationCounts[animationState] -= 1;\n // FIXME: maybe delete zero animationState\n // if (stateAnimationCounts[animationState] === 0) {\n // delete stateAnimationCounts[animationState];\n // }\n\n this.animators.set(\n animationState,\n this.animators.get(animationState).filter(ani => ani !== animator)\n );\n if (this.animators.get(animationState).length === 0) {\n this.animators.delete(animationState);\n }\n this.timelineCount[animationOptions.id] -= 1;\n const isLastAnimator = this.timelineCount[animationOptions.id] === 0;\n\n const originAnimationConfig = isImmediateAnimation\n ? this.immediateConfigs.find(config => config.id === animationOptions.id).originConfig\n : this.configs.find(config => config.id === animationOptions.id).originConfig;\n if (isLastAnimator) {\n delete this.timelineCount[animationOptions.id];\n // delete config when immediate executed animation is finished\n if (isImmediateAnimation) {\n this.immediateConfigs = this.immediateConfigs.filter(config => config.id !== animationOptions.id);\n }\n }\n\n if (clearElement) {\n if (Object.keys(this.timelineCount).length === 0) {\n this.clearAllElements();\n } else if (animationState === DiffState.exit && stateAnimationCounts[DiffState.exit] === 0) {\n // if all exit animations are finished\n this.clearElement(element);\n }\n }\n\n // emit animation end event\n const animationEvent: AnimationEvent = {\n mark: this.mark,\n animationState,\n animationConfig: originAnimationConfig\n };\n if (isLastAnimator) {\n this.mark.emit(HOOK_EVENT.ANIMATION_END, animationEvent);\n }\n this.mark.emit(HOOK_EVENT.ELEMENT_ANIMATION_END, animationEvent, element);\n }\n}\n"]}
@@ -67,7 +67,7 @@ class Animator {
67
67
  }));
68
68
  }
69
69
  animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters) {
70
- const delay = timeSlice.delay, duration = timeSlice.duration, effects = timeSlice.effects;
70
+ const delay = timeSlice.delay, delayAfter = timeSlice.delayAfter, duration = timeSlice.duration, effects = timeSlice.effects;
71
71
  if (delay > 0 && graphicAnimate.wait(delay), effects.length < 0) graphicAnimate.wait(duration); else {
72
72
  const customAnimates = effects.map(((effect, index) => {
73
73
  var _a;
@@ -83,6 +83,7 @@ class Animator {
83
83
  })).filter((animate => !(0, vutils_1.isNil)(animate)));
84
84
  1 === customAnimates.length ? graphicAnimate.play(customAnimates[0]) : graphicAnimate.play(new vrender_core_1.AnimateGroup(duration, customAnimates));
85
85
  }
86
+ delayAfter > 0 && graphicAnimate.wait(delayAfter);
86
87
  }
87
88
  }
88
89
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graph/animation/animator.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AAGxD,yDAA4F;AAa5F,2CAAwH;AAExH,sBAAO,CAAC,IAAI,IAAI,0BAAW,CAAC,oBAAoB,CAAC;AAEjD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,MAAM,mBAAmB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,EAAE,cAAc,CAAC,CAAC,CAAC;aACjE;SACF;IACH,CAAC;CACF;AA7LD,4BA6LC","file":"animator.js","sourcesContent":["import { isNil, isValidNumber } from '@visactor/vutils';\nimport type { IAnimate as IGraphicAnimate } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, Animate, AnimateGroup, AnimateMode } from '@visactor/vrender-core';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationCustomConstructor,\n IAnimationTimeline,\n IAnimator,\n IAnimatorOptions,\n IAnimationUnit,\n IAnimationParameters,\n IAnimationTimeSlice,\n IElement,\n IAnimationEffect\n} from '../../types';\nimport { AttributeAnimate, channelAnimationAttributes, CustomInterpolator, typeAnimationAttributes } from './attribute';\n\nAnimate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;\n\nlet GlobalAnimatorId = 0;\n\nconst isCustomAnimateCtor = (custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor) => {\n return !isNil(custom) && custom.prototype instanceof ACustomAnimate;\n};\n\nexport class Animator implements IAnimator {\n id: number = GlobalAnimatorId++;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean = false;\n\n private unit: IAnimationUnit;\n private runnings: IGraphicAnimate[] = [];\n private callbackFunction: (...args: any[]) => any;\n\n constructor(\n element: IElement,\n unit: IAnimationUnit,\n animationOptions: {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n }\n ) {\n this.element = element;\n this.animationOptions = animationOptions;\n this.unit = unit;\n }\n\n callback(callbackFunction: (...args: any[]) => void): this {\n this.callbackFunction = callbackFunction;\n return this;\n }\n\n animate(animationParameters: IAnimationParameters, parameters: any): this {\n this.isAnimating = true;\n\n this.animateElement(animationParameters, parameters);\n\n // if no valid running, end animating immediately\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n return this;\n }\n\n stop(stopState: 'start' | 'end' = 'end', invokeCallback: boolean = true): this {\n // FIXME: wait for VRender to fix 'end' parameter\n this.runnings.forEach(running => running.stop(stopState));\n this.animationEnd(invokeCallback);\n return this;\n }\n\n pause(): this {\n this.runnings.forEach(running => running.pause());\n return this;\n }\n\n resume(): this {\n this.runnings.forEach(running => running.resume());\n return this;\n }\n\n startAt(startTime: number): this {\n this.runnings.forEach(running => {\n const initialDelay = this.unit.initialDelay;\n running.startAt(initialDelay + startTime);\n });\n return this;\n }\n\n getTotalAnimationTime() {\n const timeLineDuration = this.unit.initialDelay + this.unit.loopDuration * this.unit.loopCount;\n return this.unit.totalTime ?? timeLineDuration;\n }\n\n getEndAttributes() {\n return this.runnings.reduce((attributes, running) => {\n return Object.assign(attributes, running.getEndProps());\n }, {} as Record<string, any>);\n }\n\n private animationEnd(invokeCallback: boolean = true) {\n this.isAnimating = false;\n this.runnings = null;\n if (invokeCallback) {\n this.callbackFunction?.call(null);\n }\n }\n\n private animateElement(animationParameters: IAnimationParameters, parameters: any) {\n const graphicItem = this.element.getGraphicItem();\n\n if (!graphicItem) {\n return;\n }\n\n const graphicAnimate: IGraphicAnimate = graphicItem.animate();\n this.runnings.push(graphicAnimate);\n // initialDelay is only used at first loop\n graphicAnimate.startAt(this.unit.initialDelay);\n // execute loop animation\n graphicAnimate.wait(this.unit.loopDelay);\n this.unit.timeSlices.forEach(timeSlice => {\n this.animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters);\n });\n graphicAnimate.wait(this.unit.loopDelayAfter);\n\n graphicAnimate.loop(this.unit.loopCount - 1);\n\n if (isValidNumber(this.unit.totalTime)) {\n // FIXME: use VRender api instead after VRender refactor is finished\n setTimeout(() => {\n if (graphicAnimate) {\n graphicAnimate.stop('end');\n }\n }, this.unit.totalTime);\n }\n\n graphicAnimate.onEnd(() => {\n this.runnings = this.runnings.filter(running => running !== graphicAnimate);\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n });\n }\n\n private animateTimeSlice(\n graphicAnimate: IGraphicAnimate,\n timeSlice: IAnimationTimeSlice,\n animationParameters: IAnimationParameters,\n parameters: any\n ) {\n const delay = timeSlice.delay as number;\n const duration = timeSlice.duration as number;\n const effects = timeSlice.effects as IAnimationEffect[];\n\n // wait in loop animation before animation starts\n if (delay > 0) {\n graphicAnimate.wait(delay);\n }\n\n if (effects.length < 0) {\n graphicAnimate.wait(duration);\n } else {\n const customAnimates = effects\n .map((effect, index) => {\n const attributes =\n (effect.type\n ? typeAnimationAttributes(this.element, effect, animationParameters, parameters)\n : channelAnimationAttributes(this.element, effect, animationParameters, parameters)) ?? {};\n const customOption = attributes?.custom || effect?.custom;\n const customParametersOption = attributes?.customParameters || effect?.customParameters;\n\n if (\n attributes.from &&\n Object.keys(attributes.from).length &&\n this.unit &&\n this.animationOptions.timeline.controlOptions.immediatelyApply &&\n this.element.mark.markType !== 'component'\n ) {\n this.element.getGraphicItem().setAttributes(attributes.from);\n }\n\n const isCustomAnimate = isCustomAnimateCtor(customOption);\n const isCustomInterpolator = !isNil(customOption) && !isCustomAnimateCtor(customOption);\n\n if (isCustomInterpolator) {\n return new CustomInterpolator(attributes.from, attributes.to, duration, effect.easing, {\n interpolator: customOption as IAnimationChannelInterpolator,\n element: this.element,\n parameters: customParametersOption\n });\n } else if (isCustomAnimate) {\n return new (customOption as IAnimationCustomConstructor)(\n attributes.from,\n attributes.to,\n duration,\n effect.easing,\n customParametersOption\n );\n } else if (attributes.to) {\n return new AttributeAnimate(attributes.from, attributes.to, duration, effect.easing);\n }\n })\n .filter(animate => !isNil(animate));\n\n if (customAnimates.length === 1) {\n graphicAnimate.play(customAnimates[0]);\n } else {\n graphicAnimate.play(new AnimateGroup(duration, customAnimates));\n }\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/graph/animation/animator.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AAGxD,yDAA4F;AAa5F,2CAAwH;AAExH,sBAAO,CAAC,IAAI,IAAI,0BAAW,CAAC,oBAAoB,CAAC;AAEjD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,MAAM,mBAAmB,GAAG,CAAC,MAAoE,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AC,IAAI,2BAAY,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;aACjE;SACF;QAED,IAAI,UAAU,GAAG,CAAC,EAAE;YAClB,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACjC;IACH,CAAC;CACF;AAlMD,4BAkMC","file":"animator.js","sourcesContent":["import { isNil, isValidNumber } from '@visactor/vutils';\nimport type { IAnimate as IGraphicAnimate } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, Animate, AnimateGroup, AnimateMode } from '@visactor/vrender-core';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationCustomConstructor,\n IAnimationTimeline,\n IAnimator,\n IAnimatorOptions,\n IAnimationUnit,\n IAnimationParameters,\n IAnimationTimeSlice,\n IElement,\n IAnimationEffect\n} from '../../types';\nimport { AttributeAnimate, channelAnimationAttributes, CustomInterpolator, typeAnimationAttributes } from './attribute';\n\nAnimate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;\n\nlet GlobalAnimatorId = 0;\n\nconst isCustomAnimateCtor = (custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor) => {\n return !isNil(custom) && custom.prototype instanceof ACustomAnimate;\n};\n\nexport class Animator implements IAnimator {\n id: number = GlobalAnimatorId++;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean = false;\n\n private unit: IAnimationUnit;\n private runnings: IGraphicAnimate[] = [];\n private callbackFunction: (...args: any[]) => any;\n\n constructor(\n element: IElement,\n unit: IAnimationUnit,\n animationOptions: {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n }\n ) {\n this.element = element;\n this.animationOptions = animationOptions;\n this.unit = unit;\n }\n\n callback(callbackFunction: (...args: any[]) => void): this {\n this.callbackFunction = callbackFunction;\n return this;\n }\n\n animate(animationParameters: IAnimationParameters, parameters: any): this {\n this.isAnimating = true;\n\n this.animateElement(animationParameters, parameters);\n\n // if no valid running, end animating immediately\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n return this;\n }\n\n stop(stopState: 'start' | 'end' = 'end', invokeCallback: boolean = true): this {\n // FIXME: wait for VRender to fix 'end' parameter\n this.runnings.forEach(running => running.stop(stopState));\n this.animationEnd(invokeCallback);\n return this;\n }\n\n pause(): this {\n this.runnings.forEach(running => running.pause());\n return this;\n }\n\n resume(): this {\n this.runnings.forEach(running => running.resume());\n return this;\n }\n\n startAt(startTime: number): this {\n this.runnings.forEach(running => {\n const initialDelay = this.unit.initialDelay;\n running.startAt(initialDelay + startTime);\n });\n return this;\n }\n\n getTotalAnimationTime() {\n const timeLineDuration = this.unit.initialDelay + this.unit.loopDuration * this.unit.loopCount;\n return this.unit.totalTime ?? timeLineDuration;\n }\n\n getEndAttributes() {\n return this.runnings.reduce((attributes, running) => {\n return Object.assign(attributes, running.getEndProps());\n }, {} as Record<string, any>);\n }\n\n private animationEnd(invokeCallback: boolean = true) {\n this.isAnimating = false;\n this.runnings = null;\n if (invokeCallback) {\n this.callbackFunction?.call(null);\n }\n }\n\n private animateElement(animationParameters: IAnimationParameters, parameters: any) {\n const graphicItem = this.element.getGraphicItem();\n\n if (!graphicItem) {\n return;\n }\n\n const graphicAnimate: IGraphicAnimate = graphicItem.animate();\n this.runnings.push(graphicAnimate);\n // initialDelay is only used at first loop\n graphicAnimate.startAt(this.unit.initialDelay);\n // execute loop animation\n graphicAnimate.wait(this.unit.loopDelay);\n this.unit.timeSlices.forEach(timeSlice => {\n this.animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters);\n });\n graphicAnimate.wait(this.unit.loopDelayAfter);\n\n graphicAnimate.loop(this.unit.loopCount - 1);\n\n if (isValidNumber(this.unit.totalTime)) {\n // FIXME: use VRender api instead after VRender refactor is finished\n setTimeout(() => {\n if (graphicAnimate) {\n graphicAnimate.stop('end');\n }\n }, this.unit.totalTime);\n }\n\n graphicAnimate.onEnd(() => {\n this.runnings = this.runnings.filter(running => running !== graphicAnimate);\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n });\n }\n\n private animateTimeSlice(\n graphicAnimate: IGraphicAnimate,\n timeSlice: IAnimationTimeSlice,\n animationParameters: IAnimationParameters,\n parameters: any\n ) {\n const delay = timeSlice.delay as number;\n const delayAfter = timeSlice.delayAfter as number;\n const duration = timeSlice.duration as number;\n const effects = timeSlice.effects as IAnimationEffect[];\n\n // wait in loop animation before animation starts\n if (delay > 0) {\n graphicAnimate.wait(delay);\n }\n\n if (effects.length < 0) {\n graphicAnimate.wait(duration);\n } else {\n const customAnimates = effects\n .map((effect, index) => {\n const attributes =\n (effect.type\n ? typeAnimationAttributes(this.element, effect, animationParameters, parameters)\n : channelAnimationAttributes(this.element, effect, animationParameters, parameters)) ?? {};\n const customOption = attributes?.custom || effect?.custom;\n const customParametersOption = attributes?.customParameters || effect?.customParameters;\n\n if (\n attributes.from &&\n Object.keys(attributes.from).length &&\n this.unit &&\n this.animationOptions.timeline.controlOptions.immediatelyApply &&\n this.element.mark.markType !== 'component'\n ) {\n this.element.getGraphicItem().setAttributes(attributes.from);\n }\n\n const isCustomAnimate = isCustomAnimateCtor(customOption);\n const isCustomInterpolator = !isNil(customOption) && !isCustomAnimateCtor(customOption);\n\n if (isCustomInterpolator) {\n return new CustomInterpolator(attributes.from, attributes.to, duration, effect.easing, {\n interpolator: customOption as IAnimationChannelInterpolator,\n element: this.element,\n parameters: customParametersOption\n });\n } else if (isCustomAnimate) {\n return new (customOption as IAnimationCustomConstructor)(\n attributes.from,\n attributes.to,\n duration,\n effect.easing,\n customParametersOption\n );\n } else if (attributes.to) {\n return new AttributeAnimate(attributes.from, attributes.to, duration, effect.easing);\n }\n })\n .filter(animate => !isNil(animate));\n\n if (customAnimates.length === 1) {\n graphicAnimate.play(customAnimates[0]);\n } else {\n graphicAnimate.play(new AnimateGroup(duration, customAnimates));\n }\n }\n\n if (delayAfter > 0) {\n graphicAnimate.wait(delayAfter);\n }\n }\n}\n"]}
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  const vutils_1 = require("@visactor/vutils"), constants_1 = require("../constants");
8
8
 
9
9
  function transformToTimelineConfig(animationConfig) {
10
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
10
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
11
11
  if ((0, vutils_1.isNil)(animationConfig.timeSlices)) {
12
12
  const typeConfig = animationConfig;
13
13
  return {
@@ -19,11 +19,12 @@ function transformToTimelineConfig(animationConfig) {
19
19
  timeSlices: [ {
20
20
  duration: null !== (_e = typeConfig.duration) && void 0 !== _e ? _e : constants_1.DefaultAnimationDuration,
21
21
  delay: null !== (_f = typeConfig.delay) && void 0 !== _f ? _f : constants_1.DefaultAnimationDelay,
22
+ delayAfter: null !== (_g = typeConfig.delayAfter) && void 0 !== _g ? _g : constants_1.DefaultAnimationDelayAfter,
22
23
  effects: [ {
23
24
  type: typeConfig.type,
24
25
  channel: typeConfig.channel,
25
26
  custom: typeConfig.custom,
26
- easing: null !== (_g = typeConfig.easing) && void 0 !== _g ? _g : constants_1.DefaultAnimationEasing,
27
+ easing: null !== (_h = typeConfig.easing) && void 0 !== _h ? _h : constants_1.DefaultAnimationEasing,
27
28
  customParameters: typeConfig.customParameters,
28
29
  options: typeConfig.options
29
30
  } ]
@@ -33,16 +34,17 @@ function transformToTimelineConfig(animationConfig) {
33
34
  const formattedTimeSlices = (0, vutils_1.array)(animationConfig.timeSlices).filter((timeSlice => timeSlice.effects && (0,
34
35
  vutils_1.array)(timeSlice.effects).filter((effect => effect.channel || effect.type)).length));
35
36
  if (formattedTimeSlices.length) return {
36
- startTime: null !== (_h = animationConfig.startTime) && void 0 !== _h ? _h : constants_1.DefaultAnimationStartTime,
37
+ startTime: null !== (_j = animationConfig.startTime) && void 0 !== _j ? _j : constants_1.DefaultAnimationStartTime,
37
38
  totalTime: animationConfig.totalTime,
38
- oneByOne: null !== (_j = animationConfig.oneByOne) && void 0 !== _j ? _j : constants_1.DefaultAnimationOneByOne,
39
- loop: null !== (_k = animationConfig.loop) && void 0 !== _k ? _k : constants_1.DefaultAnimationLoop,
40
- controlOptions: (0, vutils_1.merge)({}, constants_1.DefaultAnimationControlOptions, null !== (_l = animationConfig.controlOptions) && void 0 !== _l ? _l : {}),
39
+ oneByOne: null !== (_k = animationConfig.oneByOne) && void 0 !== _k ? _k : constants_1.DefaultAnimationOneByOne,
40
+ loop: null !== (_l = animationConfig.loop) && void 0 !== _l ? _l : constants_1.DefaultAnimationLoop,
41
+ controlOptions: (0, vutils_1.merge)({}, constants_1.DefaultAnimationControlOptions, null !== (_m = animationConfig.controlOptions) && void 0 !== _m ? _m : {}),
41
42
  timeSlices: formattedTimeSlices.map((timeSlice => {
42
- var _a;
43
+ var _a, _b;
43
44
  return {
44
45
  duration: timeSlice.duration,
45
46
  delay: null !== (_a = timeSlice.delay) && void 0 !== _a ? _a : constants_1.DefaultAnimationDelay,
47
+ delayAfter: null !== (_b = timeSlice.delayAfter) && void 0 !== _b ? _b : constants_1.DefaultAnimationDelayAfter,
46
48
  effects: (0, vutils_1.array)(timeSlice.effects).filter((effect => effect.channel || effect.type)).map((effect => {
47
49
  var _a;
48
50
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graph/animation/config.ts"],"names":[],"mappings":";;;AAAA,6CAAmE;AASnE,4CAQsB;AAEtB,SAAS,yBAAyB,CAAC,eAAiC;;IAClE,IAAI,IAAA,cAAK,EAAE,eAAsC,CAAC,UAAU,CAAC,EAAE;QAC7D,MAAM,UAAU,GAAG,eAAuC,CAAC;QAE3D,OAAO;YACL,SAAS,EAAE,MAAA,UAAU,CAAC,SAAS,mCAAI,qCAAyB;YAC5D,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,QAAQ,EAAE,MAAA,UAAU,CAAC,QAAQ,mCAAI,oCAAwB;YACzD,IAAI,EAAE,MAAA,UAAU,CAAC,IAAI,mCAAI,gCAAoB;YAC7C,cAAc,EAAE,IAAA,cAAK,EAAC,EAAE,EAAE,0CAA8B,E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,MAAM,gBAAgB,GAAkC,EAAE,CAAC;IAC3D,IAAI,KAAK,GAAG,YAAY,CAAC;IACzB,IAAA,cAAK,EAAC,MAAM,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;;QACtC,MAAM,cAAc,GAAG,yBAAyB,CAAC,eAAe,CAAC,CAAC;QAClE,IAAI,cAAc,EAAE;YAClB,gBAAgB,CAAC,IAAI,CAAC;gBACpB,KAAK;gBACL,EAAE,EAAE,MAAA,cAAc,CAAC,EAAE,mCAAI,GAAG,KAAK,IAAI,KAAK,EAAE;gBAC5C,QAAQ,EAAE,cAAc;gBACxB,YAAY,EAAE,eAAe;aAC9B,CAAC,CAAC;YACH,KAAK,IAAI,CAAC,CAAC;SACZ;IACH,CAAC,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AApBD,sEAoBC;AAED,SAAgB,iBAAiB,CAAI,IAA8B,EAAE,OAAiB,EAAE,UAAe;IACrG,IAAI,IAAA,mBAAU,EAAC,IAAI,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;KACjE;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AALD,8CAKC","file":"config.js","sourcesContent":["import { array, isFunction, isNil, merge } from '@visactor/vutils';\nimport type { IElement } from '../../types';\nimport type {\n IAnimationConfig,\n IAnimationTimeline,\n IAnimationTypeConfig,\n IParsedAnimationConfig,\n MarkFunctionValueType\n} from '../../types/animate';\nimport {\n DefaultAnimationControlOptions,\n DefaultAnimationDelay,\n DefaultAnimationDuration,\n DefaultAnimationEasing,\n DefaultAnimationLoop,\n DefaultAnimationOneByOne,\n DefaultAnimationStartTime\n} from '../constants';\n\nfunction transformToTimelineConfig(animationConfig: IAnimationConfig): IAnimationTimeline {\n if (isNil((animationConfig as IAnimationTimeline).timeSlices)) {\n const typeConfig = animationConfig as IAnimationTypeConfig;\n // transform type animation config into timeline animation config\n return {\n startTime: typeConfig.startTime ?? DefaultAnimationStartTime,\n totalTime: typeConfig.totalTime,\n oneByOne: typeConfig.oneByOne ?? DefaultAnimationOneByOne,\n loop: typeConfig.loop ?? DefaultAnimationLoop,\n controlOptions: merge({}, DefaultAnimationControlOptions, typeConfig.controlOptions ?? {}),\n timeSlices: [\n {\n duration: typeConfig.duration ?? DefaultAnimationDuration,\n delay: typeConfig.delay ?? DefaultAnimationDelay,\n effects: [\n {\n type: typeConfig.type,\n channel: typeConfig.channel,\n custom: typeConfig.custom,\n easing: typeConfig.easing ?? DefaultAnimationEasing,\n customParameters: typeConfig.customParameters,\n options: typeConfig.options\n }\n ]\n }\n ]\n };\n }\n\n const timeSlices = array((animationConfig as IAnimationTimeline).timeSlices);\n const formattedTimeSlices = timeSlices.filter(timeSlice => {\n return timeSlice.effects && array(timeSlice.effects).filter(effect => effect.channel || effect.type).length;\n });\n\n if (formattedTimeSlices.length) {\n // fill up default animation config\n return {\n startTime: (animationConfig as IAnimationTimeline).startTime ?? DefaultAnimationStartTime,\n totalTime: (animationConfig as IAnimationTimeline).totalTime,\n oneByOne: (animationConfig as IAnimationTimeline).oneByOne ?? DefaultAnimationOneByOne,\n loop: (animationConfig as IAnimationTimeline).loop ?? DefaultAnimationLoop,\n controlOptions: merge({}, DefaultAnimationControlOptions, animationConfig.controlOptions ?? {}),\n timeSlices: formattedTimeSlices.map(timeSlice => {\n return {\n duration: timeSlice.duration,\n delay: timeSlice.delay ?? DefaultAnimationDelay,\n effects: array(timeSlice.effects)\n .filter(effect => effect.channel || effect.type)\n .map(effect => {\n return {\n type: effect.type,\n channel: effect.channel,\n custom: effect.custom,\n easing: effect.easing ?? DefaultAnimationEasing,\n customParameters: effect.customParameters,\n options: effect.options\n };\n })\n };\n }),\n partitioner: (animationConfig as IAnimationTimeline).partitioner,\n sort: (animationConfig as IAnimationTimeline).sort\n };\n }\n\n return;\n}\n\nexport function normalizeAnimationConfig(\n config: Record<string, IAnimationConfig | IAnimationConfig[]>\n): Array<IParsedAnimationConfig> {\n let normalizedConfig: Array<IParsedAnimationConfig> = [];\n\n Object.keys(config).forEach(state => {\n normalizedConfig = normalizedConfig.concat(normalizeStateAnimationConfig(state, config[state]));\n });\n return normalizedConfig;\n}\n\nexport function normalizeStateAnimationConfig(\n state: string,\n config: IAnimationConfig | IAnimationConfig[],\n initialIndex: number = 0\n): Array<IParsedAnimationConfig> {\n const normalizedConfig: Array<IParsedAnimationConfig> = [];\n let index = initialIndex;\n array(config).forEach(animationConfig => {\n const timelineConfig = transformToTimelineConfig(animationConfig);\n if (timelineConfig) {\n normalizedConfig.push({\n state,\n id: timelineConfig.id ?? `${state}-${index}`,\n timeline: timelineConfig,\n originConfig: animationConfig\n });\n index += 1;\n }\n });\n return normalizedConfig;\n}\n\nexport function invokeAnimateSpec<T>(spec: MarkFunctionValueType<T>, element: IElement, parameters: any): T {\n if (isFunction(spec)) {\n return spec.call(null, element.getDatum(), element, parameters);\n }\n return spec;\n}\n"]}
1
+ {"version":3,"sources":["../src/graph/animation/config.ts"],"names":[],"mappings":";;;AAAA,6CAAmE;AASnE,4CASsB;AAEtB,SAAS,yBAAyB,CAAC,eAAiC;;IAClE,IAAI,IAAA,cAAK,EAAE,eAAsC,CAAC,UAAU,CAAC,EAAE;QAC7D,MAAM,UAAU,GAAG,eAAuC,CAAC;QAE3D,OAAO;YACL,SAAS,EAAE,MAAA,UAAU,CAAC,SAAS,mCAAI,qCAAyB;YAC5D,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,QAAQ,EAAE,MAAA,UAAU,CAAC,QAAQ,mCAAI,oCAAwB;YACzD,IAAI,EAAE,MAAA,UAAU,CAAC,IAAI,mCAAI,gCAAoB;YAC7C,cAAc,EAAE,IAAA,cAAK,EAAC,EAAE,EAAE,0CAA8B,EAAE,MAAA,UAAU,CAAC,cAAc,mCAAI,EAAE,CAAC;YAC1F,UAAU,EAAE;gBACV;oBACE,QAAQ,EAAE,MAA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AC7C,eAAuB,CAAC;IAExB,MAAM,gBAAgB,GAAkC,EAAE,CAAC;IAC3D,IAAI,KAAK,GAAG,YAAY,CAAC;IACzB,IAAA,cAAK,EAAC,MAAM,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;;QACtC,MAAM,cAAc,GAAG,yBAAyB,CAAC,eAAe,CAAC,CAAC;QAClE,IAAI,cAAc,EAAE;YAClB,gBAAgB,CAAC,IAAI,CAAC;gBACpB,KAAK;gBACL,EAAE,EAAE,MAAA,cAAc,CAAC,EAAE,mCAAI,GAAG,KAAK,IAAI,KAAK,EAAE;gBAC5C,QAAQ,EAAE,cAAc;gBACxB,YAAY,EAAE,eAAe;aAC9B,CAAC,CAAC;YACH,KAAK,IAAI,CAAC,CAAC;SACZ;IACH,CAAC,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AApBD,sEAoBC;AAED,SAAgB,iBAAiB,CAAI,IAA8B,EAAE,OAAiB,EAAE,UAAe;IACrG,IAAI,IAAA,mBAAU,EAAC,IAAI,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;KACjE;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AALD,8CAKC","file":"config.js","sourcesContent":["import { array, isFunction, isNil, merge } from '@visactor/vutils';\nimport type { IElement } from '../../types';\nimport type {\n IAnimationConfig,\n IAnimationTimeline,\n IAnimationTypeConfig,\n IParsedAnimationConfig,\n MarkFunctionValueType\n} from '../../types/animate';\nimport {\n DefaultAnimationControlOptions,\n DefaultAnimationDelay,\n DefaultAnimationDelayAfter,\n DefaultAnimationDuration,\n DefaultAnimationEasing,\n DefaultAnimationLoop,\n DefaultAnimationOneByOne,\n DefaultAnimationStartTime\n} from '../constants';\n\nfunction transformToTimelineConfig(animationConfig: IAnimationConfig): IAnimationTimeline {\n if (isNil((animationConfig as IAnimationTimeline).timeSlices)) {\n const typeConfig = animationConfig as IAnimationTypeConfig;\n // transform type animation config into timeline animation config\n return {\n startTime: typeConfig.startTime ?? DefaultAnimationStartTime,\n totalTime: typeConfig.totalTime,\n oneByOne: typeConfig.oneByOne ?? DefaultAnimationOneByOne,\n loop: typeConfig.loop ?? DefaultAnimationLoop,\n controlOptions: merge({}, DefaultAnimationControlOptions, typeConfig.controlOptions ?? {}),\n timeSlices: [\n {\n duration: typeConfig.duration ?? DefaultAnimationDuration,\n delay: typeConfig.delay ?? DefaultAnimationDelay,\n delayAfter: typeConfig.delayAfter ?? DefaultAnimationDelayAfter,\n effects: [\n {\n type: typeConfig.type,\n channel: typeConfig.channel,\n custom: typeConfig.custom,\n easing: typeConfig.easing ?? DefaultAnimationEasing,\n customParameters: typeConfig.customParameters,\n options: typeConfig.options\n }\n ]\n }\n ]\n };\n }\n\n const timeSlices = array((animationConfig as IAnimationTimeline).timeSlices);\n const formattedTimeSlices = timeSlices.filter(timeSlice => {\n return timeSlice.effects && array(timeSlice.effects).filter(effect => effect.channel || effect.type).length;\n });\n\n if (formattedTimeSlices.length) {\n // fill up default animation config\n return {\n startTime: (animationConfig as IAnimationTimeline).startTime ?? DefaultAnimationStartTime,\n totalTime: (animationConfig as IAnimationTimeline).totalTime,\n oneByOne: (animationConfig as IAnimationTimeline).oneByOne ?? DefaultAnimationOneByOne,\n loop: (animationConfig as IAnimationTimeline).loop ?? DefaultAnimationLoop,\n controlOptions: merge({}, DefaultAnimationControlOptions, animationConfig.controlOptions ?? {}),\n timeSlices: formattedTimeSlices.map(timeSlice => {\n return {\n duration: timeSlice.duration,\n delay: timeSlice.delay ?? DefaultAnimationDelay,\n delayAfter: timeSlice.delayAfter ?? DefaultAnimationDelayAfter,\n effects: array(timeSlice.effects)\n .filter(effect => effect.channel || effect.type)\n .map(effect => {\n return {\n type: effect.type,\n channel: effect.channel,\n custom: effect.custom,\n easing: effect.easing ?? DefaultAnimationEasing,\n customParameters: effect.customParameters,\n options: effect.options\n };\n })\n };\n }),\n partitioner: (animationConfig as IAnimationTimeline).partitioner,\n sort: (animationConfig as IAnimationTimeline).sort\n };\n }\n\n return;\n}\n\nexport function normalizeAnimationConfig(\n config: Record<string, IAnimationConfig | IAnimationConfig[]>\n): Array<IParsedAnimationConfig> {\n let normalizedConfig: Array<IParsedAnimationConfig> = [];\n\n Object.keys(config).forEach(state => {\n normalizedConfig = normalizedConfig.concat(normalizeStateAnimationConfig(state, config[state]));\n });\n return normalizedConfig;\n}\n\nexport function normalizeStateAnimationConfig(\n state: string,\n config: IAnimationConfig | IAnimationConfig[],\n initialIndex: number = 0\n): Array<IParsedAnimationConfig> {\n const normalizedConfig: Array<IParsedAnimationConfig> = [];\n let index = initialIndex;\n array(config).forEach(animationConfig => {\n const timelineConfig = transformToTimelineConfig(animationConfig);\n if (timelineConfig) {\n normalizedConfig.push({\n state,\n id: timelineConfig.id ?? `${state}-${index}`,\n timeline: timelineConfig,\n originConfig: animationConfig\n });\n index += 1;\n }\n });\n return normalizedConfig;\n}\n\nexport function invokeAnimateSpec<T>(spec: MarkFunctionValueType<T>, element: IElement, parameters: any): T {\n if (isFunction(spec)) {\n return spec.call(null, element.getDatum(), element, parameters);\n }\n return spec;\n}\n"]}
@@ -42,7 +42,7 @@ exports.transformsByType = {
42
42
  }
43
43
  } ],
44
44
  [enums_1.GrammarMarkType.line]: [ {
45
- channels: [ "x", "y", "defined", "enableSegments" ],
45
+ channels: [ "x", "y", "defined" ],
46
46
  transform: (graphicAttributes, nextAttrs, storedAttrs) => {
47
47
  graphicAttributes.x = 0, graphicAttributes.y = 0;
48
48
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graph/attributes/transform.ts"],"names":[],"mappings":";;;AAAA,6CAAsF;AAGtF,oCAA2C;AAC3C,uCAA0C;AAC1C,qCAAsE;AAEtE,SAAS,qBAAqB,CAC5B,IAAY,EACZ,QAAkB,EAClB,iBAAsB,EACtB,SAAc,EACd,OAAiB,EACjB,QAAgB;;I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;gBAClC,IAAA,iCAAwB,EAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;aAC7D;iBAAM;gBACL,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;aACzC;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AA5DW,QAAA,mBAAmB,uBA4D9B","file":"transform.js","sourcesContent":["import { has, isNil, isPlainObject, isString, isValidNumber } from '@visactor/vutils';\nimport type { IElement, IGlyphElement } from '../../types/element';\nimport type { AttributeTransform, MarkType } from '../../types/mark';\nimport { GrammarMarkType } from '../enums';\nimport { getRulePoints } from './helpers';\nimport { commonAttributes, transformCommonAttribute } from './common';\n\nfunction storeOriginAttributes(\n name: string,\n channels: string[],\n graphicAttributes: any,\n nextAttrs: any,\n element: IElement,\n markName: string\n): Record<string, any> {\n const prevStoredAttrs = (element as IGlyphElement).getGraphicAttribute(name, false, markName) ?? {};\n const storedAttrs = {};\n channels.forEach(channel => {\n storedAttrs[channel] = nextAttrs[channel] ?? prevStoredAttrs[channel];\n });\n graphicAttributes[name] = storedAttrs;\n return storedAttrs;\n}\n\nexport const transformsByType: Record<string, AttributeTransform[]> = {\n [GrammarMarkType.largeRects]: [\n {\n channels: ['x', 'y', 'y1', 'x1', 'width', 'height'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n }\n }\n ],\n [GrammarMarkType.largeSymbols]: [\n {\n channels: ['x', 'y', 'size'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n }\n }\n ],\n [GrammarMarkType.area]: [\n {\n channels: ['x', 'y', 'x1', 'y1'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n graphicAttributes.x1 = 0;\n graphicAttributes.y1 = 0;\n }\n }\n ],\n [GrammarMarkType.line]: [\n {\n channels: ['x', 'y', 'defined', 'enableSegments'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n }\n }\n ],\n [GrammarMarkType.rect]: [\n {\n channels: ['x', 'y', 'x1', 'y1', 'width', 'height'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n // width\n if (isValidNumber(nextAttrs.width) || (!isValidNumber(nextAttrs.x1) && isValidNumber(storedAttrs.width))) {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n } else if (isValidNumber(nextAttrs.x1) || (!isValidNumber(nextAttrs.width) && isValidNumber(storedAttrs.x1))) {\n graphicAttributes.x = Math.min(storedAttrs.x, storedAttrs.x1);\n graphicAttributes.width = Math.abs(storedAttrs.x1 - storedAttrs.x);\n } else {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n }\n\n // height\n if (isValidNumber(nextAttrs.height) || (!isValidNumber(nextAttrs.y1) && isValidNumber(storedAttrs.height))) {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n } else if (isValidNumber(nextAttrs.y1) || (!isValidNumber(nextAttrs.height) && isValidNumber(storedAttrs.y1))) {\n graphicAttributes.y = Math.min(storedAttrs.y, storedAttrs.y1);\n graphicAttributes.height = Math.abs(storedAttrs.y1 - storedAttrs.y);\n } else {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ],\n rect3d: [\n {\n channels: ['x', 'y', 'z', 'x1', 'y1', 'width', 'height', 'length'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n // width\n if (isValidNumber(nextAttrs.width) || (!isValidNumber(nextAttrs.x1) && isValidNumber(storedAttrs.width))) {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n } else if (isValidNumber(nextAttrs.x1) || (!isValidNumber(nextAttrs.width) && isValidNumber(storedAttrs.x1))) {\n graphicAttributes.x = Math.min(storedAttrs.x, storedAttrs.x1);\n graphicAttributes.width = Math.abs(storedAttrs.x1 - storedAttrs.x);\n } else {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n }\n\n // height\n if (isValidNumber(nextAttrs.height) || (!isValidNumber(nextAttrs.y1) && isValidNumber(storedAttrs.height))) {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n } else if (isValidNumber(nextAttrs.y1) || (!isValidNumber(nextAttrs.height) && isValidNumber(storedAttrs.y1))) {\n graphicAttributes.y = Math.min(storedAttrs.y, storedAttrs.y1);\n graphicAttributes.height = Math.abs(storedAttrs.y1 - storedAttrs.y);\n } else {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n }\n\n // length\n if (isValidNumber(nextAttrs.length) || (!isValidNumber(nextAttrs.z1) && isValidNumber(storedAttrs.length))) {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n } else if (isValidNumber(nextAttrs.z1) || (!isValidNumber(nextAttrs.length) && isValidNumber(storedAttrs.z1))) {\n graphicAttributes.z = Math.min(storedAttrs.z, storedAttrs.z1);\n graphicAttributes.length = Math.abs(storedAttrs.z1 - storedAttrs.z);\n } else {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ],\n [GrammarMarkType.text]: [\n {\n channels: ['text', 'limit', 'autoLimit', 'maxLineWidth'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const limit = storedAttrs.limit ?? Infinity;\n const autoLimit = storedAttrs.autoLimit ?? Infinity;\n const maxWidth = Math.min(limit, autoLimit);\n const isTextConfig = isPlainObject(storedAttrs.text) && !isNil(storedAttrs.text.text);\n const text = isTextConfig ? storedAttrs.text.text : storedAttrs.text;\n\n if (Array.isArray(text)) {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n } else {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n }\n\n if (isTextConfig) {\n if (storedAttrs.text.type === 'html') {\n graphicAttributes.html = {\n dom: text,\n width: nextAttrs.width ?? maxWidth,\n height: nextAttrs.height ?? nextAttrs.fontSize,\n anchorType: 'position'\n };\n graphicAttributes.text = '';\n } else if (storedAttrs.text.type === 'rich') {\n graphicAttributes.textConfig = text;\n } else {\n graphicAttributes.text = text;\n }\n } else {\n graphicAttributes.text = text;\n }\n },\n storedAttrs: 'limitAttrs'\n }\n ],\n [GrammarMarkType.rule]: [\n {\n channels: ['x', 'y', 'x1', 'y1'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const points = getRulePoints(storedAttrs);\n graphicAttributes.points = points;\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n },\n storedAttrs: 'pointAttrs'\n }\n ],\n [GrammarMarkType.symbol]: [\n {\n channels: ['shape', 'symbolType'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.symbolType = nextAttrs.shape ?? nextAttrs.symbolType;\n }\n },\n {\n channels: ['image', 'fill', 'background'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n if (nextAttrs.image) {\n graphicAttributes.background = nextAttrs.image;\n graphicAttributes.fill = false;\n } else if (storedAttrs.image) {\n graphicAttributes.background = storedAttrs.image;\n graphicAttributes.fill = false;\n } else {\n graphicAttributes.fill = storedAttrs.fill;\n graphicAttributes.background = storedAttrs.background;\n }\n },\n storedAttrs: 'imageAttrs'\n }\n ],\n [GrammarMarkType.richtext]: [\n {\n channels: ['text', 'textConfig'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.text = null;\n\n if (nextAttrs.text?.type === 'rich') {\n graphicAttributes.textConfig = nextAttrs.text.text;\n } else if (nextAttrs.textConfig?.type === 'html') {\n graphicAttributes.html = {\n dom: nextAttrs.textConfig.text,\n width: nextAttrs.width,\n height: nextAttrs.height ?? nextAttrs.fontSize,\n anchorType: 'position'\n };\n graphicAttributes.text = '';\n } else if (nextAttrs.textConfig?.type === 'rich') {\n graphicAttributes.textConfig = nextAttrs.textConfig.text;\n } else {\n graphicAttributes.textConfig = nextAttrs.textConfig;\n }\n }\n }\n ]\n};\n\nexport function cloneTransformAttributes(markType: MarkType, attributes: any) {\n const transforms = transformsByType[markType] ?? [];\n return transforms.reduce((clonedAttributes, transform) => {\n transform.channels.forEach(channel => {\n if (has(attributes, channel)) {\n clonedAttributes[channel] = attributes[channel];\n }\n });\n return clonedAttributes;\n }, {} as any);\n}\n\nexport const transformAttributes = (\n markType: MarkType | AttributeTransform[],\n nextAttrs: any,\n element: IElement,\n markName?: string\n) => {\n const graphicAttributes = {};\n const changedKeys = nextAttrs ? Object.keys(nextAttrs) : [];\n const transforms: AttributeTransform[] = isString(markType)\n ? transformsByType[markType]\n : (markType as AttributeTransform[]);\n\n if (transforms?.length) {\n const tags: boolean[] = [];\n\n changedKeys.forEach(key => {\n let isTransformed = false;\n\n transforms.forEach((transform, index) => {\n if (transform.channels.includes(key)) {\n if (!tags[index]) {\n if (transform.storedAttrs) {\n const storedAttrs = storeOriginAttributes(\n transform.storedAttrs,\n transform.channels,\n graphicAttributes,\n nextAttrs,\n element,\n markName\n );\n transform.transform(graphicAttributes, nextAttrs, storedAttrs);\n } else {\n transform.transform(graphicAttributes, nextAttrs, null);\n }\n }\n // 记录一下,不重复处理\n tags[index] = true;\n isTransformed = true;\n }\n });\n\n if (!isTransformed) {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n }\n });\n } else {\n changedKeys.forEach(key => {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n });\n }\n\n return graphicAttributes;\n};\n"]}
1
+ {"version":3,"sources":["../src/graph/attributes/transform.ts"],"names":[],"mappings":";;;AAAA,6CAAsF;AAGtF,oCAA2C;AAC3C,uCAA0C;AAC1C,qCAAsE;AAEtE,SAAS,qBAAqB,CAC5B,IAAY,EACZ,QAAkB,EAClB,iBAAsB,EACtB,SAAc,EACd,OAAiB,EACjB,QAAgB;;IAEhB,MAAM,eAAe,GAAG,MAAC,OAAyB,CAAC,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,mCAAI,EAAE,CAAC;IACpG,MAAM,WAAW,GAAG,EAAE,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;;QACzB,WAAW,CAAC,OAAO,CAAC,GAAG,MAAA,SAAS,CAAC,OAAO,CAAC,mCAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;IACH,iBAAiB,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IACtC,OAAO,WAAW,CAAC;AACrB,CAAC;AAEY,QAAA,gBAAgB,GAAyC;IACpE,CAAC,uBAAe,CAAC,UAAU,CAAC,EAAE;QAC5B;YACE,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAA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BAAiB,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;yBAChE;6BAAM;4BACL,SAAS,CAAC,SAAS,CAAC,iBAAiB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;yBACzD;qBACF;oBAED,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;oBACnB,aAAa,GAAG,IAAI,CAAC;iBACtB;YACH,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,aAAa,EAAE;gBAClB,IAAI,yBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBAClC,IAAA,iCAAwB,EAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;iBAC7D;qBAAM;oBACL,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;iBACzC;aACF;QACH,CAAC,CAAC,CAAC;KACJ;SAAM;QACL,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACxB,IAAI,yBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAClC,IAAA,iCAAwB,EAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;aAC7D;iBAAM;gBACL,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;aACzC;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AA5DW,QAAA,mBAAmB,uBA4D9B","file":"transform.js","sourcesContent":["import { has, isNil, isPlainObject, isString, isValidNumber } from '@visactor/vutils';\nimport type { IElement, IGlyphElement } from '../../types/element';\nimport type { AttributeTransform, MarkType } from '../../types/mark';\nimport { GrammarMarkType } from '../enums';\nimport { getRulePoints } from './helpers';\nimport { commonAttributes, transformCommonAttribute } from './common';\n\nfunction storeOriginAttributes(\n name: string,\n channels: string[],\n graphicAttributes: any,\n nextAttrs: any,\n element: IElement,\n markName: string\n): Record<string, any> {\n const prevStoredAttrs = (element as IGlyphElement).getGraphicAttribute(name, false, markName) ?? {};\n const storedAttrs = {};\n channels.forEach(channel => {\n storedAttrs[channel] = nextAttrs[channel] ?? prevStoredAttrs[channel];\n });\n graphicAttributes[name] = storedAttrs;\n return storedAttrs;\n}\n\nexport const transformsByType: Record<string, AttributeTransform[]> = {\n [GrammarMarkType.largeRects]: [\n {\n channels: ['x', 'y', 'y1', 'x1', 'width', 'height'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n }\n }\n ],\n [GrammarMarkType.largeSymbols]: [\n {\n channels: ['x', 'y', 'size'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n }\n }\n ],\n [GrammarMarkType.area]: [\n {\n channels: ['x', 'y', 'x1', 'y1'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n graphicAttributes.x1 = 0;\n graphicAttributes.y1 = 0;\n }\n }\n ],\n [GrammarMarkType.line]: [\n {\n channels: ['x', 'y', 'defined'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n }\n }\n ],\n [GrammarMarkType.rect]: [\n {\n channels: ['x', 'y', 'x1', 'y1', 'width', 'height'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n // width\n if (isValidNumber(nextAttrs.width) || (!isValidNumber(nextAttrs.x1) && isValidNumber(storedAttrs.width))) {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n } else if (isValidNumber(nextAttrs.x1) || (!isValidNumber(nextAttrs.width) && isValidNumber(storedAttrs.x1))) {\n graphicAttributes.x = Math.min(storedAttrs.x, storedAttrs.x1);\n graphicAttributes.width = Math.abs(storedAttrs.x1 - storedAttrs.x);\n } else {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n }\n\n // height\n if (isValidNumber(nextAttrs.height) || (!isValidNumber(nextAttrs.y1) && isValidNumber(storedAttrs.height))) {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n } else if (isValidNumber(nextAttrs.y1) || (!isValidNumber(nextAttrs.height) && isValidNumber(storedAttrs.y1))) {\n graphicAttributes.y = Math.min(storedAttrs.y, storedAttrs.y1);\n graphicAttributes.height = Math.abs(storedAttrs.y1 - storedAttrs.y);\n } else {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ],\n rect3d: [\n {\n channels: ['x', 'y', 'z', 'x1', 'y1', 'width', 'height', 'length'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n // width\n if (isValidNumber(nextAttrs.width) || (!isValidNumber(nextAttrs.x1) && isValidNumber(storedAttrs.width))) {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n } else if (isValidNumber(nextAttrs.x1) || (!isValidNumber(nextAttrs.width) && isValidNumber(storedAttrs.x1))) {\n graphicAttributes.x = Math.min(storedAttrs.x, storedAttrs.x1);\n graphicAttributes.width = Math.abs(storedAttrs.x1 - storedAttrs.x);\n } else {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n }\n\n // height\n if (isValidNumber(nextAttrs.height) || (!isValidNumber(nextAttrs.y1) && isValidNumber(storedAttrs.height))) {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n } else if (isValidNumber(nextAttrs.y1) || (!isValidNumber(nextAttrs.height) && isValidNumber(storedAttrs.y1))) {\n graphicAttributes.y = Math.min(storedAttrs.y, storedAttrs.y1);\n graphicAttributes.height = Math.abs(storedAttrs.y1 - storedAttrs.y);\n } else {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n }\n\n // length\n if (isValidNumber(nextAttrs.length) || (!isValidNumber(nextAttrs.z1) && isValidNumber(storedAttrs.length))) {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n } else if (isValidNumber(nextAttrs.z1) || (!isValidNumber(nextAttrs.length) && isValidNumber(storedAttrs.z1))) {\n graphicAttributes.z = Math.min(storedAttrs.z, storedAttrs.z1);\n graphicAttributes.length = Math.abs(storedAttrs.z1 - storedAttrs.z);\n } else {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ],\n [GrammarMarkType.text]: [\n {\n channels: ['text', 'limit', 'autoLimit', 'maxLineWidth'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const limit = storedAttrs.limit ?? Infinity;\n const autoLimit = storedAttrs.autoLimit ?? Infinity;\n const maxWidth = Math.min(limit, autoLimit);\n const isTextConfig = isPlainObject(storedAttrs.text) && !isNil(storedAttrs.text.text);\n const text = isTextConfig ? storedAttrs.text.text : storedAttrs.text;\n\n if (Array.isArray(text)) {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n } else {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n }\n\n if (isTextConfig) {\n if (storedAttrs.text.type === 'html') {\n graphicAttributes.html = {\n dom: text,\n width: nextAttrs.width ?? maxWidth,\n height: nextAttrs.height ?? nextAttrs.fontSize,\n anchorType: 'position'\n };\n graphicAttributes.text = '';\n } else if (storedAttrs.text.type === 'rich') {\n graphicAttributes.textConfig = text;\n } else {\n graphicAttributes.text = text;\n }\n } else {\n graphicAttributes.text = text;\n }\n },\n storedAttrs: 'limitAttrs'\n }\n ],\n [GrammarMarkType.rule]: [\n {\n channels: ['x', 'y', 'x1', 'y1'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const points = getRulePoints(storedAttrs);\n graphicAttributes.points = points;\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n },\n storedAttrs: 'pointAttrs'\n }\n ],\n [GrammarMarkType.symbol]: [\n {\n channels: ['shape', 'symbolType'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.symbolType = nextAttrs.shape ?? nextAttrs.symbolType;\n }\n },\n {\n channels: ['image', 'fill', 'background'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n if (nextAttrs.image) {\n graphicAttributes.background = nextAttrs.image;\n graphicAttributes.fill = false;\n } else if (storedAttrs.image) {\n graphicAttributes.background = storedAttrs.image;\n graphicAttributes.fill = false;\n } else {\n graphicAttributes.fill = storedAttrs.fill;\n graphicAttributes.background = storedAttrs.background;\n }\n },\n storedAttrs: 'imageAttrs'\n }\n ],\n [GrammarMarkType.richtext]: [\n {\n channels: ['text', 'textConfig'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.text = null;\n\n if (nextAttrs.text?.type === 'rich') {\n graphicAttributes.textConfig = nextAttrs.text.text;\n } else if (nextAttrs.textConfig?.type === 'html') {\n graphicAttributes.html = {\n dom: nextAttrs.textConfig.text,\n width: nextAttrs.width,\n height: nextAttrs.height ?? nextAttrs.fontSize,\n anchorType: 'position'\n };\n graphicAttributes.text = '';\n } else if (nextAttrs.textConfig?.type === 'rich') {\n graphicAttributes.textConfig = nextAttrs.textConfig.text;\n } else {\n graphicAttributes.textConfig = nextAttrs.textConfig;\n }\n }\n }\n ]\n};\n\nexport function cloneTransformAttributes(markType: MarkType, attributes: any) {\n const transforms = transformsByType[markType] ?? [];\n return transforms.reduce((clonedAttributes, transform) => {\n transform.channels.forEach(channel => {\n if (has(attributes, channel)) {\n clonedAttributes[channel] = attributes[channel];\n }\n });\n return clonedAttributes;\n }, {} as any);\n}\n\nexport const transformAttributes = (\n markType: MarkType | AttributeTransform[],\n nextAttrs: any,\n element: IElement,\n markName?: string\n) => {\n const graphicAttributes = {};\n const changedKeys = nextAttrs ? Object.keys(nextAttrs) : [];\n const transforms: AttributeTransform[] = isString(markType)\n ? transformsByType[markType]\n : (markType as AttributeTransform[]);\n\n if (transforms?.length) {\n const tags: boolean[] = [];\n\n changedKeys.forEach(key => {\n let isTransformed = false;\n\n transforms.forEach((transform, index) => {\n if (transform.channels.includes(key)) {\n if (!tags[index]) {\n if (transform.storedAttrs) {\n const storedAttrs = storeOriginAttributes(\n transform.storedAttrs,\n transform.channels,\n graphicAttributes,\n nextAttrs,\n element,\n markName\n );\n transform.transform(graphicAttributes, nextAttrs, storedAttrs);\n } else {\n transform.transform(graphicAttributes, nextAttrs, null);\n }\n }\n // 记录一下,不重复处理\n tags[index] = true;\n isTransformed = true;\n }\n });\n\n if (!isTransformed) {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n }\n });\n } else {\n changedKeys.forEach(key => {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n });\n }\n\n return graphicAttributes;\n};\n"]}
@@ -15,6 +15,7 @@ export declare const ImmediateAnimationState = "VGRAMMAR_IMMEDIATE_ANIMATION";
15
15
  export declare const DefaultAnimationStartTime = 0;
16
16
  export declare const DefaultAnimationDuration = 1000;
17
17
  export declare const DefaultAnimationDelay = 0;
18
+ export declare const DefaultAnimationDelayAfter = 0;
18
19
  export declare const DefaultAnimationLoop = false;
19
20
  export declare const DefaultAnimationOneByOne = false;
20
21
  export declare const DefaultAnimationEasing = "quintInOut";
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.DefaultAnimationParameters = exports.DefaultAnimationControlOptions = exports.DefaultAnimationEasing = exports.DefaultAnimationOneByOne = exports.DefaultAnimationLoop = exports.DefaultAnimationDelay = exports.DefaultAnimationDuration = exports.DefaultAnimationStartTime = exports.ImmediateAnimationState = exports.DefaultEnableExitAnimation = exports.DefaultSplitPath = exports.DefaultMorphAll = exports.DefaultMorph = exports.DefaultReuse = exports.DefaultGroupKeys = exports.DefaultMarkData = exports.DefaultKey = exports.Mark3DType = exports.CollectionMarkType = exports.BridgeElementKey = void 0;
5
+ }), exports.DefaultAnimationParameters = exports.DefaultAnimationControlOptions = exports.DefaultAnimationEasing = exports.DefaultAnimationOneByOne = exports.DefaultAnimationLoop = exports.DefaultAnimationDelayAfter = exports.DefaultAnimationDelay = exports.DefaultAnimationDuration = exports.DefaultAnimationStartTime = exports.ImmediateAnimationState = exports.DefaultEnableExitAnimation = exports.DefaultSplitPath = exports.DefaultMorphAll = exports.DefaultMorph = exports.DefaultReuse = exports.DefaultGroupKeys = exports.DefaultMarkData = exports.DefaultKey = exports.Mark3DType = exports.CollectionMarkType = exports.BridgeElementKey = void 0;
6
6
 
7
7
  const enums_1 = require("./enums");
8
8
 
@@ -12,8 +12,8 @@ exports.DefaultKey = "key", exports.DefaultMarkData = [ {} ], exports.DefaultGro
12
12
  exports.DefaultReuse = !0, exports.DefaultMorph = !0, exports.DefaultMorphAll = !1,
13
13
  exports.DefaultSplitPath = null, exports.DefaultEnableExitAnimation = !0, exports.ImmediateAnimationState = "VGRAMMAR_IMMEDIATE_ANIMATION",
14
14
  exports.DefaultAnimationStartTime = 0, exports.DefaultAnimationDuration = 1e3, exports.DefaultAnimationDelay = 0,
15
- exports.DefaultAnimationLoop = !1, exports.DefaultAnimationOneByOne = !1, exports.DefaultAnimationEasing = "quintInOut",
16
- exports.DefaultAnimationControlOptions = {
15
+ exports.DefaultAnimationDelayAfter = 0, exports.DefaultAnimationLoop = !1, exports.DefaultAnimationOneByOne = !1,
16
+ exports.DefaultAnimationEasing = "quintInOut", exports.DefaultAnimationControlOptions = {
17
17
  stopWhenStateChange: !1,
18
18
  immediatelyApply: !0
19
19
  }, exports.DefaultAnimationParameters = "VGRAMMAR_ANIMATION_PARAMETERS";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graph/constants.ts"],"names":[],"mappings":";;;AACA,mCAA0C;AAE7B,QAAA,gBAAgB,GAAG,yBAAyB,CAAC;AAE7C,QAAA,kBAAkB,GAAG,CAAC,uBAAe,CAAC,IAAI,EAAE,uBAAe,CAAC,IAAI,CAAC,CAAC;AAElE,QAAA,UAAU,GAAG,CAAC,uBAAe,CAAC,KAAK,EAAE,uBAAe,CAAC,MAAM,EAAE,uBAAe,CAAC,SAAS,CAAC,CAAC;AAExF,QAAA,UAAU,GAAG,KAAK,CAAC;AAEnB,QAAA,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC;AAEvB,QAAA,gBAAgB,GAAG,CAAC,kBAAU,CAAC,CAAC;AAEhC,QAAA,YAAY,GAAG,IAAI,CAAC;AACpB,QAAA,YAAY,GAAG,IAAI,CAAC;AACpB,QAAA,eAAe,GAAG,KAAK,CAAC;AACxB,QAAA,gBAAgB,GAAmB,IAAI,CAAC;AACxC,QAAA,0BAA0B,GAAG,IAAI,CAAC;AAElC,QAAA,uBAAuB,GAAG,8BAA8B,CAAC;AAGzD,QAAA,yBAAyB,GAAG,CAAC,CAAC;AAC9B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAChC,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAC1B,QAAA,oBAAoB,GAAG,KAAK,CAAC;AAC7B,QAAA,wBAAwB,GAAG,KAAK,CAAC;AACjC,QAAA,sBAAsB,GAAG,YAAY,CAAC;AACtC,QAAA,8BAA8B,GAA6B;IACtE,mBAAmB,EAAE,KAAK;IAC1B,gBAAgB,EAAE,IAAI;CACvB,CAAC;AACW,QAAA,0BAA0B,GAAG,+BAA+B,CAAC","file":"constants.js","sourcesContent":["import type { IAnimationControlOptions } from '../types/animate';\nimport { GrammarMarkType } from './enums';\n\nexport const BridgeElementKey = '__vgrammar_scene_item__';\n\nexport const CollectionMarkType = [GrammarMarkType.line, GrammarMarkType.area];\n\nexport const Mark3DType = [GrammarMarkType.arc3d, GrammarMarkType.rect3d, GrammarMarkType.pyramid3d];\n\nexport const DefaultKey = 'key';\n\nexport const DefaultMarkData = [{}];\n\nexport const DefaultGroupKeys = [DefaultKey];\n\nexport const DefaultReuse = true;\nexport const DefaultMorph = true;\nexport const DefaultMorphAll = false;\nexport const DefaultSplitPath: null | 'clone' = null;\nexport const DefaultEnableExitAnimation = true;\n\nexport const ImmediateAnimationState = 'VGRAMMAR_IMMEDIATE_ANIMATION';\n\n/** default animation configs */\nexport const DefaultAnimationStartTime = 0;\nexport const DefaultAnimationDuration = 1000;\nexport const DefaultAnimationDelay = 0;\nexport const DefaultAnimationLoop = false;\nexport const DefaultAnimationOneByOne = false;\nexport const DefaultAnimationEasing = 'quintInOut';\nexport const DefaultAnimationControlOptions: IAnimationControlOptions = {\n stopWhenStateChange: false,\n immediatelyApply: true\n};\nexport const DefaultAnimationParameters = 'VGRAMMAR_ANIMATION_PARAMETERS';\n"]}
1
+ {"version":3,"sources":["../src/graph/constants.ts"],"names":[],"mappings":";;;AACA,mCAA0C;AAE7B,QAAA,gBAAgB,GAAG,yBAAyB,CAAC;AAE7C,QAAA,kBAAkB,GAAG,CAAC,uBAAe,CAAC,IAAI,EAAE,uBAAe,CAAC,IAAI,CAAC,CAAC;AAElE,QAAA,UAAU,GAAG,CAAC,uBAAe,CAAC,KAAK,EAAE,uBAAe,CAAC,MAAM,EAAE,uBAAe,CAAC,SAAS,CAAC,CAAC;AAExF,QAAA,UAAU,GAAG,KAAK,CAAC;AAEnB,QAAA,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC;AAEvB,QAAA,gBAAgB,GAAG,CAAC,kBAAU,CAAC,CAAC;AAEhC,QAAA,YAAY,GAAG,IAAI,CAAC;AACpB,QAAA,YAAY,GAAG,IAAI,CAAC;AACpB,QAAA,eAAe,GAAG,KAAK,CAAC;AACxB,QAAA,gBAAgB,GAAmB,IAAI,CAAC;AACxC,QAAA,0BAA0B,GAAG,IAAI,CAAC;AAElC,QAAA,uBAAuB,GAAG,8BAA8B,CAAC;AAGzD,QAAA,yBAAyB,GAAG,CAAC,CAAC;AAC9B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAChC,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAC1B,QAAA,0BAA0B,GAAG,CAAC,CAAC;AAC/B,QAAA,oBAAoB,GAAG,KAAK,CAAC;AAC7B,QAAA,wBAAwB,GAAG,KAAK,CAAC;AACjC,QAAA,sBAAsB,GAAG,YAAY,CAAC;AACtC,QAAA,8BAA8B,GAA6B;IACtE,mBAAmB,EAAE,KAAK;IAC1B,gBAAgB,EAAE,IAAI;CACvB,CAAC;AACW,QAAA,0BAA0B,GAAG,+BAA+B,CAAC","file":"constants.js","sourcesContent":["import type { IAnimationControlOptions } from '../types/animate';\nimport { GrammarMarkType } from './enums';\n\nexport const BridgeElementKey = '__vgrammar_scene_item__';\n\nexport const CollectionMarkType = [GrammarMarkType.line, GrammarMarkType.area];\n\nexport const Mark3DType = [GrammarMarkType.arc3d, GrammarMarkType.rect3d, GrammarMarkType.pyramid3d];\n\nexport const DefaultKey = 'key';\n\nexport const DefaultMarkData = [{}];\n\nexport const DefaultGroupKeys = [DefaultKey];\n\nexport const DefaultReuse = true;\nexport const DefaultMorph = true;\nexport const DefaultMorphAll = false;\nexport const DefaultSplitPath: null | 'clone' = null;\nexport const DefaultEnableExitAnimation = true;\n\nexport const ImmediateAnimationState = 'VGRAMMAR_IMMEDIATE_ANIMATION';\n\n/** default animation configs */\nexport const DefaultAnimationStartTime = 0;\nexport const DefaultAnimationDuration = 1000;\nexport const DefaultAnimationDelay = 0;\nexport const DefaultAnimationDelayAfter = 0;\nexport const DefaultAnimationLoop = false;\nexport const DefaultAnimationOneByOne = false;\nexport const DefaultAnimationEasing = 'quintInOut';\nexport const DefaultAnimationControlOptions: IAnimationControlOptions = {\n stopWhenStateChange: false,\n immediatelyApply: true\n};\nexport const DefaultAnimationParameters = 'VGRAMMAR_ANIMATION_PARAMETERS';\n"]}
@@ -23,7 +23,7 @@ export declare class Element implements IElement {
23
23
  updateData(groupKey: string | null, data: any[], key: MarkKeySpec): MarkElementItem[];
24
24
  state(markState: MarkFunctionType<string | string[]>, parameters?: any): void;
25
25
  encodeGraphic(attrs?: any): void;
26
- private _setCutomizedShape;
26
+ private _setCustomizedShape;
27
27
  encodeItems(items: MarkElementItem[], encoders: BaseEncodeSpec, isReentered?: boolean, parameters?: any): void;
28
28
  protected coordinateTransformEncode(items: MarkElementItem[]): void;
29
29
  clearStates(hasAnimation?: boolean): void;