📜  您可以使用 gsap 附加课程吗?无论代码示例

📅  最后修改于: 2022-03-11 14:57:34.650000             🧑  作者: Mango

代码示例1
Yes, as mentioned in the release notes, GSAP 3 doesn't support className tweens because they're just generally a bad idea in most cases:

From a performance perspective, they require looping through every single CSS property available to find which ones change between the start and end, and then isolating those for the tween. It's just a lot of work that could be avoided by simply being explicit with your animations about which properties you want to animate.
From a code perspective, being explicit about which properties you're animating helps to make your code more maintainable and aids in troubleshooting/readability. 
Dropping className support saves valuable kb in the engine. 
We may consider a separate ClassNamePlugin down the road if there's enough demand from users, but I think it's better in most cases to just nudge users toward writing cleaner animation code that doesn't rely on things being defined in CSS. If you have a certain use case that helps make the case for a ClassNamePlugin, definitely let us know.

 

If you just want to add a class at the end of an animation or something, that's easy to do in an onComplete callback. And of course you can use simple CSS transitions if you're looking for basic CSS state changes.