Bug Tracker

Modify

Ticket #3239 (closed bug: fixed)

Opened 5 years ago

Last modified 4 years ago

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
Blocking: Blocked by:

Description

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:1.9.0.1) 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

comment:1 Changed 5 years ago by flesler

  • Owner set to brandon
  • Component changed from core to dimensions

comment:2 Changed 5 years ago by flesler

  • Cc Tgr, flesler, brandon added

comment:3 Changed 4 years ago by brandon

  • Status changed from new to closed
  • Resolution set to fixed

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.