jQuery:当我单击滚动条时,滚动条会粘住,导致当我的鼠标未按下时它会滚动。 (以jsfiddle为例)

发布于 2024-10-16 03:40:01 字数 270 浏览 5 评论 0原文

http://jsfiddle.net/nicktheandroid/7raYa/9/

我的脚本允许我滚动页面就像 PDF 一样,允许您抓取页面并向下或向上拖动。我的问题是,当我使用滚动条,然后从滚动条向上移动鼠标时,即使我的鼠标处于抬起状态,滚动条也会随着鼠标上下滚动。因此,当单击滚动条时,就像我从未松开鼠标一样。我该如何解决这个问题?

谢谢!

http://jsfiddle.net/nicktheandroid/7raYa/9/

My script allows me to scroll the page like a PDF, allowing you to grab the page and drag down or up. My problem, is that when i use the scrollbar, then mouseup from the scroll bar, the scrollbar will stick and scroll with my mouse up and down, even though my mouse is up. So when clicking on the scrollbar, its like i never moused up. how do I fix this?

THANKS!

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

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

发布评论

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

评论(1

老旧海报 2024-10-23 03:40:01

我相信滚动条是页面的一部分,所以当您单击它时,它会让您的脚本相信鼠标已按下 - 您会注意到,在单击滚动条后,页面会继续上下移动,直到您按下鼠标。点击。尝试在鼠标按下时获取鼠标的坐标,并确保单击发生在页面内部(减去滚动条)

编辑:我是正确的 - 这是更新后的 jsFiddle ,它可以工作: http://jsfiddle.net/xDtVL/

I believe the scrollbar is part of the page, so when you click it, it makes your script believe the mouse is down - you'll notice that after you mouseup from clicking on the scrollbar that the page continues to move up and down until you click. Try to grab the coordinates of the mouse on mouse down, and make sure that the click occurred inside of the page (minus the scrollbar)

Edit: I was correct - here is the updated jsFiddle with it working: http://jsfiddle.net/xDtVL/

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