-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.story.tsx
51 lines (48 loc) · 1.6 KB
/
default.story.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import SequencePlayer from '../src/SequencePlayer';
import SampleImage from './sample.png';
storiesOf('SequencePlayer', module)
.add('default', () => {
const playerRef = React.useRef<any>(null);
const handleControl = (action: string) => () => {
switch (action) {
case 'play': playerRef.current.play(); break;
case 'pause': playerRef.current.pause(); break;
case 'resume': playerRef.current.resume(); break;
case 'reverse': playerRef.current.reverse(); break;
}
};
return (
<div>
<button onClick={handleControl('play')}>PLAY</button>
<button onClick={handleControl('pause')}>PAUSE</button>
<button onClick={handleControl('resume')}>RESUME</button>
<button onClick={handleControl('reverse')}>REVERSE PLAY</button>
<br/><br/>
<SequencePlayer
image={SampleImage}
data={[
{ x: 0, y: 0 },
{ x: -183, y: 0 },
{ x: -366, y: 0 },
{ x: -545, y: 0 },
{ x: -732, y: 0 },
{ x: 0, y: -172 },
{ x: -183, y: -172 },
{ x: -366, y: -172 },
{ x: -549, y: -172 },
{ x: -732, y: -172 },
{ x: 0, y: -338 },
{ x: -183, y: -339 },
{ x: -363, y: -338 },
{ x: -549, y: -338 }
]}
playerSize={{ width: 183, height: 168 }}
imageSize={{ width: 918, height: 506 }}
ref={playerRef}
logging={true}
/>
</div>
);
});