Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created May 4, 2016 19:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atduskgreg/734dcd32e80283b83ca5cb82d69030bd to your computer and use it in GitHub Desktop.
Save atduskgreg/734dcd32e80283b83ca5cb82d69030bd to your computer and use it in GitHub Desktop.
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if(mutation.addedNodes.length > 0 && mutation.addedNodes[0].nodeName == "CANVAS"){
// do stuff after the sketch loaded
}
});
});
var config = { attributes: false, childList: true, characterData: false }
target = document.getElementById("myDiv")
observer.observe(target, config);
new p5(mySketch, target);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment