Jump to content
GreenSock

Alexis_G

Is easing functions accessible for other operations than DOM manipulation?

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

Hi everyone,

 

I was about to implement something like this in my current project, but I guess the GSAP codebase already have it, is it accessible for something else than DOM manipulation?

Best.

See the Pen XWrjJVN by yyy589 (@yyy589) on CodePen

Link to comment
Share on other sites

45 minutes ago, Alexis_G said:

is it accessible for something else than DOM manipulation?

 

At its core, GSAP doesn't do DOM manipulation. That's what the CSSPlugin does, so yes, you can use the easing functions for whatever you want. Every ease has a .getRatio() method, where you pass in a normalized value from 0 to 1.

 

var ratio = Power1.easeIn.getRatio(0.5);

 

Check out this post where I use different easings to plot points for sine waves.

 

 

If you need help normalizing a value, here's a little helper function. Just pass in the current, min, and max values.

 

// normalize will return a value between 0 and 1
function normalize(value, min, max) {
  return (value - min) / (max - min);
}

 

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