'use strict';

var initClasses   = ['mui-enter', 'mui-leave'];
var activeClasses = ['mui-enter-active', 'mui-leave-active'];

// Find the right "transitionend" event for this browser
var endEvent = (function() {
  var transitions = {
    'transition': 'transitionend',
    'WebkitTransition': 'webkitTransitionEnd',
    'MozTransition': 'transitionend',
    'OTransition': 'otransitionend'
  }
  var elem = window.document.createElement('div');

  for (var t in transitions) {
    if (typeof elem.style[t] !== 'undefined') {
      return transitions[t];
    }
  }
})();

function animate(isIn, element, animation, cb) {
  element = $(element).eq(0);

  if (!element.length) return;

  var initClass = isIn ? initClasses[0] : initClasses[1];
  var activeClass = isIn ? activeClasses[0] : activeClasses[1];

  // Set up the animation
  reset();
  element.addClass(animation);
  element.css('transition', 'none');
  requestAnimationFrame(function() {
    element.addClass(initClass);
    if (isIn) element.show();
  });

  // Start the animation
  requestAnimationFrame(function() {
    element[0].offsetWidth;
    element.css('transition', '');
    element.addClass(activeClass);
  });

  // Clean up the animation when it finishes
  element.one('transitionend', finish);

  // Hides the element (for out animations), resets the element, and runs a callback
  function finish() {
    if (!isIn) element.hide();
    reset();
    if (cb) cb.apply(element);
  }

  // Resets transitions and removes motion-specific classes
  function reset() {
    element[0].style.transitionDuration = 0;
    element.removeClass(initClass + ' ' + activeClass + ' ' + animation);
  }
}

var MotionUI = {
  animateIn: function(element, animation, cb) {
    animate(true, element, animation, cb);
  },

  animateOut: function(element, animation, cb) {
    animate(false, element, animation, cb);
  }
}

@@ -8,16 +8,990 @@
 rict';%0A%0A
+// Polyfill for requestAnimationFrame%0A(function() %7B%0A  if (!Date.now)%0A    Date.now = function() %7B return new Date().getTime(); %7D;%0A%0A  var vendors = %5B'webkit', 'moz'%5D;%0A  for (var i = 0; i %3C vendors.length && !window.requestAnimationFrame; ++i) %7B%0A      var vp = vendors%5Bi%5D;%0A      window.requestAnimationFrame = window%5Bvp+'RequestAnimationFrame'%5D;%0A      window.cancelAnimationFrame = (window%5Bvp+'CancelAnimationFrame'%5D%0A                                 %7C%7C window%5Bvp+'CancelRequestAnimationFrame'%5D);%0A  %7D%0A  if (/iP(ad%7Chone%7Cod).*OS 6/.test(window.navigator.userAgent)%0A    %7C%7C !window.requestAnimationFrame %7C%7C !window.cancelAnimationFrame) %7B%0A    var lastTime = 0;%0A    window.requestAnimationFrame = function(callback) %7B%0A        var now = Date.now();%0A        var nextTime = Math.max(lastTime + 16, now);%0A        return setTimeout(function() %7B callback(lastTime = nextTime); %7D,%0A                          nextTime - now);%0A    %7D;%0A    window.cancelAnimationFrame = clearTimeout;%0A  %7D%0A%7D)();%0A%0A
 var init
@@ -1526,24 +1526,40 @@
 %5D;%0A    %7D%0A  %7D
+%0A%0A  return null;
 %0A%7D)();%0A%0Afunc
@@ -1634,16 +1634,16 @@
 eq(0);%0A%0A
-
   if (!e
@@ -1666,16 +1666,114 @@
 eturn;%0A%0A
+  if (endEvent === null) %7B%0A    isIn ? element.show() : element.hide();%0A    cb();%0A    return;%0A  %7D%0A%0A
   var in

Add requestAnimationFrame polyfill and add IE9 compatibility