Bug Tracker

Ticket #12536 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

Make .offset() calc less wrong on browsers w/o getBoundingClientRect

Reported by: gabriel.schulhof@… Owned by:
Priority: blocker Milestone: 1.8.2
Component: offset Version: git
Keywords: Cc:
Blocking: Blocked by:

Description

We had agreed that the fix was not for the whole offset function to return { left: 0, top: 0 }, but to have something like

if ( typeof elem.getBoundingClientRect === "undefined" ) {

box = { left: 0, top: 0 };

} else {

box = elem.getBoundingClientRect();

}

... and then proceed to the calculation below, which will give us an offset that may be incorrect, but it's closer than 0, 0, because it takes into account the scrollLeft and scrollTop.

This is related to ticket #12534 ...

Change History

comment:1 Changed 2 years ago by anonymous

I've also noticed that on BB5 elements have properties called clientLeft, clientTop, clientWidth, and clientHeight ... I think these could be used as well.

comment:2 Changed 2 years ago by dmethvin

  • Priority changed from undecided to blocker
  • Status changed from new to open
  • Summary changed from Please re-open ticket #12534 to Make .offset() calc less wrong on browsers w/o getBoundingClientRect
  • Component changed from unfiled to offset
  • Milestone changed from None to 1.8.2

Sounds reasonable, I didn't get that from the IRC discussion yesterday. Before I make further changes though, let's discuss.

comment:3 Changed 2 years ago by Dave Methvin

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

Fix #12536. Start at .offset() 0,0 if no getBoundingClientRect.

This lets us still add the other offset components to the number so they're less wrong. Affects BlackBerry 5 and iOS 3, everyone else has gBCR.

Changeset: 560c178c82da95b2f88ae518552463d87fe5adbf

comment:4 Changed 2 years ago by dmethvin

#12580 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.