I'm trying to change the source of a statically positioned image based upon the scroll position of a window.
Basically, I want to cycle through MRI scan images depending on where the viewport is relative to the page. I want to get through all 100+ images over the length of the page. This length will change, so I'm trying to work out how to make it proportional.
I confess that I am new to coding so it may be best to use pseudocode rather than trying to code:
window.image1position == ( 1 / [#images] ) * document.totalheight
window.image2position == ( 2 / [#images] ) * document.totalheight
...
if window.scrollposition == window.image1position
set image.src = image1.png
elseif window.scrollposition == window.image2position
set image.src = image2.png
...
Would anyone be able to help me with this idea? Any input would be very much appreciated.
Alan