q5xjs
q5xjs copied to clipboard
Parent Container not working as expected
How would you put it in a parent div?
q5.createCanvas(width, height).parent(
"div-id-or-element"
);
returns an error of can't find parent of null
Hi @neelr ,
Currently you can use q5.canvas
to get the canvas HTML element, and put it under new parent using the usual JS way:
let parent = document.getElementById("div-id");
parent.appendChild(q5.canvas);
But I do think the .parent()
wrapper is nice, so I'm considering adding the feature soon. Thanks for reporting!
.parent()
is definitely a useful thing!
I won't implement .parent()
because technically its bad practice because it causes a CLS https://web.dev/cls/
But I did implement adding the parent element as a parameter to the instance constructor!
let q = Q5(parentElem);
https://github.com/quinton-ashley/q5js