Following instructions from this question, I have a div which is being cloned that has a p5 canvas inside it. When it is cloned the canvas is not responsive to mouse coordinates.
How do I make the p5 canvas still active after cloning?
$(document).ready(function() {
$(".showcanvas").click(function() {
// Find the original canvas element
var origCanvas = $(".canvas").first().find('canvas')[0];
// Clone the div wrapper
var clonedDiv = $(".canvas").first().clone(true);
// Find the cloned canvas
var clonedCanvas = clonedDiv.find('canvas');
// Update the ID. (IDs should be unique in the document)
clonedCanvas.prop('id', 'defaultCanvas' + $(".canvas").length)
// Draw the original canvas to the cloned canvas
clonedCanvas[0].getContext('2d').drawImage(origCanvas, 0, 0);
// Append the cloned elements
clonedDiv.appendTo("article").fadeIn('1200');
});
});