-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Of multiple script/paperscript
scripts, only the first seems to run in PaperScope.
#153
Comments
I needed the ability to load multiple scripts for the same canvas/scope, so I added this in a fork: Specifying the same canvas name for two scripts will cause them to be loaded in the same scope:
In this example, paperscript1.js and paperscript2.js are both loaded into pcanvas1, while paperscript3.js is loaded into pcanvas2. If compatibility is a concern, one option is to add a data attribute to explicitly control the multiple script behavior (add/overwrite/etc):
I didn't add this extra level of control because I didn't need it, but it wouldn't be a lot of work. If this is useful for the project, let me know and I'll sign the agreement and send a pull request. |
That's great, and makes a whole lot of sense! I totally agree that the extra level is not needed. I am confident that this will make it into the next release. I just need to look at implementation details first to see if I merge the request, or restructure the code a bit. |
This looks good. @andypayne would you like to create a pull request? |
Done - #171 |
This is merged in, closing. |
If I have multiple paperscripts in my page, only the first seems to be run in paperscript scope.
Eg:
< script type="text/paperscript" src="scripts/main.js" canvas="myCanvas"></script>
< script type="text/paperscript" src="scripts/extra.js"></script>
'extra.js' is actually loaded by Paper.js, but I cannot, for instance, alter 'view.zoom'. I have to write 'paper.view.zoom', indicating that this script runs in the global scope instead of the paper scope.
Example project: http://barbata.nl/SO/Maps/ (Cannot promise it will be there forever, sorry)
See also: http://stackoverflow.com/questions/14039554/multiple-script-paperscripts-in-the-same-paperscope
The text was updated successfully, but these errors were encountered: