Skip to content

Commit

Permalink
docs: 添加 react-use-gesture 用法
Browse files Browse the repository at this point in the history
  • Loading branch information
cncolder committed Apr 24, 2020
1 parent e971321 commit bedef7e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,18 @@ const config = {

## 类库

* [x] [react-vtree](docs/react-vtree.mdx) - 虚拟滚动树
* [x] `FixedSizeTree`
### 虚拟滚动

* [x] [react-window](docs/react-window.mdx) - 虚拟滚动
* [x] `FixedSizeList`
* [x] `VariableSizeList`
* [x] [react-vtree](docs/react-vtree.mdx) - 虚拟滚动树
* [x] `FixedSizeTree`

### 交互动画

* [x] [react-spring](docs/react-spring.mdx) - 弹性物理动画
* [x] [react-use-gesture](docs/react-use-gesture.mdx) - 触摸手势

## 支持

Expand Down
30 changes: 30 additions & 0 deletions docs/react-use-gesture.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
id: react-use-gesture
title: react-use-gesture
sidebar_label: react-use-gesture
---

## [react-use-gesture](https://github.com/react-spring/react-use-gesture)

### 使用

```jsx
import React from 'react'
import { View } from '@tarojs/components'
import { useDrag } from 'react-use-gesture'
import { useGestureConfig } from '@tarojsx/library'

const Demo = () => {
const [gestureConfig, containerProps] = useGestureConfig()

const bind = useDrag(({ down, movement: [mx, my], direction: [xDir, yDir], distance, cancel }) => {
console.log('按下', down)
console.log('轴移动距离', mx, my)
console.log('轴移动方向', xDir, yDir)
console.log('直线移动距离', distance)
console.log('取消拖动操作', cancel)
}, gestureConfig)

return <View {...containerProps}>{<View {...bind()} />}</View>
}
```
10 changes: 2 additions & 8 deletions docs/react-window.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,17 @@ sidebar_label: react-window

## [react-window](https://github.com/bvaughn/react-window)

### 安装

`npm i react-window`

`npm i -D @types/react-window`

### 使用

```jsx
import React from 'react'
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import { FixedSizeList } from 'react-window'
import { FixedSizeList } from '@tarojsx/library'

const { windowWidth, windowHeight } = Taro.getSystemInfoSync()

const Example = () => (
const Demo = () => (
<FixedSizeList width={windowWidth} height={windowHeight} itemCount={1000} itemSize={35}>
{({ index, style }) => <View style={style}>Row {index}</View>}
</FixedSizeList>
Expand Down

0 comments on commit bedef7e

Please sign in to comment.