我正在将此库用于滚动https://kingsora.github.io。您如何知道该元素已完全滚动?我只能nyyati滚动= 0的初始点,但是您怎么知道该元素滚动到末尾?
var instance = $("#road-scroll")
.overlayScrollbars({
callbacks: {
onScrollStop: function(e) {
scrollLeft = e.target.scrollLeft;
if (scrollLeft === 0) {
btnL.removeClass("btn-active");
}
if (scrollLeft > 0) {
btnL.addClass("btn-active");
}
}
}
})
.overlayScrollbars();
最佳答案
回答:
var instance = $("#road-scroll")
.overlayScrollbars({
callbacks: {
onScrollStop: function(e) {
scrollLeft = e.target.scrollLeft;
var scrollInfo = instance.scroll();
let max = scrollInfo.x.max;
if (scrollLeft === 0) {
btnL.removeClass("btn-active");
}
if (scrollLeft > 0) {
btnL.addClass("btn-active");
}
if (scrollLeft >= max) {
btnR.removeClass("btn-active");
}
if (scrollLeft < max) {
btnR.addClass("btn-active");
}
}
}
})
.overlayScrollbars();
关于javascript - 滚动时查找滚动位置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51495940/