Home > Mobile >  JS or jQuery vertical carousel with mouse wheel event
JS or jQuery vertical carousel with mouse wheel event

Time:12-28

I'm trying to do some scrolling in JS. What i want is when i spin my mouse wheel my page should scroll down by one element. Elements are full screen, so basicaly i want vertical carousel.
My div elements have 100vh so when i resize window it should scroll by the height of the window.

document.addEventListener("wheel", function(event){
    if(event.deltaY<0)
    {
        window.scrollBy(0, -window.innerHeight);
    }
    if(event.deltaY>0)
    {
        window.scrollBy(0, window.innerHeight);
    }
});

I found this code on internet. When I scroll it flickers, it moves window as I want for a milisecond and gets it back where default scroll position is (20px or w/e the number is). Thanks in advance!

CodePudding user response:

It will be easier to prevent the scrollbar from popping up and show the content as a slide: Slick Carousel Vertical Mouse Whell Scrool

This is easiest method to solve this! Thanks

  • Related