#1162 new
Philippe Lang

Prototype 1.7 getdimensions

Reported by Philippe Lang | November 1st, 2010 @ 01:57 PM


I'm using http://kammerer.boo.pl/code/prototype-overlay/ with Prototype 1.7 RC3, and I noticed something strange when assigning dynamically an image to a hidden div that will be rendered as an overlay.

If the image height IS NOT set (only the width, in order to preserve the aspect ratio), getdimensions returns most of the time a wrong element height the FIRST time. The second time, that's fine, height is computed correctly, as long as the image source does not change.

If the image height IS set, no problem, getdimensions returns a correct height all the time, and the overlay is well centered on the screen.

Note that I tried displaying the overlay before assigning the image, and the same problem happens, so this does not seem to be related to the "hidden parent" problem mentioned in the getdimensions documentation page. One more thing: I tried using the new "layout" object, and the same thing happens.

Is that supposed to be a bug maybe? Or am I missing something?

Thanks a lot for Prototype, and best regards,

Philippe Lang

Comments and changes to this ticket

  • Philippe Lang

    Philippe Lang November 1st, 2010 @ 02:05 PM

    Sorry, but further tests showed me that setting the height of the image explicitely solved the problem under Chrome, but not under Firefox. Strange...

  • Konstantin Buklej

    Konstantin Buklej November 19th, 2010 @ 11:58 AM


    I've experienced this problem in 1.6.* and after update to 1.7 rc3 I still can't figure this out. I've tried $(obj).getHeight, $(obj).measure("height"), $(obj).getDimensions() and always height is 3-10px less at first time then at others.

    Now i got to use terrible js code adding few pixels depending on browser and which time my popup is showed. And my question is the same as Philippe's Lang is: it's a bug or am I missing something?

    Thank you for prototype.a

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

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