I'm using data-scroll-call to switch on/off .active class on the buttons in my navigation.
I am not a programmer and not very familiar with JS, but somehow I manage to make it work..
The problem is that for some reason data-scroll-call is triggered twice - first when the element enter the viewport and receive class .is-inview, and next time when the element leave the viewport (the class .is-inview is removed from the element) - the corresponding button gets again .active class.
I am assuming that the problem is in my "If - statements" but don't know how to configure it.
My scrolling container is grid based and I remove all margins and padding and use only grid-gap for spacing between sections.
The navigation has data-scroll-sticky, so it can be stick while the scroll container is scrolled.
Here is my code:
https://codepen.io/mmilde/pen/gOvNxwQ
If anyone is able to help me with this will be very much appreciated! I have to upload the project as soon as possible and this is the only issue left to be fixed.
I'm using data-scroll-call to switch on/off .active class on the buttons in my navigation.
I am not a programmer and not very familiar with JS, but somehow I manage to make it work..
The problem is that for some reason data-scroll-call is triggered twice - first when the element enter the viewport and receive class .is-inview, and next time when the element leave the viewport (the class .is-inview is removed from the element) - the corresponding button gets again .active class.
I am assuming that the problem is in my "If - statements" but don't know how to configure it.
My scrolling container is grid based and I remove all margins and padding and use only grid-gap for spacing between sections. The navigation has data-scroll-sticky, so it can be stick while the scroll container is scrolled. Here is my code: https://codepen.io/mmilde/pen/gOvNxwQ
If anyone is able to help me with this will be very much appreciated! I have to upload the project as soon as possible and this is the only issue left to be fixed.