-
Notifications
You must be signed in to change notification settings - Fork 165
/
Copy pathon.stories.js
117 lines (103 loc) · 2.32 KB
/
on.stories.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import { storiesOf } from '@storybook/html'
storiesOf('on()', module)
.add(
'open',
() => `
<img src="image-2.jpg">
<script>
const zoom = mediumZoom('img');
zoom.on('open', () => alert('open'));
</script>
`,
{
notes: {
markdown:
'The `open` event fires immediately when the open method is called.',
},
}
)
.add(
'opened',
() => `
<img src="image-2.jpg">
<script>
const zoom = mediumZoom('img');
zoom.on('opened', () => alert('opened'));
</script>
`,
{
notes: {
markdown:
'The `opened` event fires when the zoom has finished being animated.',
},
}
)
.add(
'close',
() => `
<img src="image-2.jpg">
<script>
const zoom = mediumZoom('img');
zoom.on('close', () => alert('close'));
</script>
`,
{
notes: {
markdown:
'The `close` event fires immediately when the `close` instance method is called.',
},
}
)
.add(
'closed',
() => `
<img src="image-2.jpg">
<script>
const zoom = mediumZoom('img');
zoom.on('closed', () => alert('closed'));
</script>
`,
{
notes: {
markdown:
'The `closed` event fires when the zoom out has finished being animated.',
},
}
)
.add(
'detach',
() => `
<img src="image-2.jpg">
<div>
<button id="detach">Detach</button>
</div>
<script>
const zoom = mediumZoom('img');
const button = document.querySelector('#detach');
button.addEventListener('click', () => zoom.detach());
zoom.on('detach', () => alert('detach'), { once: true });
</script>
`,
{
notes: {
markdown: `The \`detach\` event fires when the \`detach\` instance method is called.
Once detached, the image is not part of the zoom anymore.`,
},
}
)
.add(
'open only once',
() => `
<img src="image-2.jpg">
<script>
const zoom = mediumZoom('img');
zoom.on('open', () => alert('open'), { once: true });
</script>
`,
{
notes: {
markdown:
'The `open` event fires immediately and only once when the open method is called.',
},
}
)