mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-28 22:08:54 -04:00
Reuse PaperScope objects when associating multiple scripts with the same canvas.
Closes #504.
This commit is contained in:
parent
e0ec2bf2c3
commit
0198f4c45f
3 changed files with 88 additions and 91 deletions
|
@ -443,12 +443,13 @@ Base.exports.PaperScript = (function() {
|
|||
// If a canvas id is provided, pass it on to the PaperScope
|
||||
// so a project is created for it now.
|
||||
var canvas = PaperScope.getAttribute(script, 'canvas'),
|
||||
// See if there already is a scope for this canvas and reuse
|
||||
// it, to support multiple scripts per canvas. Otherwise
|
||||
// create a new one.
|
||||
scope = PaperScope.get(canvas)
|
||||
|| new PaperScope(script).setup(canvas),
|
||||
src = script.src;
|
||||
canvas = document.getElementById(canvas) || canvas;
|
||||
// See if there already is a scope for this canvas and reuse
|
||||
// it, to support multiple scripts per canvas. Otherwise
|
||||
// create a new one.
|
||||
var scope = PaperScope.get(canvas)
|
||||
|| new PaperScope().setup(canvas);
|
||||
if (src) {
|
||||
// If we're loading from a source, request that first and
|
||||
// then run later.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue