Jump to content
Search Community

Continuous animation even after scrolling

Phenelo test
Moderator Tag

Go to solution Solved by Diaco,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello once again, GreenSock community!
 

I'm currently working on a project that uses the scroll to kick the animations running. One effect that I would like to apply is that even the user stops scrolling, there's still some movement on the screen. Below is my CodePen example.

 

My problem is I'm having some occasional performance issues and animation lapses. Like for example, one of the boxes sometimes duplicates itself in half and would scroll across the page vertically in a short period of time. So what I did was convert all left/top/etc properties into 3d space translation, but still I'm having those issues. How would I further improve this? I'm thinking that there is something wrong with me using the setInterval function. Also to clear things up, this line:
 

var prog = (1-0.05) * boxTween.progress() + 0.05 * pos; 

This line enables me to "lerp" the Timeline's progress over a period of time to the current scroll position. I got this from another CodePen (

See the Pen KGIEh by ma77os (@ma77os) on CodePen

) and I thought that I could use the solution he used. Am I doing something wrong? Any suggestions? Thanks in advance!
 

Hi-five,

Phenelo

See the Pen CBbDg by anon (@anon) on CodePen

Link to comment
Share on other sites

Hi Phenelo  :)

 

try this ; remove the setInterval function and use this method :

window.addEventListener("scroll", progress);
function progress(){
var prog = $(window).scrollTop() / 4333;
TweenMax.to(boxTween,0.7,{progress:prog});
	}

... :)

 

I don't actually knew that you can tween the progress value! That worked gold. Before, the 3d values still increments up to the last decimal even if the elements already stopped moving. Now, once the elements stopped moving, the values stops running on background. Also, some jitters were gone. Thanks! I'm open for more suggestions! XD

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...