There are more display types than "block", unfortunately. Hence the
hack with "". In particular, the display types "table" and "inline"
are rather common. Perhaps we should write some utility function or
lookup table that returns the default display type for a tagName?
Ugly, but doable.

But I think we would remain broken if a parent element has "display:
none". What to do about that?

Cheers,

/Per

On Mon, Oct 27, 2008 at 1:34 PM, Yoann Aubineau
<[EMAIL PROTECTED]> wrote:
>
> Why not set s.diplay to 'block' instead of an empty string ? It
> actually works for me (Safari 3+, Firefox 2+, IE 6+). But there may be
> a trick I'm not aware of that explains this particuliar choice.
>
> 2008/10/27 Per Cederberg <[EMAIL PROTECTED]>:
>>
>> Thanks for the suggestion, but that sort of code is already in
>> getElementDimensions I think:
>>
>>        if (disp == 'none' || disp == '' || typeof(disp) == 'undefined') {
>>            var s = elem.style;
>>            var originalVisibility = s.visibility;
>>            var originalPosition = s.position;
>>            var originalDisplay = s.display;
>>            s.visibility = 'hidden';
>>            s.position = 'absolute';
>>            s.display = '';
>>            var originalWidth = elem.offsetWidth;
>>            var originalHeight = elem.offsetHeight;
>>            s.display = originalDisplay;
>>            s.position = originalPosition;
>>            s.visibility = originalVisibility;
>>        } else {
>>            originalWidth = elem.offsetWidth || 0;
>>            originalHeight = elem.offsetHeight || 0;
>>        }
>>
>> Only the "block/inline/whatever" part uses "". Which works nicely if
>> the style property is set on the element itself. But not on in the CSS
>> class.
>>
>> So, I think we're still stuck... :-(
>>
>> Cheers,
>>
>> /Per
>>
>> On Mon, Oct 27, 2008 at 12:44 PM, Andreas Marienborg
>> <[EMAIL PROTECTED]> wrote:
>>>
>>> On Oct 27, 2008, at 12:30 PM, Per Cederberg wrote:
>>>
>>>>
>>>> I just ran into a bug that I can't resolve. At least I'm out of ideas
>>>> right now:
>>>>
>>>>   http://trac.mochikit.com/ticket/325#comment:2
>>>>
>>>> The problem is when using getElementDimensions() on elements having
>>>> "display: none" set in the CSS class. Or in a parent element. Is there
>>>> a work-around for this? Or do we have to give up and just document
>>>> this?
>>>>
>>>
>>>
>>> You might have tried this, but I think we once did some trickery with
>>> visibility: hidden to get the size of display: none blocks.
>>>
>>> Basicly you set position: absolute and visibility: hidden, then change from
>>> display: none to display: block/inline/whatever
>>> Then you get the dimensions
>>> And set everything back
>>>
>>>
>>> - andreas
>>>
>>>
>>
>> >
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to