Animation Based On Scroll Position
So, I'm trying to animate elements (sequentially and independently) based on their scroll position. The goal is to loop through each element, and change it's rotation based on the
Solution 1:
I think this is the fix you're looking for:
I added this right above your assignment of the rotation var:
// Transform the item based on scroll
rotationFactor = Math.max(0, scrollTop - elementTop),
rotation = ( rotationFactor / (documentHeight - windowHeight) * 360),
After replacing this they each get their relative offset rotation :)
The error is that the only changing/affecting variable to the rotation was your scrollTop, while that is only on a document-level. To effect on an element-level we also want to include that difference :)
Post a Comment for "Animation Based On Scroll Position"