Modify ↓
Ticket #3011 (closed bug: duplicate)
Dimensions fails to return dimensions when visiblity is set to hidden
| Reported by: | jdsharp | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.3 |
| Component: | dimensions | Version: | 1.2.6 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Testing in 1.2.6 using innerWidth() on an element who's parent is visibility: hidden returns 0 in Firefox. Below are two test cases. This behavior changed in 1.2.6 with dimensions integrated into core.
http://jdsharp.us/jQuery/debug/scrollbar-1.2.6.html http://jdsharp.us/jQuery/debug/scrollbar-1.2.3-dimensions.html
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

I isolated the issue to how width/height calculations are different from 1.2.3+dimensions to 1.2.6. In the dimensions plugin element.clientWidth is read if the element isn't visible. In 1.2.6 the element is "shown" temporarily, the property (offsetWidth) is read, and then hidden again. The issue is that if visibility is set for a parent element the element in question won't become "visible" by merely setting the css attributes.
I'll work on a patch and see what I can come up with.