-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
div get dimensions #391
Comments
Would it make sense to integrate something like bonzo? https://github.com/ded/bonzo Chandler McWilliams On Sat, Oct 11, 2014 at 10:03 AM, Daniel Shiffman
|
@shiffman this would be great. I've been making most of the things in this library work as both setters and getters, so maybe these methods could set the w and h or return vals if arguments are null. @brysonian interesting suggestion! we might have already implemented most of this, and in some ways slightly different than this lib, but let me take a closer look. |
@lmccart yeah to be more clear i guess i'm just wondering how much wheel-reinventing is necessary, but if the work is already done then that's great! |
.size() now returns a string with the current width & height of the element if no arguments are provided. However, p5 Elements already have the variables 'width' and 'height' that store the element's initial offsetWidth/offsetHeight. Should we use a naming convention like eltWidth and eltHeight? |
I ran some quick tests (with the following code).
The current behavior I believe is:
|
I think an object returned from In this spirit of doubling as a getter/setter, what if with null arguments things like This could also help when considering how to more easily deal with input events. We can make the setter/getter Something like: var btn = createButton();
var div = createDiv('im a div');
btn.events().onmousedown = div.html('listening to btn'); |
I think this syntax is a bit hard to follow. We have a mousedown event handler actually, so I wonder how it fits with this? Or are you suggesting replacing it? btn.mousePressed( function(e) { // do stuff } ) If we wanted to add a generic btn.event('mousedown', function(e) { // do stuff } ); In any case, the right side of the code above would need to be wrapped inside of a function, so it's not fired immediately, something like: = function() { div.html('listening to btn'); }; |
re: |
@lmccart I guess I'm trying to find a place for things that people might want when working with form elements. What if we had an |
closed with 9015ffe |
A small thing, but also re: p5.dom a lot of my examples require dynamically accessing the size of a DIV (which changes according to the amount of text). I may be mistaken but I believe p5 only allows for setting the dimensions with
size()
but for retrieving the width/height I am doing the following:Would it make sense to have a
width()/height()
method that returns the dimensions?The text was updated successfully, but these errors were encountered: