Late load of paperjs should still run paperscripts

See this problem html http://stackoverflow.com/questions/14110205/dynamically-loading-a-script-changes-its-behaviour/14114337 and note how jquery handle this at https://github.com/jquery/jquery/blob/master/src/core.js#L768
This commit is contained in:
Yuval Greenfield 2013-01-02 01:57:30 +02:00
parent b04eb2b98f
commit a3a211eead

View file

@ -298,7 +298,13 @@ var PaperScript = this.PaperScript = new function() {
}
}
DomEvent.add(window, { load: load });
// Catch cases where paperjs is loaded after the browser event has already occurred.
if ( document.readyState === "complete" ) {
// Handle it asynchronously
setTimeout( load );
} else {
DomEvent.add(window, { load: load });
}
// Produces helpers to e.g. check for both 'canvas' and 'data-paper-canvas'
// attributes: