javascriptdomsafarigetboundingclientrect

Safari's getBoundingClientRect() Implementation Returns Incorrect Top


I have a div with float: right and I'm trying to get its distance from the top of the viewport. In every browser except Safari I'm getting the expected results from element.getBoundingClientRect().top. Safari appears to be reporting the element's distance from the top of the page rather than the viewport. This is contrary to what is defined in the spec for this method (as I understand it). Is Safari just not following the rules here, or are other browsers being more forgiving of some mistake of mine that I'm not seeing?


Solution

  • This appears to be a bug that effects the way that Safari reports element and scroll locations on its load event. If you run the exact same call with a 500ms timeout everything works as expected.

    I will update when I hear back on my bug report.