Get horizontal scroll event in js

拜拜、爱过 提交于 2019-12-03 05:51:42

You can handle horizontal scrolling by :

$("#someContainer").on("scroll", function (e) {
            horizontal = e.currentTarget.scrollLeft;
            vertical = e.currentTarget.scrollTop;
            });

In this case this bind all kind of scroll events on this element so you can also handle

Vertical by e.currentTarget.scrollTop

and

Horizontal by e.currentTarget.scrollLeft

I don't have the proper setup to test this, but $.scroll() should do the trick. It's probably preferable to binding the mousewheel event as well. People use all means of scrolling ;)

e.currentTarget.scrollX instead of e.currentTarget.scrollLeft and e.currentTarget.scrollY instead of e.currentTarget.scrollTop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!