Question

I'm trying to initialize an application but seem to be having trouble getting paper js to properly load into my script. I'm using require.js as my AMD loader and am trying to load paper js with the shim module.

Here's my code:

requirejs.config({
    urlArgs: "bust=" + (new Date()).getTime(),//used to keep the browser from caching the scripts as we move
    baseUrl : "scripts",//base scripts page!
    paths : {   
        'jquery' : "../components/jquery/jquery.min", //specific libraries -- can be specified later
        'underscore' : "../components/underscore/underscore",
        'paper' : "../components/paper/paper"
    },
    shim: {
        'underscore': {
            exports: '_'
        },
        'paper' : {
            exports: 'Paper'
        },
    },
});

// initialize the document with a doc ready!

requirejs(["jquery", "underscore", "paper"], function ($, _, Paper) {
    alert(_);
    alert(Paper);
});

The first alert works fine, (the underscore) meaning that it loads okay, but I can't seem to figure out how to get paper.js working properly.

Any help would be greatly appreciated.

Was it helpful?

Solution

The PaperJS global namespace is "paper".

Simply replace "Paper" by "paper" and it should work.

'paper' : {
    exports: 'paper'
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top