-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Open
Description
While we're here making changes, we could also account for scrolling.
- // Incorporate borders into its offset, since they are outside its content origin + // The origin against which we will be returning a relative position is the absolute offset + // of offsetParent, plus the top/left width of its borders (since they are outside offsetParent's + // content origin), minus its top/left scroll position (which has already affected element + // absolute offset and should not be counted twice) parentOffset = jQuery( offsetParent ).offset(); - parentOffset.top += > jQuery.css( offsetParent, "borderTopWidth", true ); - parentOffset.left > += jQuery.css( offsetParent, "borderLeftWidth", true ); + parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true ) - offsetParent.scrollTop; + parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true ) - offsetParent.scrollLeft;
Originally posted by @gibson042 in #4861 (comment)
0Chan-smc