获取可滚动 div 内的 x 轴位置
我有一个可滚动的 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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())
.