Jump to content
Search Community

What is the best practice

harp30 test
Moderator Tag

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,

 

Had a general question when it comes to best practice.

 

example: say we have an animation we want to fade in - or any animation for that matter.

 

Options:

1. do we perform the settings via css file and then animate in JS with GSAP timeline(s)

2. Perform settings in JS via GSAP and then animate via timeline(s)

3. Don’t do any settings and just perform GSAP timeline with from method?

 

to save memory and have best performance, which is the best option?

 

thank you.

Link to comment
Share on other sites

It's really up to you. Most people prefer to set up the initial state of the page with CSS and then animate things in JS with GSAP. One caveat is that we'd strongly recommend setting transform-related values (scale, rotation, x, y, etc.) via GSAP in order to maximize performance (caching) and avoid ambiguous rotational data that occurs when the browser reports things in matrix() or matrix3d(). Even in that case, though, it's totally fine to set the initial values in CSS and then in the JS level set them again to inform GSAP of your intent. 

 

The good thing about setting initial state in CSS is that the browser can immediately render things in the proper state rather than waiting until some JS files load before executing the code there (which could cause an flash of unstyled content). 

 

Does that answer your question? 

  • Like 4
  • Thanks 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...