mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Add documentation and remove dontSwitch parameter, since it will also receive the time as defined for requestAnimationFrame() callback.
This commit is contained in:
parent
535e5fc5fc
commit
5bc2889f1c
1 changed files with 11 additions and 8 deletions
|
@ -178,6 +178,13 @@ var DocumentView = this.DocumentView = Base.extend({
|
|||
*/
|
||||
onResize: null,
|
||||
|
||||
/**
|
||||
* Handler to be called on each frame of an animation.
|
||||
*/
|
||||
getOnFrame: function() {
|
||||
return this._onFrame;
|
||||
},
|
||||
|
||||
setOnFrame: function(onFrame) {
|
||||
this._onFrame = onFrame;
|
||||
var that = this,
|
||||
|
@ -185,13 +192,13 @@ var DocumentView = this.DocumentView = Base.extend({
|
|||
before,
|
||||
time = 0,
|
||||
count = 0;
|
||||
function frame(dontSwitch) {
|
||||
function frame() {
|
||||
if (!that._onFrame) {
|
||||
running = false;
|
||||
return;
|
||||
}
|
||||
if (!dontSwitch)
|
||||
paper = that._document._scope;
|
||||
// Set the global paper object to the current scope
|
||||
paper = that._document._scope;
|
||||
// Request next frame already
|
||||
DomEvent.requestAnimationFrame(frame, that._canvas);
|
||||
running = true;
|
||||
|
@ -209,11 +216,7 @@ var DocumentView = this.DocumentView = Base.extend({
|
|||
// Call the onFrame handler straight away, initializing the sequence
|
||||
// of onFrame calls.
|
||||
if (!running)
|
||||
frame(true);
|
||||
},
|
||||
|
||||
getOnFrame: function() {
|
||||
return this._onFrame;
|
||||
frame();
|
||||
},
|
||||
|
||||
_createEvents: function() {
|
||||
|
|
Loading…
Reference in a new issue