TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Dynamics.js, a JavaScript library to create physics-based animations

286 pointsby michaelvillaralmost 10 years ago

15 comments

drostiealmost 10 years ago
Very cool. There is one thing that I didn&#x27;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&#x27;&#x27;(t) = -2a * x&#x27;(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 &gt; a^2`, the system is &quot;underdamped&quot; and you see sinusoidal oscillations, and increasing `a` will make the system relax to equilibrium faster. But for `k &lt; a^2`, the system is &quot;overdamped&quot; 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&#x27;t find a point where the friction started to make the relaxation to equilibrium <i>slower</i> rather than <i>faster</i>.
评论 #9721259 未加载
valgazealmost 10 years ago
If this library is too much muscle &amp; you just need a serviceable animation library, check out Daniel Eden&#x27;s animate.css: <a href="https:&#x2F;&#x2F;github.com&#x2F;daneden&#x2F;animate.css" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;daneden&#x2F;animate.css</a><p>Demo: <a href="http:&#x2F;&#x2F;daneden.github.io&#x2F;animate.css&#x2F;" rel="nofollow">http:&#x2F;&#x2F;daneden.github.io&#x2F;animate.css&#x2F;</a><p>Of course there&#x27;s always a the danger of &quot;overdoing it&quot; w&#x2F; ridiculous animations but if you can avoid that temptation it&#x27;s a very handy tool.
评论 #9722117 未加载
pimlottcalmost 10 years ago
Neat. Couldn&#x27;t this be implemented as a generator of easing functions, allowing the animation code to be handled by another project?<p><a href="http:&#x2F;&#x2F;easings.net&#x2F;" rel="nofollow">http:&#x2F;&#x2F;easings.net&#x2F;</a>
评论 #9724128 未加载
agumonkeyalmost 10 years ago
Anybody feeling this kind of animations aren&#x27;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&#x27;t enjoy or even have the luxury to waste time on distracting animations.
评论 #9721155 未加载
评论 #9721657 未加载
评论 #9721230 未加载
评论 #9721026 未加载
评论 #9721025 未加载
zechoalmost 10 years ago
As a hacker on Hacker News I&#x27;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.
评论 #9721113 未加载
评论 #9721064 未加载
drcodealmost 10 years ago
Please don&#x27;t show this to anyone at Apple... I don&#x27;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&#x27;t overdo it...)
评论 #9721269 未加载
talmandalmost 10 years ago
It&#x27;s a nice library but I&#x27;m failing to understand the &quot;physics-based&quot; part.<p>I&#x27;m not seeing anything &quot;physics&quot; 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.
评论 #9721229 未加载
评论 #9721203 未加载
th0ma5almost 10 years ago
Amazing library! I question it being targeted towards UI elements. I guess I&#x27;m thinking about the &quot;condescending UI&quot; arguments. On phones at least we can mostly turn it down, at least for system-level animations.
评论 #9721223 未加载
lackeralmost 10 years ago
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.
评论 #9723264 未加载
iraldiralmost 10 years ago
Yeah, I don&#x27;t really see the point compared to GreenSock&#x27;s GSAP which is really performant and has some cool plugins.
html5webalmost 10 years ago
Awesome, thanks for creating this!
z3t4almost 10 years ago
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>
评论 #9722749 未加载
tomphooleryalmost 10 years ago
OK so how do I make this control an LFO in my music? ;)
评论 #9728225 未加载
johnalxndralmost 10 years ago
excited to play with this, cheeers
denniskanealmost 10 years ago
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&#x27;s first distributed, web-based operating system: see <a href="https:&#x2F;&#x2F;www.urdesk.net&#x2F;desk" rel="nofollow">https:&#x2F;&#x2F;www.urdesk.net&#x2F;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.
评论 #9721779 未加载
评论 #9721632 未加载
评论 #9721781 未加载
评论 #9722370 未加载