@visactor/vgrammar-core 0.9.0 → 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.
- package/cjs/component/title.d.ts +4 -3
- package/cjs/component/title.js.map +1 -1
- package/cjs/graph/animation/animate.js +5 -3
- package/cjs/graph/animation/animate.js.map +1 -1
- package/cjs/graph/animation/animator.js +5 -2
- package/cjs/graph/animation/animator.js.map +1 -1
- package/cjs/graph/animation/config.js +9 -7
- package/cjs/graph/animation/config.js.map +1 -1
- package/cjs/graph/attributes/transform.js +1 -1
- package/cjs/graph/attributes/transform.js.map +1 -1
- package/cjs/graph/constants.d.ts +1 -0
- package/cjs/graph/constants.js +3 -3
- package/cjs/graph/constants.js.map +1 -1
- package/cjs/graph/element.d.ts +3 -1
- package/cjs/graph/element.js +23 -20
- package/cjs/graph/element.js.map +1 -1
- package/cjs/graph/glyph-element.js +2 -3
- package/cjs/graph/glyph-element.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/parse/scale.js +1 -1
- package/cjs/parse/scale.js.map +1 -1
- package/cjs/semantic-marks/interval.js +4 -2
- package/cjs/semantic-marks/interval.js.map +1 -1
- package/cjs/transforms/data/contour.js +2 -1
- package/cjs/transforms/data/contour.js.map +1 -1
- package/cjs/transforms/data/sampling.js +3 -3
- package/cjs/transforms/data/sampling.js.map +1 -1
- package/cjs/transforms/data/unfold.js +2 -2
- package/cjs/transforms/data/unfold.js.map +1 -1
- package/cjs/transforms/mark/symmetry.js +2 -1
- package/cjs/transforms/mark/symmetry.js.map +1 -1
- package/cjs/transforms/util/util.d.ts +0 -2
- package/cjs/transforms/util/util.js +2 -11
- package/cjs/transforms/util/util.js.map +1 -1
- package/cjs/types/animate.d.ts +2 -0
- package/cjs/types/animate.js.map +1 -1
- package/cjs/types/component.d.ts +5 -5
- package/cjs/types/component.js.map +1 -1
- package/cjs/types/element.d.ts +2 -0
- package/cjs/types/element.js.map +1 -1
- package/cjs/types/grammar.d.ts +2 -1
- package/cjs/types/grammar.js.map +1 -1
- package/cjs/types/mark.d.ts +1 -0
- package/cjs/types/mark.js.map +1 -1
- package/cjs/view/View.js +3 -1
- package/cjs/view/View.js.map +1 -1
- package/cjs/view/dataflow.js +7 -7
- package/cjs/view/dataflow.js.map +1 -1
- package/cjs/view/mark.d.ts +3 -1
- package/cjs/view/mark.js +9 -3
- package/cjs/view/mark.js.map +1 -1
- package/es/component/title.d.ts +4 -3
- package/es/component/title.js.map +1 -1
- package/es/graph/animation/animate.js +4 -3
- package/es/graph/animation/animate.js.map +1 -1
- package/es/graph/animation/animator.js +5 -2
- package/es/graph/animation/animator.js.map +1 -1
- package/es/graph/animation/config.js +10 -8
- package/es/graph/animation/config.js.map +1 -1
- package/es/graph/attributes/transform.js +1 -1
- package/es/graph/attributes/transform.js.map +1 -1
- package/es/graph/constants.d.ts +1 -0
- package/es/graph/constants.js +2 -0
- package/es/graph/constants.js.map +1 -1
- package/es/graph/element.d.ts +3 -1
- package/es/graph/element.js +23 -19
- package/es/graph/element.js.map +1 -1
- package/es/graph/glyph-element.js +2 -3
- package/es/graph/glyph-element.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interactions/brush-filter.js +2 -1
- package/es/interactions/element-highlight-by-group.js +1 -2
- package/es/interactions/index.js +2 -1
- package/es/interactions/legend-filter.js +1 -1
- package/es/interactions/player-filter.js +1 -1
- package/es/interactions/roll-up.js +1 -1
- package/es/interactions/scrollbar-filter.js +1 -1
- package/es/interactions/slider-filter.js +1 -1
- package/es/interactions/tooltip.js +1 -1
- package/es/interactions/view-drag-mixin.js +1 -1
- package/es/parse/coordinate.js +1 -1
- package/es/parse/event.js +1 -1
- package/es/parse/mark.js +1 -1
- package/es/parse/option.js +1 -1
- package/es/parse/scale.js +3 -4
- package/es/parse/scale.js.map +1 -1
- package/es/parse/transform.js +1 -1
- package/es/parse/util.js +1 -1
- package/es/parse/view.js +1 -1
- package/es/semantic-marks/interval.js +3 -3
- package/es/semantic-marks/interval.js.map +1 -1
- package/es/transforms/data/contour.js +2 -2
- package/es/transforms/data/contour.js.map +1 -1
- package/es/transforms/data/sampling.js +5 -3
- package/es/transforms/data/sampling.js.map +1 -1
- package/es/transforms/data/unfold.js +3 -3
- package/es/transforms/data/unfold.js.map +1 -1
- package/es/transforms/mark/symmetry.js +2 -2
- package/es/transforms/mark/symmetry.js.map +1 -1
- package/es/transforms/util/util.d.ts +0 -2
- package/es/transforms/util/util.js +0 -8
- package/es/transforms/util/util.js.map +1 -1
- package/es/types/animate.d.ts +2 -0
- package/es/types/animate.js.map +1 -1
- package/es/types/component.d.ts +5 -5
- package/es/types/component.js.map +1 -1
- package/es/types/element.d.ts +2 -0
- package/es/types/element.js.map +1 -1
- package/es/types/grammar.d.ts +2 -1
- package/es/types/grammar.js.map +1 -1
- package/es/types/mark.d.ts +1 -0
- package/es/types/mark.js.map +1 -1
- package/es/view/View.js +3 -1
- package/es/view/View.js.map +1 -1
- package/es/view/dataflow.js +9 -8
- package/es/view/dataflow.js.map +1 -1
- package/es/view/mark.d.ts +3 -1
- package/es/view/mark.js +9 -3
- package/es/view/mark.js.map +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAW1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AACtG,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EA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AI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;SAC1D;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;CACF","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,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAW1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AACtG,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAA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C;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,UAAU,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;SAC1D;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;CACF","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"]}
|
|
@@ -51,7 +51,9 @@ export class Animator {
|
|
|
51
51
|
this.isAnimating = !1, this.runnings = null, invokeCallback && (null === (_a = this.callbackFunction) || void 0 === _a || _a.call(null));
|
|
52
52
|
}
|
|
53
53
|
animateElement(animationParameters, parameters) {
|
|
54
|
-
const
|
|
54
|
+
const graphicItem = this.element.getGraphicItem();
|
|
55
|
+
if (!graphicItem) return;
|
|
56
|
+
const graphicAnimate = graphicItem.animate();
|
|
55
57
|
this.runnings.push(graphicAnimate), graphicAnimate.startAt(this.unit.initialDelay),
|
|
56
58
|
graphicAnimate.wait(this.unit.loopDelay), this.unit.timeSlices.forEach((timeSlice => {
|
|
57
59
|
this.animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters);
|
|
@@ -63,7 +65,7 @@ export class Animator {
|
|
|
63
65
|
}));
|
|
64
66
|
}
|
|
65
67
|
animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters) {
|
|
66
|
-
const delay = timeSlice.delay, duration = timeSlice.duration, effects = timeSlice.effects;
|
|
68
|
+
const delay = timeSlice.delay, delayAfter = timeSlice.delayAfter, duration = timeSlice.duration, effects = timeSlice.effects;
|
|
67
69
|
if (delay > 0 && graphicAnimate.wait(delay), effects.length < 0) graphicAnimate.wait(duration); else {
|
|
68
70
|
const customAnimates = effects.map(((effect, index) => {
|
|
69
71
|
var _a;
|
|
@@ -78,6 +80,7 @@ export class Animator {
|
|
|
78
80
|
})).filter((animate => !isNil(animate)));
|
|
79
81
|
1 === customAnimates.length ? graphicAnimate.play(customAnimates[0]) : graphicAnimate.play(new AnimateGroup(duration, customAnimates));
|
|
80
82
|
}
|
|
83
|
+
delayAfter > 0 && graphicAnimate.wait(delayAfter);
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
//# sourceMappingURL=animator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAa5F,OAAO,EA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CAAC,CAAC;aACxC;iBAAM;gBACL,cAAc,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;aACjE;SACF;IACH,CAAC;CACF","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 graphicAnimate: IGraphicAnimate = this.element.getGraphicItem().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,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAa5F,OAAO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CAAC,OAAO,CAAC,CAAC,CAAC;YAEtC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC/B,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;aACxC;iBAAM;gBACL,cAAc,CAAC,IAAI,CAAC,IAAI,YAAY,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","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"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { array, isFunction, isNil, merge } from "@visactor/vutils";
|
|
2
2
|
|
|
3
|
-
import { DefaultAnimationControlOptions, DefaultAnimationDelay, DefaultAnimationDuration, DefaultAnimationEasing, DefaultAnimationLoop, DefaultAnimationOneByOne, DefaultAnimationStartTime } from "../constants";
|
|
3
|
+
import { DefaultAnimationControlOptions, DefaultAnimationDelay, DefaultAnimationDelayAfter, DefaultAnimationDuration, DefaultAnimationEasing, DefaultAnimationLoop, DefaultAnimationOneByOne, DefaultAnimationStartTime } from "../constants";
|
|
4
4
|
|
|
5
5
|
function transformToTimelineConfig(animationConfig) {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
7
7
|
if (isNil(animationConfig.timeSlices)) {
|
|
8
8
|
const typeConfig = animationConfig;
|
|
9
9
|
return {
|
|
@@ -15,11 +15,12 @@ function transformToTimelineConfig(animationConfig) {
|
|
|
15
15
|
timeSlices: [ {
|
|
16
16
|
duration: null !== (_e = typeConfig.duration) && void 0 !== _e ? _e : DefaultAnimationDuration,
|
|
17
17
|
delay: null !== (_f = typeConfig.delay) && void 0 !== _f ? _f : DefaultAnimationDelay,
|
|
18
|
+
delayAfter: null !== (_g = typeConfig.delayAfter) && void 0 !== _g ? _g : DefaultAnimationDelayAfter,
|
|
18
19
|
effects: [ {
|
|
19
20
|
type: typeConfig.type,
|
|
20
21
|
channel: typeConfig.channel,
|
|
21
22
|
custom: typeConfig.custom,
|
|
22
|
-
easing: null !== (
|
|
23
|
+
easing: null !== (_h = typeConfig.easing) && void 0 !== _h ? _h : DefaultAnimationEasing,
|
|
23
24
|
customParameters: typeConfig.customParameters,
|
|
24
25
|
options: typeConfig.options
|
|
25
26
|
} ]
|
|
@@ -28,16 +29,17 @@ function transformToTimelineConfig(animationConfig) {
|
|
|
28
29
|
}
|
|
29
30
|
const formattedTimeSlices = array(animationConfig.timeSlices).filter((timeSlice => timeSlice.effects && array(timeSlice.effects).filter((effect => effect.channel || effect.type)).length));
|
|
30
31
|
if (formattedTimeSlices.length) return {
|
|
31
|
-
startTime: null !== (
|
|
32
|
+
startTime: null !== (_j = animationConfig.startTime) && void 0 !== _j ? _j : DefaultAnimationStartTime,
|
|
32
33
|
totalTime: animationConfig.totalTime,
|
|
33
|
-
oneByOne: null !== (
|
|
34
|
-
loop: null !== (
|
|
35
|
-
controlOptions: merge({}, DefaultAnimationControlOptions, null !== (
|
|
34
|
+
oneByOne: null !== (_k = animationConfig.oneByOne) && void 0 !== _k ? _k : DefaultAnimationOneByOne,
|
|
35
|
+
loop: null !== (_l = animationConfig.loop) && void 0 !== _l ? _l : DefaultAnimationLoop,
|
|
36
|
+
controlOptions: merge({}, DefaultAnimationControlOptions, null !== (_m = animationConfig.controlOptions) && void 0 !== _m ? _m : {}),
|
|
36
37
|
timeSlices: formattedTimeSlices.map((timeSlice => {
|
|
37
|
-
var _a;
|
|
38
|
+
var _a, _b;
|
|
38
39
|
return {
|
|
39
40
|
duration: timeSlice.duration,
|
|
40
41
|
delay: null !== (_a = timeSlice.delay) && void 0 !== _a ? _a : DefaultAnimationDelay,
|
|
42
|
+
delayAfter: null !== (_b = timeSlice.delayAfter) && void 0 !== _b ? _b : DefaultAnimationDelayAfter,
|
|
41
43
|
effects: array(timeSlice.effects).filter((effect => effect.channel || effect.type)).map((effect => {
|
|
42
44
|
var _a;
|
|
43
45
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AASn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AU,CAAC,CAAC;KACjE;IACD,OAAO,IAAI,CAAC;AACd,CAAC","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,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KA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,IAA8B,EAAE,OAAiB,EAAE,UAAe;IACrG,IAAI,UAAU,CAAC,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","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"]}
|
|
@@ -35,7 +35,7 @@ export const transformsByType = {
|
|
|
35
35
|
}
|
|
36
36
|
} ],
|
|
37
37
|
[GrammarMarkType.line]: [ {
|
|
38
|
-
channels: [ "x", "y", "defined"
|
|
38
|
+
channels: [ "x", "y", "defined" ],
|
|
39
39
|
transform: (graphicAttributes, nextAttrs, storedAttrs) => {
|
|
40
40
|
graphicAttributes.x = 0, graphicAttributes.y = 0;
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/attributes/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;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,CAA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,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,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBAClC,wBAAwB,CAAC,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,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAClC,wBAAwB,CAAC,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","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,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,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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","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"]}
|
package/es/graph/constants.d.ts
CHANGED
|
@@ -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";
|
package/es/graph/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAE1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;AAE/E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;AAErG,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAEhC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAU,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAmB,IAAI,CAAC;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAGtE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAC1C,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAC;AACnD,MAAM,CAAC,MAAM,8BAA8B,GAA6B;IACtE,mBAAmB,EAAE,KAAK;IAC1B,gBAAgB,EAAE,IAAI;CACvB,CAAC;AACF,MAAM,CAAC,MAAM,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,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAE1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;AAE/E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;AAErG,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAEhC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAU,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAmB,IAAI,CAAC;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAGtE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAC1C,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAC;AACnD,MAAM,CAAC,MAAM,8BAA8B,GAA6B;IACtE,mBAAmB,EAAE,KAAK;IAC1B,gBAAgB,EAAE,IAAI;CACvB,CAAC;AACF,MAAM,CAAC,MAAM,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"]}
|
package/es/graph/element.d.ts
CHANGED
|
@@ -16,12 +16,14 @@ export declare class Element implements IElement {
|
|
|
16
16
|
initGraphicItem(attributes?: any): void;
|
|
17
17
|
updateGraphicItem(config: IMarkConfig): void;
|
|
18
18
|
getGraphicItem(): IGraphic<Partial<IGraphicAttribute>>;
|
|
19
|
+
removeGraphicItem(): void;
|
|
20
|
+
resetGraphicItem(): void;
|
|
19
21
|
getBounds(): import("@visactor/vutils").IBounds;
|
|
20
22
|
getStates(): string[];
|
|
21
23
|
updateData(groupKey: string | null, data: any[], key: MarkKeySpec): MarkElementItem[];
|
|
22
24
|
state(markState: MarkFunctionType<string | string[]>, parameters?: any): void;
|
|
23
25
|
encodeGraphic(attrs?: any): void;
|
|
24
|
-
private
|
|
26
|
+
private _setCustomizedShape;
|
|
25
27
|
encodeItems(items: MarkElementItem[], encoders: BaseEncodeSpec, isReentered?: boolean, parameters?: any): void;
|
|
26
28
|
protected coordinateTransformEncode(items: MarkElementItem[]): void;
|
|
27
29
|
clearStates(hasAnimation?: boolean): void;
|