Skip to content

Commit 3be70c5

Browse files
committed
nit: update to v6
1 parent 16a10fa commit 3be70c5

File tree

13 files changed

+170
-612
lines changed

13 files changed

+170
-612
lines changed

demos/hooks/boundaries/index.js

+11-17
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,20 @@ const boundaries = [-100, 100, 100, -100]
88

99
export default function Boundaries() {
1010
const [{ x, y }, set] = useSpring(() => ({ x: 0, y: 0 }))
11-
const bind = useDrag(({ delta, memo = [x.getValue(), y.getValue()] }) => {
12-
const [top, right, bottom, left] = boundaries
13-
set({
14-
x: clamp(memo[0] + delta[0], left, right),
15-
y: clamp(memo[1] + delta[1], top, bottom),
16-
})
17-
return memo
18-
})
11+
const bind = useDrag(
12+
({ movement: [mx, my], memo = [x.getValue(), y.getValue()] }) => {
13+
const [top, right, bottom, left] = boundaries
14+
set({
15+
x: clamp(memo[0] + mx, left, right),
16+
y: clamp(memo[1] + my, top, bottom),
17+
})
18+
return memo
19+
}
20+
)
1921
return (
2022
<div className="flex-content boundaries">
2123
<div>
22-
<animated.div
23-
{...bind()}
24-
style={{
25-
transform: interpolate(
26-
[x, y],
27-
(x, y) => `translate3d(${x}px,${y}px,0)`
28-
),
29-
}}
30-
/>
24+
<animated.div {...bind()} style={{ x, y }} />
3125
</div>
3226
</div>
3327
)

demos/hooks/cards/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react'
2-
import { useSprings, animated, interpolate } from 'react-spring'
3-
import { useGesture } from 'react-use-gesture'
2+
import { useSprings, animated, to as interpolate } from 'react-spring'
3+
import { useDrag } from 'react-use-gesture'
44
import './styles.css'
55

66
const cards = [
@@ -33,11 +33,11 @@ export default function Deck() {
3333
from: from(i),
3434
})) // Create a bunch of springs using the helpers above
3535
// Create a gesture, we're interested in down-state, delta (current-pos - click-pos), direction and velocity
36-
const bind = useGesture(
36+
const bind = useDrag(
3737
({
3838
args: [index],
3939
down,
40-
delta: [xDelta],
40+
movement: [mx],
4141
distance,
4242
direction: [xDir],
4343
velocity,
@@ -48,8 +48,8 @@ export default function Deck() {
4848
set(i => {
4949
if (index !== i) return // We're only interested in changing spring-data for the current spring
5050
const isGone = gone.has(index)
51-
const x = isGone ? (200 + window.innerWidth) * dir : down ? xDelta : 0 // When a card is gone it flys out left or right, otherwise goes back to zero
52-
const rot = xDelta / 100 + (isGone ? dir * 10 * velocity : 0) // How much the card tilts, flicking it harder makes it rotate faster
51+
const x = isGone ? (200 + window.innerWidth) * dir : down ? mx : 0 // When a card is gone it flys out left or right, otherwise goes back to zero
52+
const rot = mx / 100 + (isGone ? dir * 10 * velocity : 0) // How much the card tilts, flicking it harder makes it rotate faster
5353
const scale = down ? 1.1 : 1 // Active cards lift up a bit
5454
return {
5555
x,

demos/hooks/compilation/index.js

-238
This file was deleted.

0 commit comments

Comments
 (0)