mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Add paper.debug switch, set it to true by default when loading code through load.js and use it to ignore focus / blur events in Event.requestAnimationFrame() during development.
This commit is contained in:
parent
9d2459d799
commit
ba0c6dafea
2 changed files with 23 additions and 13 deletions
|
@ -102,4 +102,12 @@ if (window.tests) {
|
|||
for (var i = 0; i < sources.length; i++) {
|
||||
document.write('<script type="text/javascript" src="' + (window.root || '')
|
||||
+ sources[i] + '"></script>');
|
||||
if (sources[i] == 'src/paper.js') {
|
||||
// Activate paper.debug for code loaded through load.js, as we're in
|
||||
// development mode.
|
||||
document.write('<script type="text/javascript">'
|
||||
+ 'paper.debug = true;'
|
||||
+ '</script>');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ Event.requestAnimationFrame = new function() {
|
|||
var callbacks = [],
|
||||
fastRate = 1000 / 60,
|
||||
slowRate = 1000,
|
||||
focused = true,
|
||||
timer;
|
||||
|
||||
// Installs interval timer that checks all callbacks. This results in much
|
||||
|
@ -103,19 +104,20 @@ Event.requestAnimationFrame = new function() {
|
|||
}, timeout);
|
||||
}
|
||||
|
||||
var focused = true;
|
||||
Event.add(window, {
|
||||
focus: function() {
|
||||
focused = true;
|
||||
// Switch to falst checkCallback calls while window is focused.
|
||||
timer && setTimer(fastRate);
|
||||
},
|
||||
blur: function() {
|
||||
focused = false;
|
||||
// Switch to slow checkCallback calls while window is blured.
|
||||
timer && setTimer(slowRate);
|
||||
}
|
||||
});
|
||||
if (!paper.debug) {
|
||||
Event.add(window, {
|
||||
focus: function() {
|
||||
focused = true;
|
||||
// Switch to falst checkCallback calls while window is focused.
|
||||
timer && setTimer(fastRate);
|
||||
},
|
||||
blur: function() {
|
||||
focused = false;
|
||||
// Switch to slow checkCallback calls while window is blured.
|
||||
timer && setTimer(slowRate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return function(callback, element) {
|
||||
if (request)
|
||||
|
|
Loading…
Reference in a new issue