|
1 | 1 | export default [
|
2 |
| - { |
3 |
| - name: 'hooks/goo', |
4 |
| - title: 'Goo blobs', |
5 |
| - link: 'https://codesandbox.io/embed/8zx4ppk01l', |
6 |
| - tags: ['useTrail'], |
7 |
| - code: { |
8 |
| - useSpring: `const [trail, set] = useTrail(3, () => ({ xy: [0, 0] })) |
9 |
| -const tr = (x, y) => \`translate3d(\${x}px,\${y}px,0)\` |
10 |
| -return ( |
11 |
| - <div onMouseMove={({ clientX: x, clientY: y }) => set({ p1: [x, y] })}> |
12 |
| - {trail.map(({ xy }, index) => ( |
13 |
| - <animated.div key={index} style={{ transform: xy.interpolate(tr) }} /> |
14 |
| - ))} |
15 |
| - </div> |
16 |
| -)`, |
17 |
| - }, |
18 |
| - }, |
19 |
| - { |
20 |
| - name: 'hooks/card', |
21 |
| - title: '3D card', |
22 |
| - link: 'https://codesandbox.io/embed/rj998k4vmm', |
23 |
| - tags: ['useSpring'], |
24 |
| - code: { |
25 |
| - useSpring: `const [props, set] = useSpring(() => ({ xys: [0, 0, 1] })) |
26 |
| -const calc = (x, y) => [-(y - height / 2), (x - width / 2), 1.1] |
27 |
| -const trans = (x, y, s) => |
28 |
| - \`perspective(600px) rotateX(\${x}deg) rotateY(\${y}deg) scale(\${s})\` |
29 |
| -return ( |
30 |
| - <animated.div |
31 |
| - onMouseMove={({ clientX: x, clientY: y }) => set({ xys: calc(x, y) })} |
32 |
| - onMouseLeave={() => set({ xys: [0, 0, 1] })} |
33 |
| - style={{ transform: props.xys.interpolate(trans) }} |
34 |
| - /> |
35 |
| -)`, |
36 |
| - }, |
37 |
| - }, |
38 |
| - { |
39 |
| - name: 'hooks/flip-card', |
40 |
| - title: 'Flip card', |
41 |
| - link: 'https://codesandbox.io/embed/01yl7knw70', |
42 |
| - tags: ['useSpring'], |
43 |
| - code: { |
44 |
| - useSpring: `const { transform, opacity } = useSpring({ |
45 |
| - opacity: flipped ? 1 : 0, |
46 |
| - transform: \`perspective(1400px) rotateX(\${flipped ? 180 : 0}deg)\`, |
47 |
| -}) |
48 |
| -return ( |
49 |
| - <a.div style={{ opacity: opacity.interpolate(o => 1 - o), transform }} /> |
50 |
| - <a.div style={{ opacity, transform: transform.interpolate(t => |
51 |
| - \`\${t} rotateX(180deg)\`) }} /> |
52 |
| -)`, |
53 |
| - }, |
54 |
| - }, |
55 |
| - { |
56 |
| - name: 'hooks/slider', |
57 |
| - title: 'Gesture slider', |
58 |
| - link: 'https://codesandbox.io/embed/zrj66y8714', |
59 |
| - tags: ['useSpring'], |
60 |
| - code: { |
61 |
| - useSpring: `const { x, bg, size } = useSpring({ |
62 |
| - x: down ? xDelta : 0, |
63 |
| - size: down ? 1.1 : 1, |
64 |
| - immediate: name => down && name === 'x' |
65 |
| -}) |
66 |
| -const transform = |
67 |
| - interpolate([x, size], (x, s) => \`translate3d(\${x}px,0,0) scale(\${s})\`) |
68 |
| -return <animated.div style={{ transform }} children="Slide">`, |
69 |
| - }, |
70 |
| - }, |
71 | 2 | {
|
72 | 3 | name: 'hooks/draggable-list',
|
73 | 4 | title: 'Draggable list',
|
74 |
| - link: 'https://codesandbox.io/embed/r5qmj8m6lq', |
75 | 5 | tags: ['useSprings'],
|
76 | 6 | },
|
77 | 7 | {
|
78 |
| - name: 'hooks/mouse-parallax', |
79 |
| - title: 'Mouse parallax', |
80 |
| - link: 'https://codesandbox.io/embed/r5x34869vq', |
81 |
| - tags: ['useSpring'], |
82 |
| - }, |
83 |
| - { |
84 |
| - name: 'hooks/scroll-parallax', |
85 |
| - title: 'Scroll parallax', |
86 |
| - link: 'https://codesandbox.io/embed/py912w5k6m', |
87 |
| - tags: ['useSpring'], |
88 |
| - }, |
89 |
| - { |
90 |
| - name: 'hooks/trails', |
91 |
| - title: 'Trails', |
92 |
| - link: 'https://codesandbox.io/embed/zn2q57vn13', |
93 |
| - tags: ['useTrail'], |
94 |
| - code: { |
95 |
| - useTrail: `const trail = useTrail(items.length, { |
96 |
| - items, |
97 |
| - opacity: toggle ? 1 : 0, |
98 |
| - x: toggle ? 0 : 20, |
99 |
| - height: toggle ? 80 : 0, |
100 |
| - from: { opacity: 0, x: 20, height: 0 }, |
101 |
| -}) |
102 |
| -const transform = x.interpolate(x => \`translate3d(0,\${x}px,0)\`) |
103 |
| -return trail.map(({ x, height, opacity }, index) => ( |
104 |
| - <animated.div key={item} style={{ opacity, transform }}> |
105 |
| - <animated.div style={{ height }}>{items[index]}</animated.div> |
106 |
| - </animated.div> |
107 |
| -))`, |
108 |
| - }, |
109 |
| - }, |
110 |
| - { |
111 |
| - name: 'hooks/simple-transition', |
112 |
| - title: 'Simple transition', |
113 |
| - link: 'https://codesandbox.io/embed/1y3yyqpq7q', |
114 |
| - tags: ['useTransition'], |
115 |
| - code: { |
116 |
| - useTransition: `const transitions = useTransition({ |
117 |
| - items: pages[index], |
118 |
| - from: { opacity: 0, transform: 'translate3d(100%,0,0)' }, |
119 |
| - enter: { opacity: 1, transform: 'translate3d(0%,0,0)' }, |
120 |
| - leave: { opacity: 0, transform: 'translate3d(-50%,0,0)' }, |
121 |
| -}) |
122 |
| -return transitions.map(({ item: Page, props, key }) => ( |
123 |
| - <Page key={key} style={props} /> |
124 |
| -))`, |
125 |
| - }, |
126 |
| - }, |
127 |
| - { |
128 |
| - name: 'hooks/image-fade', |
129 |
| - title: 'Image fade', |
130 |
| - link: 'https://codesandbox.io/embed/morr206pv8', |
131 |
| - tags: ['useTransition'], |
132 |
| - code: { |
133 |
| - useTransition: `const transitions = useTransition({ |
134 |
| - items: slides[index], |
135 |
| - keys: item => item.id, |
136 |
| - from: { opacity: 0 }, |
137 |
| - enter: { opacity: 1 }, |
138 |
| - leave: { opacity: 0 }, |
139 |
| -}) |
140 |
| -return transitions.map(({ item, props, key }) => ( |
141 |
| - <animated.div |
142 |
| - key={key} |
143 |
| - style={{ ...props, backgroundImage: \`url(\${item.url})\` }} |
144 |
| - /> |
145 |
| -))`, |
146 |
| - }, |
147 |
| - }, |
148 |
| - { |
149 |
| - name: 'hooks/multistage-transitions', |
150 |
| - title: 'Multistage transitions', |
151 |
| - link: 'https://codesandbox.io/embed/vqpqx5vrl0', |
152 |
| - tags: ['useTransition'], |
153 |
| - }, |
154 |
| - { |
155 |
| - name: 'hooks/keyframes', |
156 |
| - title: 'Emulating css keyframes', |
157 |
| - link: 'https://codesandbox.io/embed/88lmnl6w88', |
158 |
| - tags: ['useSpring'], |
159 |
| - }, |
160 |
| - { |
161 |
| - name: 'hooks/list-reordering', |
162 |
| - title: 'List-reordering', |
163 |
| - link: 'https://codesandbox.io/embed/1wqpz5mzqj', |
164 |
| - tags: ['useTransition'], |
165 |
| - }, |
166 |
| - { |
167 |
| - name: 'hooks/chain-animation', |
168 |
| - title: 'Chain animation', |
169 |
| - link: 'https://codesandbox.io/embed/2v716k56pr', |
170 |
| - tags: ['useChain'], |
171 |
| - }, |
172 |
| - { |
173 |
| - name: 'hooks/notification-hub', |
174 |
| - title: 'Notification hub', |
175 |
| - link: 'https://codesandbox.io/embed/7mqy09jyq', |
176 |
| - tags: ['useTransition'], |
177 |
| - }, |
178 |
| - { |
179 |
| - name: 'hooks/script', |
180 |
| - title: 'Spring scripting', |
181 |
| - link: 'https://codesandbox.io/embed/141nrz6v73', |
182 |
| - tags: ['useSpring'], |
183 |
| - }, |
184 |
| - { |
185 |
| - name: 'hooks/auto', |
186 |
| - title: 'Animating auto', |
187 |
| - link: 'https://codesandbox.io/embed/q3ypxr5yp4', |
188 |
| - tags: ['useSpring'], |
189 |
| - }, |
190 |
| - { |
191 |
| - name: 'hooks/tree', |
192 |
| - title: 'Treeview (nested auto)', |
193 |
| - link: 'https://codesandbox.io/embed/lp80n9z7v9', |
194 |
| - tags: ['useSpring'], |
195 |
| - }, |
196 |
| - { |
197 |
| - name: 'hooks/blackflag', |
198 |
| - title: 'Spring reset script', |
199 |
| - link: 'https://codesandbox.io/embed/8ypj5vq6m9', |
200 |
| - tags: ['useSpring'], |
201 |
| - code: { |
202 |
| - useKeyframes: `const interp = i => r => |
203 |
| - \`translate3d(0, \${15 * Math.sin(r + (i * 2 * Math.PI) / 1.6)}px, 0)\` |
204 |
| -const useScript = useKeyframes.spring(async next => { |
205 |
| - while (1) |
206 |
| - await next({ |
207 |
| - r: 2 * Math.PI, |
208 |
| - from: { r: 0 }, |
209 |
| - config: { duration: 3500 }, |
210 |
| - reset: true, |
211 |
| - }) |
212 |
| -}) |
213 |
| -
|
214 |
| -const props = useScript() |
215 |
| -return items.map(i => |
216 |
| - <animated.div style={{ transform: props.r.interpolate(interp(i)) }} />)`, |
217 |
| - }, |
218 |
| - }, |
219 |
| - { |
220 |
| - name: 'hooks/gestures-pull', |
221 |
| - title: 'Gestures (pull & release)', |
222 |
| - link: 'https://codesandbox.io/embed/r24mzvo3q', |
223 |
| - tags: ['useSpring'], |
224 |
| - }, |
225 |
| - { |
226 |
| - name: 'hooks/gestures-pager', |
227 |
| - title: 'View pager', |
228 |
| - link: 'https://codesandbox.io/embed/n9vo1my91p', |
| 8 | + name: 'hooks/card', |
| 9 | + title: 'Multi-gesture card', |
229 | 10 | tags: ['useSprings'],
|
230 | 11 | },
|
231 | 12 | {
|
232 |
| - name: 'hooks/card-flick', |
233 |
| - title: 'Card stack', |
234 |
| - link: 'https://codesandbox.io/embed/j0y0vpz59', |
| 13 | + name: 'hooks/viewpager', |
| 14 | + title: 'Viewpager', |
235 | 15 | tags: ['useSprings'],
|
236 | 16 | },
|
237 | 17 | {
|
238 |
| - name: 'hooks/masonry-grid', |
239 |
| - title: 'Masonry grid', |
240 |
| - link: 'https://codesandbox.io/embed/26mjowzpr', |
241 |
| - tags: ['useTransition'], |
242 |
| - }, |
243 |
| - { |
244 |
| - name: 'hooks/liquid', |
245 |
| - title: 'Svg filter', |
246 |
| - link: 'https://codesandbox.io/embed/rloj7nw3pn', |
247 |
| - tags: ['useSpring'], |
| 18 | + name: 'hooks/cards', |
| 19 | + title: 'Deck of cards', |
| 20 | + tags: ['useSprings'], |
248 | 21 | },
|
249 | 22 | ]
|
0 commit comments