I have made a slider, I’m trying to make a scroll-to-slide function with pure JS, But I am not sure how to set a delay function scroll in each slide(set a delay time each time the user scrolls). I don’t know how to set the delay function in the javascript wheel
event, I’m not looking with js scroll
function, have any possibility with wheel
event?
let sTop = document.querySelector(".maze");
sTop.addEventListener('wheel', (e) => {
e.stopPropagation()
let delta = e.deltaY
if(delta == -100){
leftSl();
} else if(delta == 100) {
nextSl();
}
});
3
Answers
The following Example may help you.
Just update your configuration
https://www.geeksforgeeks.org/how-to-configure-mouse-wheel-speed-across-browsers-using-javascript/
In this case I think you should have two different function for right and left slide.
So you can make some changes in your code and work around.
I have prepared two answers for you:
To achieve a delay function in your scroll-to-slide functionality, you can use a combination of ‘setTimeout‘ and a variable to track whether the scroll event has been
I feel that the code should be modified as follows
I will write you a more complete model
Below is a simple example of HTML and CSS code for a slider with left and next navigation buttons, and scroll functionality using pure JavaScript:
HTML :
JS :
I hope I have helped.