Jump to content
Search Community

Rotation back to zero when reaching top

dna75 test
Moderator Tag

Go to solution Solved by PointC,

Recommended Posts

I have a logo which rotates 360 degrees after loading the page.

When the users scroll down, the logo also rotates.

When I scroll down before the initial 360 rotation has finished and go back up I notice that the logo is skewed because the 'scroll-rotation' has already begun. Is it possible to rotate the logo back to zero when reaching the top?

See the Pen mdpwWPR by dna75 (@dna75) on CodePen

Link to comment
Share on other sites

  • Solution

Hi @dna75

 

Welcome to the forum.

 

You're creating a bit of a conflict there with two tweens fighting for control of the same property. If it were me, I think I'd simply wrap the image in a div and rotate the image on load and the div on scroll. Maybe something like this.

 

See the Pen 4d2fa7059db58c1500e9274f95256518 by PointC (@PointC) on CodePen

 

Just FYI - there is no #wrap so nothing will pin and you have some large delays in there (1000 & 5000?) I'm not sure what those are supposed to be doing. Hopefully that approach helps.

 

Happy tweening and welcome aboard.

:)

 

  • Like 3
Link to comment
Share on other sites

First of all thanks for the warm welcome! 
As you might have noticed this was my first GSAP project (47 years old and just discovered GSAP... something with better late then never...)

Your solution works fine! Thanks. 
I think I found a alternative method. I don't want to finish the initial rotation if the user scrolls down before it has finished!
Thanks for helping pointing in the right direction.

I will also check the mega delays.

 

See the Pen YzYxrqx by dna75 (@dna75) on CodePen

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...