-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
148 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/vstory/src/dsl/story-processor/vchart/charts/character/characterAppear.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { VChart, ISpec } from '@visactor/vchart'; | ||
import type { IChartAppearAction } from '../../../../types/chart/appear'; | ||
import type { ICharacterVisactor } from '../../../../../story/character/visactor/interface'; | ||
import { graphicAppearProcessor } from '../../../graphic/appear'; | ||
import { appearEffectMap } from '../../../graphic/effect/appear'; | ||
|
||
export const characterAppearProcessor = async ( | ||
chartInstance: ICharacterVisactor, | ||
spec: ISpec, | ||
action: IChartAppearAction | ||
) => { | ||
const chart = chartInstance.getGraphicParent(); | ||
const vchart = chart?._vchart; | ||
const instance: VChart = vchart ? vchart : chartInstance; | ||
if (!instance) { | ||
return; | ||
} | ||
|
||
const { animation } = action.payload ?? {}; | ||
const { effect } = animation ?? {}; | ||
|
||
const effects = effect && appearEffectMap[effect] ? [effect] : Object.keys(appearEffectMap); | ||
|
||
effects.forEach(effect => { | ||
instance | ||
.getChart() | ||
.getAllMarks() | ||
.forEach(mark => { | ||
const product = mark.getProduct(); | ||
if (product) { | ||
const graphic = product.getGroupGraphicItem(); | ||
const appearEffect = appearEffectMap[effect]; | ||
appearEffect(graphic, animation); | ||
} | ||
}); | ||
}); | ||
}; |
26 changes: 26 additions & 0 deletions
26
packages/vstory/src/dsl/story-processor/vchart/charts/character/characterDisappear.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import VChart, { ISpec } from '@visactor/vchart'; | ||
import { IChartAppearAction } from '../../../../types/chart/appear'; | ||
import { ICharacterVisactor } from '../../../../../story/character/visactor/interface'; | ||
import { graphicDisappearProcessor } from '../../../graphic/disappear'; | ||
|
||
export const characterDisappearProcessor = async ( | ||
chartInstance: ICharacterVisactor, | ||
spec: ISpec, | ||
action: IChartAppearAction | ||
) => { | ||
const chart = chartInstance.getGraphicParent(); | ||
const vchart = chart?._vchart; | ||
const instance: VChart = vchart ? vchart : chartInstance; | ||
|
||
if (!instance) { | ||
return; | ||
} | ||
// Group Disappear | ||
// @ts-ignore | ||
graphicDisappearProcessor(chartInstance, spec, action); | ||
|
||
// 隐藏group | ||
chart.setAttributes({ | ||
visible: false | ||
}); | ||
}; |
10 changes: 10 additions & 0 deletions
10
packages/vstory/src/dsl/story-processor/vchart/charts/character/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { characterAppearProcessor } from './characterAppear'; | ||
import { characterDisappearProcessor } from './characterDisappear'; | ||
|
||
export { characterDisappearProcessor } from './characterDisappear'; | ||
export { characterAppearProcessor } from './characterAppear'; | ||
|
||
export const characterProcessorMap = { | ||
appear: characterAppearProcessor, | ||
disappear: characterDisappearProcessor | ||
}; |
3 changes: 1 addition & 2 deletions
3
packages/vstory/src/dsl/story-processor/vchart/marks/rect/appear.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters