Skip to content

Commit 94c61e4

Browse files
committed
docs: added example option with react-spring v8
1 parent 3e9716d commit 94c61e4

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

docusaurus/docs/introduction.mdx

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ sidebar_label: Getting started
66

77
import Example from './examples/'
88
import { EasterDiv } from './examples/examples'
9-
import Tabs from '@theme/Tabs';
10-
import TabItem from '@theme/TabItem';
9+
import Tabs from '@theme/Tabs'
10+
import TabItem from '@theme/TabItem'
1111

1212
React-use-gesture is a set of hooks that let you bind mouse and touch events to any React component. With the data you receive, it becomes easy to set up complex gestures like dragging and pinching with a few lines of code.
1313

@@ -44,6 +44,17 @@ npm install --save react-use-gesture
4444

4545
The following example makes a <EasterDiv>&lt;div/&gt;</EasterDiv> draggable so that it follows your mouse or finger on drag, and returns to its initial position on release.
4646

47+
> All examples in this documentation use React-spring v9, that you can install with the `next` tag: `react-spring@next`. v9 api is more convenient and allows for more compact, less distracting code. The following example is the only one available with React-spring v8.
48+
49+
<Tabs
50+
defaultValue="v9"
51+
values={[
52+
{ label: 'With React-spring v9', value: 'v9', },
53+
{ label: 'With React-spring v8', value: 'v8', },
54+
]
55+
}>
56+
<TabItem value="v9">
57+
4758
```jsx {1-100}
4859
import { useSpring, animated } from 'react-spring'
4960
import { useDrag } from 'react-use-gesture'
@@ -61,7 +72,35 @@ function PullRelease() {
6172
}
6273
```
6374

64-
> All examples in this documentation use React-spring v9, that you can install with the `next` tag: `react-spring@next`. v9 api is more convenient and allows for more compact, less distracting code.
75+
</TabItem>
76+
<TabItem value="v8">
77+
78+
```jsx {1-100}
79+
import { useSpring, animated } from 'react-spring'
80+
import { useDrag } from 'react-use-gesture'
81+
82+
function PullRelease() {
83+
const [{ xy }, set] = useSpring(() => ({ xy: [0, 0] }))
84+
85+
// Set the drag hook and define component movement based on gesture data
86+
const bind = useDrag(({ down, movement }) => {
87+
set({ xy: down ? movement : [0, 0] })
88+
})
89+
90+
// Bind it to a component
91+
return (
92+
<animated.div
93+
{...bind()}
94+
style={{
95+
transform: xy.interpolate((x, y) => `translate3d(${x}px, ${y}px, 0)`)
96+
}}
97+
/>
98+
)
99+
}
100+
```
101+
102+
</TabItem>
103+
</Tabs>
65104

66105
### How does this work?
67106

docusaurus/src/css/custom.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ nav strong {
212212
font-size: 1.2em;
213213
}
214214

215-
.pagination-nav {
216-
white-space: normal;
215+
.navbar__title {
216+
white-space: nowrap;
217217
}
218218

219219
body.dragged {

0 commit comments

Comments
 (0)