trusty97 Posted May 5, 2022 Share Posted May 5, 2022 It appears as though the ease property does not accept a function returning a default ease string (such as 'power4.out' ) as a value. I know there is language around it accepting a "function that accepts a progress value between 0 and 1 and returns a converted, similarly normalized value" but it'd be great if I could use a function to return a preset easing value based on some condition in the browser (such as resizing the window). Condition: gsap.to(el, { ... ease: () => (condition ? 'power4.out' : 'none', ... } Expected: Preset easing value set based on ternary function. Result: GSAP tween breaks and no longer works. I've included a codepen that demonstrates this not working. Is there any way to do this? Any thoughts here are greatly appreciated! See the Pen GRQpRKW by pdnellius (@pdnellius) on CodePen Link to comment Share on other sites More sharing options...
Solution PointC Posted May 5, 2022 Solution Share Posted May 5, 2022 Please give this a try. ease: condition ? "power4" : "none" See the Pen ea42ab4e6e542401ef5a8bab653c5b32 by PointC (@PointC) on CodePen If you need it for your project, there's also a parseEase() method. https://greensock.com/docs/v3/GSAP/gsap.parseEase() Hopefully that helps. Happy tweening. 4 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now