onScroll
The onScroll function attaches a scroll event listener to elements matching the specified selector. When the scroll event is triggered and meets the required conditions, the provided callback function
Last updated
The onScroll function attaches a scroll event listener to elements matching the specified selector. When the scroll event is triggered and meets the required conditions, the provided callback function
Last updated
$('.container').onScroll(40, function (s, n, e) {
if (s) {
console.log(`Scrolled ${n} pixels.`);
} else {
console.log('Scroll threshold not met.');
}
// Access the event object
console.log('Scroll event:', e);
});
$('.container').onScroll(40, function (s, n, e) {
if (s) {
console.log(`Scrolled ${n} pixels.`);
} else {
console.log('Scroll threshold not met.');
}
// Access the event object
console.log('Scroll event:', e);
}, function () {
// Additional condition: Only execute if the window width is greater than 768px
return $(window).width() > 768;
});
$('.container').onScroll(40,(s)=>{
s?$('#side_btn').hide():$('#side_btn').show();
});