1
Vote

.getScreenPosition and .getPagePosition could be better

description

The two functions: .getScreenPosition and .getPagePosition might be able to be improved by using some proprietary methods from IE and Mozilla.
 
Currently both implementations rely on the rather buggy properties of .offsetLeft and .offsetTop (browsers have sharp disagreements over what these properties should return and often have bugs regarding padding, borders, and overflow).
 
IE offers .getBoundingClientRect, which appears to be very accurate, though it seems to return the screen position, not the page position, so extra will be needed to ensure the proper x/y values are returned when the page is scrolled.
 
Mozilla offsets document.getBoxObjectFor, which also appears to be more accurate than .offsetTop/Left. However, it is not a publicly documented method. It is apparently meant for Add-on developers of Firefox, and the Mozilla devs discourage that use of this in public web sites -- special care will be needed to determine if this is a safe method to use.

comments