r/CodingHelp • • 8d ago

[How to] How can I achieve this scrolling effect in react?

I want to achieve an effect like this - https://genshin.hoyoverse.com/en/

Basically, I have multiple sections in my site, and I want to make sure a user scrolls exactly where I want them to. Right now, I use this -

.snapContainer {
    height: 100vh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    overflow-x: hidden;
}


.section {
    height: 100vh;
    width: 100vw;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    align-items: center;
    justify-content: center;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}.snapContainer {
    height: 100vh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    overflow-x: hidden;
}


.section {
    height: 100vh;
    width: 100vw;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    align-items: center;
    justify-content: center;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

This works, but I want to know how they did it (The proper, non-buggy way). Thanks!

1 Upvotes

3 comments sorted by

1

u/AutoModerator 8d ago
Moderator Announcement Read More »

1

u/toi80QC 8d ago

They just used https://swiperjs.com/..

1

u/piano-guitarhero 8d ago

Got it. Thanks for the help :)