我有一个可滚动的 div,其溢出被隐藏。我正在使用 this 插件来滚动 div。如何使用jquery(或者可能使用此插件)检测轴x位置,以便如果左侧没有任何内容可滚动,我将能够隐藏向左箭头,并在轴移动时再次显示它?
I have a scrollable div which overflow is hidden. I am using this plug-in to scroll the div. How can I detect the axis x position with jquery (or maybe with this plug-in) so if there is nothing to scroll on left, I would be able to hide the left arrow, and show it again when the axis has moved?
发布评论
评论(1)
查看
scrollLeft
属性。它可以像 jQuery 中的属性一样被访问。
jsFiddle。
要确定用户是否已一直滚动到左侧,请检查
(scrollLeft == 0)
。要查看它们是否一直滚动到右侧,您应该能够执行
(scrollLeft == element.attr('scrollWidth') - element.width())
。Look at the
scrollLeft
property.It can be accessed like an attribute in jQuery.
jsFiddle.
To determine if the user has scrolled all the way to the left, check for
(scrollLeft == 0)
.To see if they have scrolled all the way to the right, you should be able to do
(scrollLeft == element.attr('scrollWidth') - element.width())
.