如何在 iPhone/Android 上捕获滚动开始事件

发布于 2024-12-11 18:51:00 字数 212 浏览 0 评论 0原文

我在移动网站上使用 JQuery,在没有位置:固定支持的情况下重新定位滚动上的标题导航。当用户停止滚动时,标题会放回页面顶部,效果很好。

为了增强用户的体验,我想在用户开始滚动时隐藏()标题,然后在停止时将其滑入。问题是滚动事件仅在用户停止滚动时触发。我读到有 iOS 特定的触摸事件,但是有什么方法可以使用共同的代码捕获 iOS 和 Android 上的滚动启动事件吗?

谢谢

I'm using JQuery with a mobile site to reposition the header nav on scroll in the absence of position:fixed support. That works fine, when the user stops scrolling the header is placed back at the top of the page.

To enhance the experience for the user I want to hide() the header when the user starts to scroll and then have it slide in when they stop. The problem is that the scroll event only fires when the user stops scrolling. I've read that there are iOS specific touch events but is there any way I can capture a scroll start event on iOS and Android using mutually common code?

Thanks

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

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

发布评论

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

评论(3

小霸王臭丫头 2024-12-18 18:51:00

我相信 jQuery Mobile 可以做到这一点。看一下下面的代码:

$(document).bind("scrollstop", function() {

//What occurs when the scrolling stops
alert("You have stopped scrolling");
});

$(document).bind("scrollstart", function() {

//What occurs when the scrolling starts
alert("You have started scrolling");

});

I believe jQuery Mobile, can do this. Take a look at the following code:

$(document).bind("scrollstop", function() {

//What occurs when the scrolling stops
alert("You have stopped scrolling");
});

$(document).bind("scrollstart", function() {

//What occurs when the scrolling starts
alert("You have started scrolling");

});
-黛色若梦 2024-12-18 18:51:00

您可以从 jQuery Touchwipe 开始:它是一个添加新事件wipeleft和wiperight的插件。

可以轻松修改它以将水平划像更改为垂直划像(将 x 更改为 y)
http://plugins.jquery.com/project/Touchwipe-iPhone-iPad -wipe-gesture

适用于 Android、IOS 和 BBOS。

You can start with jQuery Touchwipe : it's a plugin which add new events, wipeleft and wiperight.

It can be easily modified to change horizontal wipes to vertical ones (changing x's to y's)
http://plugins.jquery.com/project/Touchwipe-iPhone-iPad-wipe-gesture

It works on Android, IOS and BBOS.

瀞厅☆埖开 2024-12-18 18:51:00

此scrollstart 事件在android 2.3.4 的默认android 浏览器中是错误的 当用户开始滚动时,scrollstart 事件不会100% 触发。我正在尝试找出问题所在。我正在寻找在滚动启动事件之前触发的任何事件。这也可能是我的代码中某个地方的冲突事件。我需要先排除这一点。

This scrollstart event is faulty in the default android browser for android 2.3.4 The scrollstart event doesn't fire 100% of the time when the user starts a scroll. I am trying to track down problem. I am looking for any event that fires just before the scrollstart event. It could also be a conflicting event somewhere in my code. I need to rule that out first.

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