Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The New Hotness - CSS3/JS Based Animation

bahoo
August 15, 2012

The New Hotness - CSS3/JS Based Animation

Detailed breakdown of lessons learned while building the CSS3 & animation magic for simplymeasured.com

Seattle Interactive Developer Meetup, Aug 15 2012

Jon Culver / @bahoo
Simply Measured / http://simplymeasured.com

bahoo

August 15, 2012
Tweet

Other Decks in Programming

Transcript

  1. Workaround: staging class ˒ /* global.js */ $(function(){ $slides =

    $('.slides li'); // stage some animation goodness. if(Modernizr.csstransitions){ $slides.addClass('staging'); } // .. }); ˒ /* style.css (prefixed rules omitted) */ .slides .staging{ visibility: hidden; transform: translate(-800px,0); } .slides .staging img{ opacity: 0; } .slides li.animate-in{ visibility: visible; transition: 0.7s transform ease-out; } .slides .animate-in img{ opacity: 1; transition: inherit; transition-property: opacity; } ★ Swap
  2. getComputedStyle polyfill (aka “We’ll Do It Live!”) ˒ /* Particularly

    for our good friend IE8 */ if (!window.getComputedStyle) { window.getComputedStyle = function(el, pseudo){ this.el = el; this.getPropertyValue = function(prop) { var re = /(\-([a-z]){1})/g; if (prop == 'float') prop = 'styleFloat'; if (re.test(prop)) { prop = prop.replace(re, function () { return arguments[2].toUpperCase(); }); } return el.currentStyle[prop] ? el.currentStyle[prop] : null; }; return this; }; } ★ Ship
  3. For Safari < 6 / older WebKit ˒ .brands-drawer.staging img{

    visibility: visible; transform: translate(0,200px); } .brands-drawer img.animate-in{ transform: translate(0,0); transition: 0.6s transform cubic-bezier(0,1.33,0.66,1); } /* Oh, Safari, get on board. Y2 clamped to 1.0*/ .brands-drawer img.animate-in.clamped{ transition: 0.6s transform cubic-bezier(0,1,0.66,1); } Then JS side... $(el).addClass('animate-in'); if($.browser.webkit && parseInt($.browser.version) < 535){ $(el).addClass('clamped'); } ★ ‘535’