Bug Tracker

Opened 14 years ago

Closed 14 years ago

#3239 closed bug (fixed)

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.

Change History (3)

comment:1 Changed 14 years ago by flesler

Component: coredimensions
Owner: set to brandon

comment:2 Changed 14 years ago by flesler

Cc: Tgr flesler brandon added

comment:3 Changed 14 years ago by brandon

Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.