Animating clip path with gsap?
Anyone know why animating this clip-path isn't working? It's just jumping from the initial to end state, and I'm not sure why :/
https://codepen.io/nwoodward/pen/bNbWJKK?editors=1010
13 Replies
i think the number of commands in the path makes a difference
you have 19 commands and values, but the one in gsap has 20
use the 2nd path, change rx and ry to 0 and you have a square
M 0 0 H 80 A 0 0 0 0 1 80 80 H 0 A 0 0 0 0 1 0 0 Z
try this path as the initial path
by the way, you might be able to remove the first command, as svg files start at 0,0 already
moving to 0,0 doesn't do anythingYep it has to have the same number of points
does it? i swear they're the same š
i counted 19, and 20 on the 2nd
20 on this one yeah?
gsap.to(".hero", {
clipPath:
path("M20 10 H80 A20 20 0 0 1 80 90 H20 A20 20 0 0 1 20 10 Z")
,š¤
now you made me doubt myself
i was hoping you were right / i couldn't count
š
(there's still a chance)
yeah, you're right, i was wrong
i miscounted the 2nd path
and you already have the same commands too, with different arguments
I just cannot get my head around it š
i am all out of ideas too
thanks for trying anyway š
i think it is because you're not animating the same clippath value type.
in CSS it is a
url
(pointing to a svg ) and you're animating it with GSAP to an actual path
. So a smooth transition is not possible. it will jump from url to path
I can not test it myself right now, but try and see if it works when you put the actuall clippath in the css instead of using the urlthat makes sense