Skip to content

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

Closed

Description

@radames

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.

Activity

  1. self-assigned this
    on Jun 18, 2015
  2. futuremarc commented on Jun 20, 2015

    @futuremarc
    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.

  3. radames commented on Jun 20, 2015

    @radames
    Author

    it makes sense! great!

  4. workergnome commented on Jun 21, 2015

    @workergnome
    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?

  5. futuremarc commented on Jun 22, 2015

    @futuremarc
    Contributor

    @lmccart is this something we should try to address?

  6. shiffman commented on Jun 22, 2015

    @shiffman
    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!

  7. workergnome commented on Jun 23, 2015

    @workergnome
    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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions