将scrollByX和scrollByY分配给jScrollPane中的jspDrag?
我正在为一个涉及水平滚动的项目实现 jScrollPane。客户端希望水平滚动以增量方式进行,以便用户基本上可以从一张幻灯片跳到另一张幻灯片。
我可以使用 jScrollPane 的 API 和“scrollByX”在箭头上执行此操作。然而,问题在于用户可以单击滚动条并前后拖动并以这种方式滚动内容。
有没有办法将“scrollByX”(或“scrollByY”,就此而言)分配给jspDrag,以便当用户拖动滚动条时,滚动不是连续的,而是增量的?
提前致谢。
I am implementing jScrollPane for a project that involves horizontal scrolling. The client wants the horizontal scrolling to take place in increments, so that the user can basically jump from slide to slide.
I can do this on the arrows using jScrollPane's API and "scrollByX". However, the problem lies with the scrollbar that the user can click on and drag back and forth and scroll the content that way.
Is there any way to assign "scrollByX" (or "scrollByY", for that matter) to jspDrag so that when the user drags the scrollbar, the scrolling isn't continuous, but in increments as well?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在任何 jsp-scroll-x 事件之后监听 mouseup 事件,这样您就可以找出最近的项目在哪里,并使用 jScrollPane API 滚动到该元素的位置。我已经更新了您找到的示例,以便它以这种方式工作(正如您注意到的那样,它以前只向前滚动):
http://www.jsfiddle.net/dzvSC/14/
(显然这段代码是垂直工作的,但你可以将 y 更改为 x 以及将顶部更改为左侧等)
原始答案:
可以做你想做的事,我在某处写了一个例子 您可以在 jScrollPane 邮件列表 上找到它 - 在示例中它是垂直滚动窗格,当您释放滚动条时,它会动画到最近的图像。实际示例位于 jsfiddle.net 上。
我现在很着急,找不到这个例子,但这可能对你有帮助。如果当我下次在电脑前时你还没有找到它,我会尝试找到它并更新这个答案......
You can listen to the mouseup event after any jsp-scroll-x event and in that you can figure out where the nearest item is and use the jScrollPane API to scroll to the position of that element. I've updated the example you found so that it works in this manner (as you noticed it previously only scrolled forwards):
http://www.jsfiddle.net/dzvSC/14/
(obviously this code is working vertically but you can change the y's to x's and the top's to left's etc)
Original answer:
It is possible to do what you want and I wrote an example somewhere. You may be able to track it down on the jScrollPane mailing list - in the example it was a vertical scrollpane and it animated to the nearest image when you released the scrollbar. The actual example was on jsfiddle.net.
I'm in a rush now and can't find the example but that may help you to. If you haven't found it when I'm next in front of the computer I'll try to track it down and update this answer...