[Prototype-core] Proto 1.7rc1, problem with measuring width of elements with display: none

9 views
Skip to first unread message

Viktor Kojouharov

unread,
Apr 22, 2010, 6:40:26 AM4/22/10
to Prototype: Core
I'm having a bit of a problem with measuring the width of a hidden
(with display: none) element, that has the 'body' as its parent. I
don't have a set width for this element (which is a div), but the
browsers do calculate a finite width for it, which is much smaller
than the size of the page body. However, with the layout changes,
since there is no predefined width, prototype will not use the
computed width, but will take the parent's width, which just happens
to be the width of the entire page.

will there be any plans for fixing this? otherwise I can always use
the old code for this special case.

--
You received this message because you are subscribed to the Google Groups "Prototype: Core" group.
To post to this group, send email to prototy...@googlegroups.com
To unsubscribe from this group, send email to prototype-cor...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en

Viktor Kojouharov

unread,
Apr 27, 2010, 4:22:46 AM4/27/10
to Prototype: Core
Another thing I forgot to mention. In the CSS file, the div has an
absolute position (which is probably why the browser can calculate its
size). After reading the comment in the source:

if (width && (positionedWidth === width)) {
// If the element's width is the same both before and after
// we set absolute positioning, that means:
// (a) it was already absolutely-positioned; or
// (b) it has an explicitly-set width, instead of width:
auto.
// Either way, it means the element is the width it needs to
be
// in order to report an accurate height.
newWidth = getPixelValue(width);
} else if (width && (position === 'absolute' || position ===
'fixed')) {


It would seem that the width should be obtained in 'if' part. However,
there is no width, since element.style.width is empty. On the other
hand, positionedWidth is correct. The 'position' is also absolute, so
it could also go into the else if, but it won't, since the width is
null.
Reply all
Reply to author
Forward
0 new messages