Skip to main content

Bug Tracker

Side navigation

#3239 closed bug (fixed)

Opened August 10, 2008 05:10PM UTC

Closed April 22, 2009 02:39AM UTC

innerHeight/outerHeight does not round up

Reported by: Tgr Owned by: brandon
Priority: minor Milestone: 1.3
Component: dimensions Version: 1.2.6
Keywords: Cc: Tgr, flesler, brandon
Blocked by: Blocking:

innerHeight and outerHeight are sometimes one pixel off from what one might expect, because they floor instead of rounding when there sizes are not integer in pixel.

On this page (the relevant code can be found here (the first function), the original, innerHeight-based version here) I tried to position a box to the bottom of another box, and the result was sometimes but not always one pixel off, depending on the contents. Casting the relevant css attributes (height, padding-top/bottom, border-top/bottom-width) to float and summing them resulted in 41.616699999999994; outerHeight returned 41. (Tested with Firefox 3 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/2008070208 Firefox/3.0.1) on 1280x800.)

Not a bug in the strictest sense, but it makes pixel-perfect positioning with these functions impossible in certain cases. Rounding or returning the exact value seems more useful to me.

Also, from the source it seems that height, padding etc. are first cast to int and then summed; I haven't tested this, but it seems that rounding errors could grow to 6-7 pixels in unlucky cases.

Attachments (0)
Change History (3)

Changed August 10, 2008 11:47PM UTC by flesler comment:1

component: coredimensions
owner: → brandon

Changed August 10, 2008 11:47PM UTC by flesler comment:2

cc: → Tgr, flesler, brandon

Changed April 22, 2009 02:39AM UTC by brandon comment:3

resolution: → fixed
status: newclosed

This seems to be fixed in latest SVN. Please feel free to reopen if you are still experiencing issues.