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

Properties of a dom p5.element, position? #579

Closed
radames opened this issue Mar 20, 2015 · 6 comments
Closed

Properties of a dom p5.element, position? #579

radames opened this issue Mar 20, 2015 · 6 comments

Comments

@radames
Copy link

radames commented Mar 20, 2015

I was trying to access the position of a slider and noticed that only the property slider.width and slider.heigh are accessible.
I manage to get the relative positions through slider.elt.style.left or slider.elt.style.top .
Wouldn't be nice to have access straight from the element like slider.x slider.y? Perhaps with center mode or corner mode.

@futuremarc
Copy link
Contributor

Going to close this one because we decided against storing the position in x y on the Element since any changes to position in css made without using p5 would break those attributes. However, position() with null args will soon return an object with x and y.

Same thing applies to width and height attrs but we need those for the canvas, but if you wanted always accurate measurements size() will soon return them in an object .

@lmccart is it worth making width and height private to improve p5 integrity? I wonder if there are examples or tutorials that would break though.

@radames
Copy link
Author

radames commented Jun 20, 2015

it makes sense! great!

@workergnome
Copy link
Contributor

It will certainly break a ton of examples, and also working code. Would it be a terrible idea to hook into the window resize event, and check-and-update canvas sizes when that happens?

@futuremarc
Copy link
Contributor

@lmccart is this something we should try to address?

@shiffman
Copy link
Member

@workergnome are you confusing the global width and height variables for the p5.Element ones? I don't believe the latter appear in many examples (and are unrelated to a resize() event? Apologies if I'm the one misunderstanding!

@workergnome
Copy link
Contributor

Oops—I am in fact confusing those! Thank you for the clarification.

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

No branches or pull requests

5 participants