如何在 React Native 中从屏幕上的任何位置滚动 ScrollView?

发布于 2025-01-09 07:53:32 字数 69 浏览 5 评论 0原文

我用 React Native 构建了一个轮播。现在,即使我的手指没有放在里面,我也希望能够滚动它。我怎样才能实现这个目标?

I built a carousel in react native. Now I want to be able to scroll through it even when my finger is not placed inside it. How can I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋叶绚丽 2025-01-16 07:53:32

尝试获取坐标并检查方向是否发生变化。如果向左或向右,则触发滑动。

伪代码:

if (x.now > x.just now) { swipeRight()}
if (x.now < x.just) {swipeLeft()}

这可能有帮助:React本机获取我的触摸事件的坐标

Try to get the coordinates and check the direction if they change. if left or right, trigger swipe.

pseudocode:

if (x.now > x.just now) { swipeRight()}
if (x.now < x.just) {swipeLeft()}

may this helps: React native get the coordinates of my touch event

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文