motiondivision / motionone

https://motion.dev
MIT License
2.84k stars 52 forks source link

[Feature] POJO support #235

Closed braebo closed 9 months ago

braebo commented 10 months ago

Is your feature request related to a problem? Please describe. This library has everything I need from an animation library besides one thing -- the ability to animate any object as opposed to only DOM elements. Being able to throw a random class instance or threejs Object3D at a sequence would be huge.

Describe the solution you'd like Objects just work, à la GSAP

ShanonJackson commented 10 months ago
let obj = {progress: 0}
animate((progress) => obj.progress = progress, { duration: 0.5 });
braebo commented 10 months ago

@ShanonJackson Thanks, I heard about using functions in a thread somewhere but couldn't find that in the docs.

That API isn't quite as nice and, I'd imagine, wouldn't scale nicely either with very large, complex systems. Nonetheless, it's much better than nothing.

I'm curious about your example though -- did you mean to destructure progress in the callback? i.e.:

let obj = {progress: 0}
animate(({ progress }) => obj.progress = progress, { duration: 0.5 });

If so, that makes sense. If not, I've got a few more questions 😅

mattgperry commented 9 months ago

Labelling this as a won't fix as it's more likely that this library will remove polyfills and concentrate on pure browser APIs while Framer Motion picks up things like object support.