简体   繁体   English

jQuery:当我单击滚动条时,滚动条会卡住,从而导致滚动条在鼠标未按下时滚动。 (以jsfiddle为例)

[英]jQuery: The scrollbar sticks when i click it, causing it to scroll when my mouse isn't down. (with jsfiddle example)

http://jsfiddle.net/nicktheandroid/7raYa/9/ 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. 我的脚本允许我像PDF一样滚动页面,从而可以抓取页面并向下或向上拖动。 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. 我的问题是,当我使用滚动条,然后使用滚动条上的mouseup时,即使我的鼠标是向上的,滚动条也将随着我的鼠标向上和向下滚动并滚动。 So when clicking on the scrollbar, its like i never moused up. 因此,当单击滚动条时,就像我从不鼠标一样。 how do I fix this? 我该如何解决?

THANKS! 谢谢!

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/ 编辑:我是对的-这是更新的jsFiddle,它可以正常工作: http//jsfiddle.net/xDtVL/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我有一个导航栏,当您向下滚动时,它会变得固定。 除非您向下滚动,否则它不起作用 - I have a navigation bar that becomes fixed when you scroll down. It doesn't work unless you're scrolled down 当在IE中单击滚动条内部小部件时,Gridster小部件会粘到鼠标上 - Gridster widget sticks to mouse when scrollbar inside widget is clicked in IE 单击按钮时使用JavaScript或JQuery向下滚动 - Scroll down with JavaScript or JQuery when click on button jQuery 的 jsfiddle 示例不适用于 jQuery 代码 - jsfiddle example of jQuery isn't applying on jQuery code 带滚动条的JQuery UI Draggable Div鼠标 - JQuery UI Draggable Div with scroll sticks to mouse 当用户向下滚动时更改 css 显示。 没有 jQuery - change css display when user scrolls down. Without jQuery 为什么当我将 div 向下移动到页面时滚动条会滚动 - why does the scrollbar scroll when I move the div down to the page 当您在jquery中滚动通过时会停留在顶部的div - div that sticks to the top when you scroll past it in jquery 为什么当我在页面顶部滚动并单击附加表格的链接时,它会向下滚动 - Why when i scroll top my page and click link which append a form it scroll me down 当我单击操作下拉菜单时,滚动条中显示的选项为何? - When i click on action drop down the options are displaying in scrollbar why?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM