mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
Avoid endless recursion when changing view from onFrame handler.
Closes #184.
This commit is contained in:
parent
e546848bcc
commit
96b886ae8d
1 changed files with 4 additions and 0 deletions
|
@ -183,6 +183,7 @@ var View = this.View = Base.extend(Callback, /** @lends View# */{
|
|||
var now = Date.now() / 1000,
|
||||
delta = this._before ? now - this._before : 0;
|
||||
this._before = now;
|
||||
this._handlingFrame = true;
|
||||
// Use Base.merge to convert into a Base object, for #toString()
|
||||
this.fire('frame', Base.merge({
|
||||
// Time elapsed since last redraw in seconds:
|
||||
|
@ -194,6 +195,7 @@ var View = this.View = Base.extend(Callback, /** @lends View# */{
|
|||
// Update framerate stats
|
||||
if (this._stats)
|
||||
this._stats.update();
|
||||
this._handlingFrame = false;
|
||||
// Automatically draw view on each frame.
|
||||
this.draw(true);
|
||||
},
|
||||
|
@ -234,6 +236,8 @@ var View = this.View = Base.extend(Callback, /** @lends View# */{
|
|||
|
||||
_redraw: function() {
|
||||
this._redrawNeeded = true;
|
||||
if (this._handlingFrame)
|
||||
return;
|
||||
if (this._animate) {
|
||||
// If we're animating, call _handleFrame staight away, but without
|
||||
// requesting another animation frame.
|
||||
|
|
Loading…
Reference in a new issue