|
|
|
|
|
by mattgperry
1291 days ago
|
|
This is a home-grown solution but the version in Framer is extensively tested (though still not perfect ofc). The version in Framer has stuff like infinitely deep scale correction and shared element transitions so because of the filesize overhead (~10kb) I would only use this for complex stuff that is otherwise prohibitively tough (shared element transitions, layout etc). However I do want to make the point that this approach should be more robust and simpler to maintain for even simple examples. If you imagine an iOS-style pill toggle. The "simplest" way to animate this would be to have `translateX(0)` when off and something like `translateX(100px)` when on. However, if there were no animations, this isn't how you'd write it. You'd probably do something like switch `flex-start` to `flex-end` on the parent. This is easier to change the design and also maintain between breakpoints. But it can't be animated. Except with these technique, where you'd simply write <motion.div layout /> And it would be. Much more maintainable. |
|