#984 closed bug (invalid)
$(element).width() & $(element).height() functions return incorrect values
Reported by: | elemerz | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.1.2 |
Component: | core | Version: | 1.1.1 |
Keywords: | Layout Manager | Cc: | |
Blocked by: | Blocking: |
Description
$(element).width() & $(element).height() functions return incorrect values. I rewrote the prototype 1.5.0 -based [RUZEE layout Manager|http://www.ruzee.com/blog/ruzeelayoutmanager/] for jQuery. I needed to get the dimensions of an element, in form of a hash like: {width:widthValue,height:heightValue}. I used: {width:$(element).width(), height:$(element).height()} in the jQuery version. I noticed that these two functions (width(), and height()) do not return the same values like Element.getDimensions(element) used by prototype. My jQuery -based rewritten version of the above mentioned LayoutManager does not render correctly because of these differences. To see in action what I'm talking about, set the useJQueryDimensions variable inside of lm.jquery.js file in the attachment. Thanx in advance,
Elemér. In the attachment you can find
Attachments (1)
Change History (5)
Changed 15 years ago by
Attachment: | BugReport.zip added |
---|
comment:2 Changed 15 years ago by
Component: | ajax → core |
---|---|
Priority: | major → minor |
I'm not entirely sure what I'm supposed to be seeing - but I did notice that you subtract the padding and border widths from the height/width - jQuery already does this. The .height() and .width() returned by jQuery do not include those numbers, and are stable across browsers.
Additionally, you may want to look into the Dimensions plugin, which will reduce the size of your plugin by about 90%, it looks like.
http://dev.jquery.com/browser/trunk/plugins/dimensions/dimensions.js?format=txt
comment:3 Changed 15 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
As John mentioned, the jQuery width and height methods return the actual computed CSS width and height. If you want the offset width (includes padding and border) you should use the dimensions plugin outerWidth method (it also accounts for if an element is display: none).
Also just a note ... you can pass the css method numbers and it will append the "px" for you.
Layout Manager based on jQuery.