Skip to content

Commit

Permalink
Wait for document ready before inserting elements
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbok committed Dec 31, 2012
1 parent 1677a43 commit bb1d239
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
17 changes: 10 additions & 7 deletions build/framer.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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", "");
Expand Down Expand Up @@ -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;
};

Expand All @@ -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;
Expand Down Expand Up @@ -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);
};
Expand Down
3 changes: 2 additions & 1 deletion src/views/view.coffee
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions template/framer.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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", "");
Expand Down Expand Up @@ -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;
};

Expand All @@ -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;
Expand Down Expand Up @@ -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);
};
Expand Down

0 comments on commit bb1d239

Please sign in to comment.