In YUI I have following code working for mouse wheel. How do I make this work for a scrollbar?
Y.on('mousewheel', function(e) {
var dir = e.wheelDelta > 0 ? 'Up' : 'Down';
console.log(dir);
});
Thanks for any help...
How can I get the scrollbar position? To get or set the scroll position of an element, you follow these steps: First, select the element using the selecting methods such as querySelector() . Second, access the scroll position of the element via the scrollLeft and scrollTop properties.
The scrollTo() method scrolls the document to specified coordinates.
You can check if window. scrollY (the number of pixels the window has scrolled vertically) is equal to 0 . If you want to check if the window has been scrolled to its leftermost, you can check if window. scrollX (the number of pixels the window has scrolled horizontally) is equal to 0 .
To get the height of the scroll bar the offsetHeight of div is subtracted from the clientHeight of div. OffsetHeight = Height of an element + Scrollbar Height. ClientHeight = Height of an element. Height of scrollbar = offsetHeight – clientHeight.
it was a simple solution
Y.on('scroll', function(e) {
console.log(window.scrollY);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With