提供用于处理复杂手势的 API 的库。
用于处理复杂手势的 API。来自项目的自述文件:
¥An API for handling complex gestures. From the project's README:
该库提供了一个 API,可公开特定于移动平台的触摸和手势处理和识别的原生功能。它允许定义复杂的手势处理和识别逻辑,这些逻辑 100% 在原生线程中运行,因此具有确定性。
¥This library provides an API that exposes mobile platform-specific native capabilities of touch and gesture handling and recognition. It allows for defining complex gesture handling and recognition logic that runs 100% in the native thread and is therefore deterministic.
Android Device | Android Emulator | iOS Device | iOS Simulator | Web |
---|---|---|---|---|
¥Installation
-
npx expo install react-native-gesture-handler
If you're installing this in a bare React Native app, you should also follow these additional installation instructions.
将此导入添加到应用入口文件的顶部,例如 App.js:
¥Add this import to the top of your app entry file, such as App.js:
import 'react-native-gesture-handler';
这将确保向 React Native 注册适当的事件处理程序。现在,你可以在需要的地方导入手势处理程序:
¥This will ensure that appropriate event handlers are registered with React Native. Now, you can import gesture handlers wherever you need them:
import { TapGestureHandler, RotationGestureHandler } from 'react-native-gesture-handler';
class ComponentName extends Component {
render() {
return (
<TapGestureHandler>
<RotationGestureHandler>...</RotationGestureHandler>
</TapGestureHandler>
);
}
}
¥Usage
有关 API 和用法的更多信息,请阅读 react-native-gesture-handler 文档。
¥Read the react-native-gesture-handler docs for more information on the API and usage.