mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -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) {
|
if (onFrame) {
|
||||||
var lastTime;
|
var lastTime;
|
||||||
var totalTime = 0;
|
var totalTime = 0;
|
||||||
function frame() {
|
function frame(dontSwitch) {
|
||||||
|
if (!dontSwitch)
|
||||||
|
PaperScope.set(scope);
|
||||||
// Request next frame already
|
// Request next frame already
|
||||||
DomEvent.requestAnimationFrame(frame, doc && doc.canvas);
|
DomEvent.requestAnimationFrame(frame, doc && doc.canvas);
|
||||||
var time = Date.now() / 1000;
|
var time = Date.now() / 1000;
|
||||||
|
@ -172,9 +174,11 @@ var PaperScript = this.PaperScript = new function() {
|
||||||
if (doc)
|
if (doc)
|
||||||
doc.redraw();
|
doc.redraw();
|
||||||
lastTime = time;
|
lastTime = time;
|
||||||
|
if (!dontSwitch)
|
||||||
|
PaperScope.restore();
|
||||||
};
|
};
|
||||||
// Call the onFrame handler and redraw the document:
|
// Call the onFrame handler and redraw the document:
|
||||||
frame();
|
frame(true);
|
||||||
} else {
|
} else {
|
||||||
// Automatically redraw document at the end.
|
// Automatically redraw document at the end.
|
||||||
if (doc)
|
if (doc)
|
||||||
|
|
Loading…
Reference in a new issue