AlexanderGS Posted January 27, 2023 Posted January 27, 2023 good evening! This may seem like a silly question, but I don't understand why the clip-path isn't animated smoothly See the Pen VwBdzZY by Alexxxsander (@Alexxxsander) on CodePen.
Solution Cassie Posted January 27, 2023 Solution Posted January 27, 2023 Hi there! Just some numbers that GSAP is struggling to tween between. If you make them all percentages it works fine. It's hard for GSAP to animate between 0 and 100% as they're different units. timeline.fromTo( ".home__text span", { y: 30, clipPath: "polygon(100% 100%, 0% 100%, 0% 100%, 100% 100%)" }, { y: 0, clipPath: "polygon(100% 100%, 0% 100%, 0% 0%, 100% 0%)", duration: 0.8, stagger: 0.2, } ); 2
hinderwhack Posted March 24, 2023 Posted March 24, 2023 My question may seem inane, but I've always wondered why the clip-path wasn't animated in a more fluid fashion. Changing them all to percentages solves the problem. As 0 and 100% are in different units, animating between them is challenging with GSAP. phrazle
GreenSock Posted March 24, 2023 Posted March 24, 2023 @hinderwhack yeah, that's because it's just animating a complex string which involves isolating the numbers in each string (the beginning and ending one), and then interpolating those. So the first number in the starting string gets matched with the first number in the ending string, and so on. Otherwise, it would take a LOT more custom code to try to parse and convert every possible unit at every position, thus the GSAP core would grow. Everyone would pay the kb price for a feature that almost nobody would use. In the vast majority of cases, it's quite simple to just format the start/end strings properly to get the result you want (match units). ?
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