I would like to implement this horizontal scroll script on my page : https://github.com/Corentinfardeau/horizontal-scroll
My js code looks like this :
var blocks = document.getElementsByClassName('block');
var container = document.getElementsByClassName('containerv2');
var hs = new HorizontalScroll.default({
blocks : blocks,
container: container,
isAnimated: true,
spring: 0.06
});
It works fine, but the problem is that the animation begins when I'm on the top of the page. How can I trigger it ONLY when I'm on a specific section of my page?
To be clear, let's say my page looks like this :
<div class="hero"> XXXXXXX (lot of texts, maybe 200vh)</div>
<div class="container"> some images </div>
<div class="othersection"> XXXXXX (lot of texts, maybe 200vh) </div>
Here is an example : https://codepen.io/MannayStudios/pen/QVPpRb
I'd like the script to trigger ONLY when I reach the container section of the page, and stop when I exit it.
Thanks a lot for your answers :)