Skip to content

Commit e4c3821

Browse files
committed
The RequestAnimationFrame.step and stepTimeout functions have been updated so that the new Frame is requested from raf before the main game step is called. This allows you to now stop the raf callback from within the game update or render loop. Fix phaserjs#3952
1 parent 143957d commit e4c3821

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Updates
1010

1111
* `WebGLRenderer.deleteTexture` will check to see if the texture it is being asked to delete is the currently bound texture or not. If it is, it'll set the blank texture to be bound after deletion. This should stop `RENDER WARNING: there is no texture bound to the unit 0` errors if you destroy a Game Object, such as Text or TileSprite, from an async or timed process (thanks jamespierce)
12+
* The `RequestAnimationFrame.step` and `stepTimeout` functions have been updated so that the new Frame is requested from raf before the main game step is called. This allows you to now stop the raf callback from within the game update or render loop. Fix #3952 (thanks @tolimeh)
1213

1314
### Bug Fixes
1415

src/dom/RequestAnimationFrame.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ var RequestAnimationFrame = new Class({
9494
*/
9595
this.step = function step (timestamp)
9696
{
97-
// DOMHighResTimeStamp
97+
// DOMHighResTimeStamp
9898
_this.lastTime = _this.tick;
9999

100100
_this.tick = timestamp;
101101

102-
_this.callback(timestamp);
103-
104102
_this.timeOutID = window.requestAnimationFrame(step);
103+
104+
_this.callback(timestamp);
105105
};
106106

107107
/**
@@ -122,9 +122,9 @@ var RequestAnimationFrame = new Class({
122122

123123
_this.tick = d;
124124

125-
_this.callback(d);
126-
127125
_this.timeOutID = window.setTimeout(stepTimeout, delay);
126+
127+
_this.callback(d);
128128
};
129129
},
130130

0 commit comments

Comments
 (0)