-
Notifications
You must be signed in to change notification settings - Fork 13
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
purpose
committed
Jan 14, 2025
1 parent
9d2862b
commit e99d2d6
Showing
10 changed files
with
536 additions
and
40 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
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
109 changes: 109 additions & 0 deletions
109
packages/vstory/demo/src/demos/table/runtime/show-header.tsx
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,109 @@ | ||
import React, { useEffect } from 'react'; | ||
import { | ||
Player, | ||
Story, | ||
initVR, | ||
registerGraphics, | ||
registerCharacters, | ||
IStoryDSL | ||
} from '../../../../../../vstory-core/src'; | ||
import { | ||
registerVComponentAction, | ||
registerVChartAction, | ||
registerVTableAction | ||
} from '../../../../../../vstory-player/src'; | ||
import { listTableOption } from '../option-list-table'; | ||
import { cloneDeep } from '@visactor/vutils'; | ||
|
||
registerGraphics(); | ||
registerCharacters(); | ||
registerVChartAction(); | ||
registerVComponentAction(); | ||
registerVTableAction(); | ||
initVR(); | ||
|
||
function loadDSL() { | ||
const dsl: IStoryDSL = { | ||
characters: [ | ||
{ | ||
type: 'VTable', | ||
id: 'table0', | ||
zIndex: 10, | ||
position: { | ||
top: 20, | ||
left: 20, | ||
width: 500, | ||
height: 300 | ||
}, | ||
options: { | ||
spec: cloneDeep(listTableOption), | ||
initOption: { | ||
interactive: true, | ||
animation: false, | ||
disableTriggerEvent: true, | ||
disableDirtyBounds: true | ||
}, | ||
showHeader: false | ||
} | ||
} | ||
], | ||
acts: [] | ||
}; | ||
dsl.acts = [ | ||
{ | ||
id: 'defaultAct', | ||
scenes: [ | ||
{ | ||
id: 'defaultScene', | ||
actions: [ | ||
{ | ||
characterId: dsl.characters.map(i => i.id), | ||
characterActions: [ | ||
{ | ||
action: 'bounce', | ||
payload: { | ||
animation: { | ||
duration: 2000, | ||
easing: 'quadOut' | ||
}, | ||
type: 'bounce4', | ||
flipY: true | ||
// dy: 30, | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
]; | ||
return dsl; | ||
} | ||
|
||
export const ShowHeader = () => { | ||
const id = 'show-header'; | ||
|
||
useEffect(() => { | ||
const container = document.getElementById(id); | ||
const canvas = document.createElement('canvas'); | ||
container?.appendChild(canvas); | ||
|
||
const story = new Story(null, { canvas, width: 700, height: 500, background: 'gray' }); | ||
const player = new Player(story); | ||
story.init(player); | ||
// @ts-ignore | ||
window.story = story; | ||
// @ts-ignore | ||
window.player = player; | ||
const dsl = loadDSL(); | ||
story.load(dsl); | ||
player.play(-1); | ||
|
||
return () => { | ||
story.release(); | ||
}; | ||
}, []); | ||
|
||
return <div style={{ width: '100%', height: '100%' }} id={id}></div>; | ||
}; |
Oops, something went wrong.