Read more

Make jQuery.animate run smoother with almost no code changes

Henning Koch
January 09, 2015Software engineer at makandra GmbH

jQuery comes with .animate() Show archive.org snapshot that lets you transition some CSS selectors:

function floatIn($element) {
  $element.css({ 'opacity': 0, 'margin-top': 200px });
  $element.animate({ 'opacity': 1, 'margin-top': 0 }, { duration: 500 });
}
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

The animation is implemented using setInterval and Javascript. This works great, but it's not as smooth as a CSS transition Show archive.org snapshot .

Fortunately the animate API can be mapped almost 1:1 to CSS transitions. There are libraries like Transit Show archive.org snapshot that act as a drop-in replacement for animate, but animate using CSS transitions instead of Javascript. This gives you a much higher framerate.

If Transit has too many bells and whistles for your taste, and you'd like to roll your own animate replacement, you might want to take a look at this Show archive.org snapshot .

Posted by Henning Koch to makandra dev (2015-01-09 11:19)