Permalink
Browse files

Wait for document ready before inserting elements

  • Loading branch information...
koenbok committed Dec 31, 2012
1 parent 1677a43 commit bb1d239614b1878640f1036b2b011412d880140f
Showing with 22 additions and 15 deletions.
  1. +10 −7 build/framer.js
  2. +2 −1 src/views/view.coffee
  3. +10 −7 template/framer.js
@@ -969,7 +969,10 @@ require.define("/views/view.coffee",function(require,module,exports,__dirname,__
};
View.prototype._insertElement = function() {
return document.body.appendChild(this._element);
var _this = this;
return document.addEventListener("DOMContentLoaded", function() {
return document.body.appendChild(_this._element);
});
};
View.prototype.addListener = function(event, listener) {
@@ -1516,7 +1519,7 @@ require.define("/animation.coffee",function(require,module,exports,__dirname,__f
require("./utils");
PROPERTIES = ["view", "curve", "time", "origin"];
PROPERTIES = ["view", "curve", "time", "origin", "tolerance"];
parseCurve = function(a) {
a = a.replace("spring", "");
@@ -1565,7 +1568,6 @@ require.define("/animation.coffee",function(require,module,exports,__dirname,__f
Animation.prototype.stop = function() {
this._stop = true;
this._end();
return this.view.style.webkitTransform = this.view.computedStyle.webkitTransform;
};
@@ -1592,7 +1594,8 @@ require.define("/animation.coffee",function(require,module,exports,__dirname,__f
tension: values[0],
friction: values[1],
velocity: values[2],
speed: 1 / 60
speed: 1 / 60,
tolerance: this.tolerance || 0.01
};
this._startSpring(options, callback);
return;
@@ -1620,13 +1623,13 @@ require.define("/animation.coffee",function(require,module,exports,__dirname,__f
return _this._end(callback);
}
value = _this.spring.next();
if (_this.modifiers[k]) {
value = _this.modifiers[k](value);
}
nextState = {};
for (k in beginState) {
v = beginState[k];
nextState[k] = (deltas[k] * value) + beginState[k];
if (_this.modifiers[k]) {
nextState[k] = _this.modifiers[k](nextState[k]);
}
}
return _this._animate(nextState, "linear", _this.spring.speed, run);
};
@@ -277,7 +277,8 @@ class View extends Frame
@emit "change:class"
_insertElement: ->
document.body.appendChild @_element
document.addEventListener "DOMContentLoaded", =>
document.body.appendChild @_element
# Dom element events
@@ -969,7 +969,10 @@ require.define("/views/view.coffee",function(require,module,exports,__dirname,__
};
View.prototype._insertElement = function() {
return document.body.appendChild(this._element);
var _this = this;
return document.addEventListener("DOMContentLoaded", function() {
return document.body.appendChild(_this._element);
});
};
View.prototype.addListener = function(event, listener) {
@@ -1516,7 +1519,7 @@ require.define("/animation.coffee",function(require,module,exports,__dirname,__f
require("./utils");
PROPERTIES = ["view", "curve", "time", "origin"];
PROPERTIES = ["view", "curve", "time", "origin", "tolerance"];
parseCurve = function(a) {
a = a.replace("spring", "");
@@ -1565,7 +1568,6 @@ require.define("/animation.coffee",function(require,module,exports,__dirname,__f
Animation.prototype.stop = function() {
this._stop = true;
this._end();
return this.view.style.webkitTransform = this.view.computedStyle.webkitTransform;
};
@@ -1592,7 +1594,8 @@ require.define("/animation.coffee",function(require,module,exports,__dirname,__f
tension: values[0],
friction: values[1],
velocity: values[2],
speed: 1 / 60
speed: 1 / 60,
tolerance: this.tolerance || 0.01
};
this._startSpring(options, callback);
return;
@@ -1620,13 +1623,13 @@ require.define("/animation.coffee",function(require,module,exports,__dirname,__f
return _this._end(callback);
}
value = _this.spring.next();
if (_this.modifiers[k]) {
value = _this.modifiers[k](value);
}
nextState = {};
for (k in beginState) {
v = beginState[k];
nextState[k] = (deltas[k] * value) + beginState[k];
if (_this.modifiers[k]) {
nextState[k] = _this.modifiers[k](nextState[k]);
}
}
return _this._animate(nextState, "linear", _this.spring.speed, run);
};

0 comments on commit bb1d239

Please sign in to comment.