Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent Container not working as expected #7

Open
neelr opened this issue Oct 6, 2020 · 3 comments
Open

Parent Container not working as expected #7

neelr opened this issue Oct 6, 2020 · 3 comments

Comments

@neelr
Copy link

neelr commented Oct 6, 2020

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

@LingDong-
Copy link
Owner

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!

@Badokas
Copy link

Badokas commented Oct 15, 2020

.parent() is definitely a useful thing!

@quinton-ashley
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants