EDIT: Thanks for the comments so far! Here's a JS fiddle with (hopefully all of) the relevant code:
https://jsfiddle.net/3y1cw6nt/
I have an image slider set up where the images' classes are toggled between .above
, .active
and .below
, and their top:
attribute changes accordingly.
At the moment the toggle is activated by an event listener for up and down arrow key presses, and I have html, body { height: 100vh, overflow: hidden }
so that the user can't scroll to the the images which are .below
or .above
.
Is there a way to still capture scroll up and down events and trigger the class changes using Javascript?
I've tried this solution, but it isn't working - var st
is undefined no matter what I do to the page, which I guess is because no scroll event is being captured and therefore var st
is never declared.
Thanks a lot!