mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Add PaperScope switching to onFrame handler.
This commit is contained in:
parent
8375a97d55
commit
0356fdb3b6
1 changed files with 6 additions and 2 deletions
|
@ -156,7 +156,9 @@ var PaperScript = this.PaperScript = new function() {
|
|||
if (onFrame) {
|
||||
var lastTime;
|
||||
var totalTime = 0;
|
||||
function frame() {
|
||||
function frame(dontSwitch) {
|
||||
if (!dontSwitch)
|
||||
PaperScope.set(scope);
|
||||
// Request next frame already
|
||||
DomEvent.requestAnimationFrame(frame, doc && doc.canvas);
|
||||
var time = Date.now() / 1000;
|
||||
|
@ -172,9 +174,11 @@ var PaperScript = this.PaperScript = new function() {
|
|||
if (doc)
|
||||
doc.redraw();
|
||||
lastTime = time;
|
||||
if (!dontSwitch)
|
||||
PaperScope.restore();
|
||||
};
|
||||
// Call the onFrame handler and redraw the document:
|
||||
frame();
|
||||
frame(true);
|
||||
} else {
|
||||
// Automatically redraw document at the end.
|
||||
if (doc)
|
||||
|
|
Loading…
Reference in a new issue