Jump to content
Search Community

Parallax

pattocheu test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

  • Solution

Hi,

 

Indeed if the problem can't be replicated in codepen, then most likely is something else in your local setup.

 

A few pointers:

  • Be sure to optimize your images as much as possible so it's easier on the browser to render them.
  • Avoid long and slow animations, those normally are harder on the browser as well.
  • Since you're tweening the Y property (transform) try using will-change: transform on the elements you are animating:
    .parallax img {
      /*...*/
      will-change: transform;
    }

Performance is a deep topic and a 99% of the times it boils down to browser rendering rather than a GSAP issue.

 

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

Thank you for this information.

 

In connection with this post and in order to master performance, is there any benefit to destroying timelines and  clearProps once they are no longer in use and, for instance using onComplete()?

 

For exemple with my code

 

  animationsTitle() {
    this.elements.title.forEach(title => {
      this.splitTextToSpans(title);
      const tl = gsap.timeline({ 
        delay: this.delayIn,
        onComplete: () => {
          tl.kill();
          gsap.set(title.querySelectorAll('.word'), { clearProps: "all" });
        }});
      gsap.set(title.querySelectorAll('.word'), { yPercent: 103 });
      tl.to(title.querySelectorAll('.word'), {
        yPercent: 0,
        duration: 0.9,
        ease: 'power4.inOut',
        stagger: 0.05
      });
    })
  }

Thank you.

Link to comment
Share on other sites

1 hour ago, pattocheu said:

is there any benefit to destroying timelines and  clearProps once they are no longer in use

Definitely not. That'd actually hurt performance slightly (not that you'd ever notice). It's just wasteful - timelines already make themselves eligible for garbage collection once they complete anyway, and leaving CSS properties on an element doesn't "cost" anything. The only reason to clear props is if those inline properties are somehow interfering with something or keeping your element from displaying the way you wanted. 

  • Like 1
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...