View difference between Paste ID: ff045a79 and
SHOW: | | - or go back to the newest paste.
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
    this.e.style.transitionProperty = names.join (', ');
33
    var dur = [];
34
35
    for (var n in names) 
36
      dur.push (this[names[n]]);
37
38
    this.e.style.transitionDuration = dur.join (', ');
39
40
    if (typeof o == 'object')
41
      // ({width: '50px', height: '200px'})
42
      for (var p in o)
43
        this.e.style[p] = o[p];
44
  }
45
};
46