如何制作一个像iPhone一样的浮动滚动条?

发布于 2024-08-19 14:02:55 字数 105 浏览 4 评论 0原文

我正在创建一个手指友好的网络应用程序,但滚动条出现问题。理想情况下,我尝试重新创建 iPhone 的实现,其中滚动条仅在用户滚动内容时出现,并在滚动停止时消失。

有人有任何指点吗?

I'm creating a finger friendly web app and am having issues with the scrollbar. Ideally I'm trying to recreate the iPhone's implementation where the scrollbar only appears when the user scrolls the content and disappears when the scrolling stops.

Anyone got any pointers?

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

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

发布评论

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

评论(1

挽手叙旧 2024-08-26 14:02:55

首先,我将从一些选项开始。 Azoff 有一个可滚动插件来帮助您入门

最重要的是,从插件中删除它:

.css({"cursor":"url("+o.icons.open+"), default", "overflow-y": "auto"})

替换为:

.css({"cursor":"url("+o.icons.open+"), default"})

在您的代码中,以插件页面为例:

$(function() {
  $("#overscroll").overscroll();
  $("#overscroll").hover(
    function() { $(this).css({'overflow-y':'scroll'}); },
    function() { $(this).css({'overflow-y':'hidden'}); }
  );
});

这显示悬停时的滚动。您也可以设置 $("#overscroll").scroll() 事件来隐藏/显示,只需注意隐藏或显示将导致滚动本身,从而导致无限事件循环。您需要对回调进行一些检查,以确保它不是导致滚动事件的滚动条隐藏(它是在拖动时......所以鼠标向上并滚轮检查?)。

First, I'd start with some of the options out there. Azoff has a scrollable plugin to get you started.

On top of that, remove this from the plug-in:

.css({"cursor":"url("+o.icons.open+"), default", "overflow-y": "auto"})

Replace with:

.css({"cursor":"url("+o.icons.open+"), default"})

In your code, using the plugin page as an example:

$(function() {
  $("#overscroll").overscroll();
  $("#overscroll").hover(
    function() { $(this).css({'overflow-y':'scroll'}); },
    function() { $(this).css({'overflow-y':'hidden'}); }
  );
});

This shows the scroll on hover. You could rig up the $("#overscroll").scroll() event to hide/show as well, just be ware that hiding or showing will cause a scroll itself, causing an infinite event loop. You'd need to set some checks on the callback to make sure it isn't a scrollbar hide that's causing the scroll event (It's on drag...so mouse up and scroll wheel check?).

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