尝试使用jQuery进行自定义滚动 [英] Trying to make a custom scroll using jQuery
问题描述
我一直在尝试使用jQuery和CSS制作自定义滚动,但我已经部分成功了。问题是我无法弄清楚当滚动条达到其滚动容器的极限时如何停止滚动条。我只需要找到不会让这种情况发生的代码部分。如果有人可以帮助编写脚本,那就太棒了。我已经完成了所有工作并且在
上运行 http://jsfiddle.net/ithril/va6DW/
I've been trying to make a custom scroll using jQuery and CSS and I've been partially successful. The problem is I can't figure out how to stop the scroll bar when it reaches the limit of its scroll-container. I just need to find the code section which is not letting this happen. It'd be great if someone could help with the script. I have the whole thing up and running on http://jsfiddle.net/ithril/va6DW/
推荐答案
这是一个快速修复:在移动滚动之前添加以下条件:
Here's a quick fix: add the folowing condition before moving the scroll:
if(x-35>left_limit && x-20<right_limit)
此处的完整代码: http://jsfiddle.net/dujaQ/
但我强烈建议您使用现有的jquery插件并根据需要进行调整。这里有一些带水平滚动支持的jquery滚动插件:
But i strongly suggest you to take an existing jquery plugin and adapt it to your need. Here some jquery scroll plugins with horizontal scroll support:
- mCustomScrollbar
- jScrollPane
这篇关于尝试使用jQuery进行自定义滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!