SHARE
TWEET

Untitled

a guest Nov 13th, 2008 497 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (typeof String.trim == 'undefined') {
  2.   String.prototype.trim = function () {
  3.     return this.replace (/^\s+|\s+$/g, '');
  4.   };
  5. }
  6.  
  7. function Transition (e) {
  8.  
  9.   var prop = e.style.transitionProperty.split (',');
  10.   var dur  = e.style.transitionDuration.split (',');
  11.   this.e = e;
  12.  
  13.   // assert (true, (prop.length == dur.length));
  14.  
  15.   for (var i = 0; i < prop.length; i++)
  16.     this[prop[i].trim ()] = dur[i].trim ();
  17.  
  18.   return this;
  19.  
  20. }
  21.  
  22. Transition.prototype = {
  23.   getProperties: function () {
  24.     var names = [];
  25.     for (var p in this)
  26.       if (typeof this[p] == 'string')
  27.         names.push (p);
  28.     return names;
  29.   },
  30.   applyTransitions: function (o) {
  31.     var names = this.getProperties ();
  32.     e.style.transitionProperty = names.join (', ');
  33.     var dur = [];
  34.     for (var n in names)
  35.       dur.push (n);
  36.     e.style.transitionDuration = dur.join (', ');
  37.  
  38.     if (typeof o == 'object')
  39.       // ({width: '50px', height: '200px'})
  40.       for (var p in o)
  41.         e.style[p] = o[p];
  42.   }
  43. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top