Very cool. There is one thing that I didn't see here which was either a bug or a clever tuning of the numeric parameters: overdamping. When solving the equation:<p><pre><code> x''(t) = -2a * x'(t) - k * x(t)
</code></pre>
(spring force k, linear friction a), the solution is generally a sum of solutions x = C exp(w t) for some arbitrary constant C and w = w(a, k). Plugging this in produces:<p><pre><code> w^2 + 2 a w + k = 0
(w + a)^2 + k - a^2 = 0
w = -a ± sqrt(a^2 - k)
</code></pre>
For `k > a^2`, the system is "underdamped" and you see sinusoidal oscillations, and increasing `a` will make the system relax to equilibrium faster. But for `k < a^2`, the system is "overdamped" and increasing `a` will make the system relax <i>slower</i>. (If you find this hard to imagine, think about what happens as `a` tends to infinity: there is so much friction that the spring just barely <i>crawls</i> to its final destination. Comparisons involving molasses and other high-viscosity substances might be apt.<p>When turning the frequency all the way down, I couldn't find a point where the friction started to make the relaxation to equilibrium <i>slower</i> rather than <i>faster</i>.
If this library is too much muscle & you just need a serviceable animation library, check out Daniel Eden's animate.css: <a href="https://github.com/daneden/animate.css" rel="nofollow">https://github.com/daneden/animate.css</a><p>Demo: <a href="http://daneden.github.io/animate.css/" rel="nofollow">http://daneden.github.io/animate.css/</a><p>Of course there's always a the danger of "overdoing it" w/ ridiculous animations but if you can avoid that temptation it's a very handy tool.
Neat. Couldn't this be implemented as a generator of easing functions, allowing the animation code to be handled by another project?<p><a href="http://easings.net/" rel="nofollow">http://easings.net/</a>
Anybody feeling this kind of animations aren't bringing a lot to the table ? I was thrilled to watch lollipop material design (and even kitkat project butter), but it quickly faded (sic). Instant, simple interfaces are needed in many tasks where I don't enjoy or even have the luxury to waste time on distracting animations.
As a hacker on Hacker News I'd have to agree with the others that animations are a Very Bad Thing. They are distracting to me, an easily distracted person, who is currently avoiding work by reading Hacker News this afternoon.
Please don't show this to anyone at Apple... I don't want the buttons on my next iPod to do a little giggly dance every time I press them.<p>(BTW- This is great work, I just hope UI devs don't overdo it...)
It's a nice library but I'm failing to understand the "physics-based" part.<p>I'm not seeing anything "physics" in the traditional sense; just manipulating the matrix3d in a transform property of an element in real-time to provide difficult or impossible effects with CSS alone.
Amazing library! I question it being targeted towards UI elements. I guess I'm thinking about the "condescending UI" arguments. On phones at least we can mostly turn it down, at least for system-level animations.
Interesting that the npm is accessed with <i>npm install dynamics.js</i>. Looks like <i>npm install dynamics</i> is a different library. I wonder if we are running out of npm namespace.
For anyone wanting to do graphics in web pages I would recommend looking into the canvas tag. Example code:<p><pre><code> with (context) {
beginPath();
moveTo(100, 100);
lineTo(100, 300);
lineTo(300, 300);
closePath();
stroke();
}</code></pre>
For everyone who loves the infinite possibilities of client-site JavaScript, and who at the same time does not love the blink-taggy smell that this kind of library evokes, I present to you the world's first distributed, web-based operating system: see <a href="https://www.urdesk.net/desk" rel="nofollow">https://www.urdesk.net/desk</a><p>This has been under very active development for going on 3 years now, and it is just starting to get to the point where it can stop being called a prototype or experiment.