- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们已经使用 React Native PanResponder 开发了一个滑动器,(在有人发表评论之前)——我们不能在这里使用任何其他滑动器库。在我们开发的滑动器中,我们面临一个问题,当用户结束滑动(意味着释放 Pan)时,启动 Spring 动画会出现延迟。
因此,为了解决这个问题,我们正在尝试从 React Native Animated API 移动至 Reanimated Libary这可以解决用户面临的延迟问题。
But while developing with React Native Gesture Handler (PanGestureHandler) and Reanimated Library, we're unable to detect swipe direction in the gesture handler.
我正在添加我们用来在 PanResponder 中检测滑动方向的代码部分
onPanMoving = (evt, {dx}) => {
this.draggedEnd = dx < -this.swipeThreshold; //You are moving towards right screen
this.draggedStart = dx > this.swipeThreshold; //You are moving towards left screen
}
如您所见,在 PanResponder 中检测平移时的方向非常容易。
Here comes the problem with Gesture Handler,
I'm unable to detect swipe while the gesture state is active
我已经在 Gesture Handler 中搜索了问题,我找到了 this .
问题中提出了两个解决方法
这两种解决方法都不能解决我们的问题。
那么有没有其他方法可以使用 PanGestureHandler 和 Reanimated 找到方向。我尝试使用具有 dx 值的 Reanimated 的 PanResponder,但最终出现错误消息,即仅支持 nativeEvent 属性,因为 dx 来自 PanResponder 的 gestureState 参数。
注意:我们不能使用 FlingGestureHandler 和 Swipeables 因为我们仍然需要在 Fling 中找到方向 onHandlerStateChange 并且 Swipeables 不使用 Reanimated。
最佳答案
你可以通过属性velocityX
水平滑动时检测方向
示例:
const handleGesture = (evt) => {
const { nativeEvent } = evt;
if (nativeEvent.velocityX > 0) {
console.log('Swipe right');
} else {
console.log('Swipe left');
}
};
return (
<PanGestureHandler onGestureEvent={handleGesture}>
// child component
</PanGestureHandler>
);
关于react-native - 使用 React Native Gesture Handler 和 Reanimated 检测滑动方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58939431/
我正在尝试使用“@react-navigation/top-tabs”,但它依赖于 reanimated 2我安装了 reanimated 2 但仍然收到相同的警告: If you want to u
我已尽我所能来修复此错误。我尝试卸载 reanimated-bottom-sheet 和 react-native-reanimated 并重新安装它们。清除缓存。我不知道要编辑的 babel.con
嗨,我最近创建了一个 react native 应用程序版本 0.60.5,并安装了 react-navigation 和 react-native-reanimated。当我在 Android St
我有一个使用 .animate 的 div。我的 div CSS 位于: position:fixed; bottom:-240px; 动画脚本是: $("#media").click(func
我正在学习 reanimated,因为它在 UI 线程上工作,我想实现旋转动画。以度数旋转(如 45 度)不起作用并提示错误。那么我们如何在react-native-reanimation v1(ve
我想使用 withSequence 并将直接值作为第一个值,使用下面的代码导致应用程序崩溃。 animatedValue.value = withSequence(startValue, withTi
我一直在阅读重新激活 2 个 Hooks 的文档,并在整个互联网上搜索更好解释的博客或任何代码,但找不到任何一个,任何人都可以解释并给出源代码示例。作为示例 const App = () => {
谁能告诉我如何手动链接 react-native-reanimated 因为自动 cli 链接不起作用并且导致 React Native 应用程序崩溃 最佳答案 在 Android 中,将以下行添加到
我正在尝试构建一个 React Native 应用程序。我在终端上发现了一个错误说Unable to resolve "./useValue" from "node_modules\react-nat
这里是 React-native 新手。 我目前使用的是带 OS 11.6 的 MacBook Air M1 2020,在安装 react-native-reanimated 后我遇到了运行模拟器的问
这里是 React-native 新手。 我目前使用的是带 OS 11.6 的 MacBook Air M1 2020,在安装 react-native-reanimated 后我遇到了运行模拟器的问
我正在尝试做什么 我正在尝试创建一个动画间距/填充元素,该元素在显示或隐藏键盘时改变高度,以确保 TextInput 不会被键盘或使用 KeyboardAvoidingView { // Thes
在进行构建时,我遇到了这个问题 A problem occurred evaluating project ':react-native-reanimated'. > Task with path '
我有一个使用 reanimated-bottom-sheet 包创建的底部表,如下所示 } renderHeader={() => HEADER}
react 原生项目运行良好,没有反应导航选项卡模块,一旦我使用安装选项卡模块 npm install --save react-navigation-tab 节点终端出现以下错误。 React-ta
我目前正在学习使用 RN Reanimated 创建 React Native 动画。和 Redash图书馆。我设法创建了一个简单的计时动画,它将 TextInput 占位符转换为标签。 impo
我正在做一个关于 React Native 的项目,试图创建抽屉导航 我安装了抽屉导航、手势处理程序和重新激活的库 当我运行时出现错误第一个错误: ERROR 错误:无法初始化 react-nativ
伙计们 我正在尝试安装 react-native-reanimated,但我一直收到此错误。 C:\Users\danilojldeo\Desktop\MeuGithub\controle-de-pr
我用 Animated 创建了一个简单的动画来自 react-native与 react-native-svg . 这很好地完成了工作, 但现在我切换到 react-native-reanimated
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我是一名优秀的程序员,十分优秀!