mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -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,
|
onResize: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler to be called on each frame of an animation.
|
||||||
|
*/
|
||||||
|
getOnFrame: function() {
|
||||||
|
return this._onFrame;
|
||||||
|
},
|
||||||
|
|
||||||
setOnFrame: function(onFrame) {
|
setOnFrame: function(onFrame) {
|
||||||
this._onFrame = onFrame;
|
this._onFrame = onFrame;
|
||||||
var that = this,
|
var that = this,
|
||||||
|
@ -185,13 +192,13 @@ var DocumentView = this.DocumentView = Base.extend({
|
||||||
before,
|
before,
|
||||||
time = 0,
|
time = 0,
|
||||||
count = 0;
|
count = 0;
|
||||||
function frame(dontSwitch) {
|
function frame() {
|
||||||
if (!that._onFrame) {
|
if (!that._onFrame) {
|
||||||
running = false;
|
running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!dontSwitch)
|
// Set the global paper object to the current scope
|
||||||
paper = that._document._scope;
|
paper = that._document._scope;
|
||||||
// Request next frame already
|
// Request next frame already
|
||||||
DomEvent.requestAnimationFrame(frame, that._canvas);
|
DomEvent.requestAnimationFrame(frame, that._canvas);
|
||||||
running = true;
|
running = true;
|
||||||
|
@ -209,11 +216,7 @@ var DocumentView = this.DocumentView = Base.extend({
|
||||||
// Call the onFrame handler straight away, initializing the sequence
|
// Call the onFrame handler straight away, initializing the sequence
|
||||||
// of onFrame calls.
|
// of onFrame calls.
|
||||||
if (!running)
|
if (!running)
|
||||||
frame(true);
|
frame();
|
||||||
},
|
|
||||||
|
|
||||||
getOnFrame: function() {
|
|
||||||
return this._onFrame;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_createEvents: function() {
|
_createEvents: function() {
|
||||||
|
|
Loading…
Reference in a new issue