[英]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.