michaelvillar / dynamics.js

Javascript library to create physics-based animations
http://dynamicsjs.com
7.57k stars 414 forks source link

Allow to fake dom elemenst with js objects #15

Closed criloz closed 8 years ago

criloz commented 8 years ago

something like this

var fakeSvgObj = {
    d: "...",
    fill: "....",
    _objectType: "SVG"
}

dynamics.animate(fakeSvgObj, {
    d: "M0,0 L0,100 L100,50 L0,0 Z",
    fill: "#FF0000",
    rotateZ: 45,
    // rotateCX and rotateCY are the center of the rotation
    rotateCX: 100,
    rotateCY: 100
}, {
    friction: 800
})

then it will try the object like a svg. ( is this possible?)

why? it will integrate nicely with the vdom libraries out there, like reactjs and mercury, etc. and let the dom changes to these library instead of be done by dynamics.js itself.

because currently the library is supported in browsers where is possible create objects with with getter and setter functions, will be easy to communicate the changes to mercuryjs for example and fire the re-render functionality. without conflict with the library.

michaelvillar commented 8 years ago

This was mostly working (beside the rotate properties). But I just did a fix to make that work as well :)