Detect Scrollbar hide #556
Unanswered
MyNameTony1000
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hi, Can you try this code? var scrollbars = []
[...document.querySelectorAll('[data-scrollbar-select="true"]')].forEach((el) => {
var scrollbarInstance = window.Scrollbar.init(el, {
renderByPixels: true,
alwaysShowTracks: true,
});
scrollbars.push(scrollbarInstance)
});
scrollbars.forEach((scrollbarItem, _index) => {
let v = scrollbarItem.containerEl.querySelectorAll('ul li');
console.log(scrollbarItem);
console.log(scrollbarItem.limit);
console.log(scrollbarItem.isVisible(v[v.length - 1]));
scrollbarItem.addListener((status) => {
if (status.offset.y === status.limit.y) {
scrollbarItem.containerEl.classList.add('scroll-end');
} else {
scrollbarItem.containerEl.classList.remove('scroll-end');
}
});
}); |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, tell me, is it possible to track when an element no longer scrolls? For example, when there is only 1 element in a block and the scrollbar disappears because scrolling is not needed, how can you track this particular state during initialization?
Initialization occurs like this:
console.log outputs the following
Beta Was this translation helpful? Give feedback.
All reactions