[英]Get axis-x position inside scrollable div
I have a scrollable div which overflow is hidden. 我有一个可滚动的div,其中的溢出被隐藏了。 I am using this plug-in to scroll the div.
我正在使用此插件滚动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?
如何使用jquery(或可能使用此插件)检测x轴的位置,因此如果没有什么可向左滚动,我将能够隐藏左箭头,并在轴移动时再次显示它?
Look at the scrollLeft
property. 看一下
scrollLeft
属性。
It can be accessed like an attribute in jQuery. 可以像jQuery中的属性一样进行访问。
var scrollLeft = $('element').attr('scrollLeft');
To determine if the user has scrolled all the way to the left, check for (scrollLeft == 0)
. 要确定用户是否一直向左滚动,请检查
(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())
. 要查看它们是否一直向右滚动,您应该可以
(scrollLeft == element.attr('scrollWidth') - element.width())
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.