glide
glide copied to clipboard
Allow horizontal scroll using mouse?
I would like to enable horizontal scrolling using the mouse; is that possible? Currently I can only go to next slide using buttons, or dragging, but I'd like to be able to scroll left or right using my mouse
If it is your scroll wheel, maybe you could trigger next/prev slide based on your own listener for mouse wheel.
There's no scroll event happening. Because in Glide.js there's no overflow. So that won't work
As close as I could get for now:
glideDiv.addEventListener("wheel", throttle((e) => {
e.stopPropagation();
if (e.deltaY < -3) {
// up
glide.go("<");
}
if (e.deltaY > 3) {
// down
glide.go(">");
}
return false;
}, 50), { passive: true });
function throttle(mainFunction, delay) {
let timerFlag = null; // Variable to keep track of the timer
// Returning a throttled version
return (...args) => {
if (timerFlag === null) { // If there is no timer currently running
mainFunction(...args); // Execute the main function
timerFlag = setTimeout(() => { // Set a timer to clear the timerFlag after the specified delay
timerFlag = null; // Clear the timerFlag to allow the main function to be executed again
}, delay);
}
};
}