Skip to content

Commit

Permalink
Merge pull request #14 from VisActor/feat/playerOption
Browse files Browse the repository at this point in the history
feat: story support playerOption
  • Loading branch information
neuqzxy authored Jul 15, 2024
2 parents c1ca516 + 2904991 commit d2add1e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/vstory/demo/src/demos/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ export function Player(props: IPlayerPropsType) {
}
}
console.log(json);
const story = new Story(json, { dom: 'abc' });
const story = new Story(json, { dom: 'abc', playerOption: { scaleX: 0.5, scaleY: 0.5 } });
storyRef.current = story;
story.play();
}, [props.code]);
Expand Down
2 changes: 1 addition & 1 deletion packages/vstory/demo/src/demos/VChartSite/VChartSite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const VChartSiteDemo = () => {
]
};
console.log('dsl', tempSpec);
const story = new Story(tempSpec, { dom: id });
const story = new Story(tempSpec, { dom: id, playerOption: { scaleX: 0.5, scaleY: 0.5 } });
window.story = story;
story.play();
const btn1 = document.createElement('button');
Expand Down
4 changes: 4 additions & 0 deletions packages/vstory/src/story/interface/runtime-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type { IGraphic } from '@visactor/vrender';

export interface IStoryInitOption {
dom: string | HTMLDivElement; // dom id
playerOption?: {
scaleX?: number;
scaleY?: number;
};
}

export interface IStory {
Expand Down
6 changes: 5 additions & 1 deletion packages/vstory/src/story/player/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ export class Player implements IPlayer {
// protected _encoder: Encoder;
protected _actionProcessor: ActionProcessor;

constructor(c: StoryCanvas) {
constructor(c: StoryCanvas, options?: { scaleX?: number; scaleY?: number }) {
this._canvas = c;
this._acts = [];
this._ticker = new Ticker();
this._currTime = 0;
c.getStage().defaultLayer.setAttributes({
scaleX: options?.scaleX ?? 1,
scaleY: options?.scaleY ?? 1
});
// this._encoder = new Encoder();
this._actionProcessor = new ActionProcessor(processorMap);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vstory/src/story/story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Story implements IStory {
this,
isString(option.dom) ? (document.getElementById(option.dom) as HTMLDivElement) : option.dom
);
this._player = new Player(this._canvas);
this._player = new Player(this._canvas, option.playerOption);

if (spec) {
this.load(spec);
Expand Down

0 comments on commit d2add1e

Please sign in to comment.