#313 enhancement
datamagi

Problem with finding dimensions of hidden elements

Reported by datamagi | August 28th, 2008 @ 11:34 PM | in 1.6.1

In the getDimensions method you make an attempt at discovering the dimensions of hidden elements (i.e. display: none) by making them absolute, invisible and unhiding them. The invisible/unhide-approach makes sense, but making the hidden element absolute also makes it shrinkwrap its contents (say, if it's a div - at least on the few browsers I tested) and the width you then get is possibly much smaller than if it wasn't made absolute.

For a demonstration, see the attachment of issue #310 (the blue-bordered div).

Comments and changes to this ticket

  • John-David Dalton
  • John-David Dalton

    John-David Dalton August 28th, 2008 @ 11:52 PM

    
    They made it absolute so it wouldn't warp the rest of the page content around.
    They may not be an issue since it happens so fast, but I have seen things appear
    constantly visible when used with onmousemove events and things.
    We should test for this to make sure.
    
    Omitting the position:absolute, did fix my web application.
    The content kept shrinking everytime I opened a tooltip.
    This fixed it :)
    
  • datamagi

    datamagi August 28th, 2008 @ 11:57 PM

    Oh, I forgot this comment fra #310:

    "I suppose it's made absolute in order to prevent any flicker or movement in the flow of the page that could appear otherwise, but I'd still prefer getting the correct dimensions over infrequent (and minor?) inconveniences like that. Or maybe even the user could be allowed decide if the library should make an attempt at discovering dimensions for hidden elements or not, i.e. change the signature to getDimensions(element[, discoverHidden])? discoverHidden would default to true for backwards compatibility, obviously."

    If a discoverHidden-option was added, it would need to be documented (something resembling the paragraph above), so people can see the trade-offs.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket