diff options
author | Richard McDaniel <rm0026@uah.edu> | 2014-10-16 15:32:46 -0400 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2015-05-12 10:34:57 -0400 |
commit | 2d715940b9b6fdeed005cd006c8bf63951cf7fb2 (patch) | |
tree | 37bb8dc950bf7876fb22e52299667a05281c61d4 /src | |
parent | c252c5fac2a25869524c2eba2e93d4230e6af25c (diff) | |
download | jquery-2d715940b9b6fdeed005cd006c8bf63951cf7fb2.tar.gz jquery-2d715940b9b6fdeed005cd006c8bf63951cf7fb2.zip |
Offset: account for scroll when calculating position
Fixes gh-1708
Close gh-1714
Diffstat (limited to 'src')
-rw-r--r-- | src/offset.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/offset.js b/src/offset.js index 95658ca69..5ae7153f1 100644 --- a/src/offset.js +++ b/src/offset.js @@ -131,8 +131,11 @@ jQuery.fn.extend({ } // Add offsetParent borders - parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); - parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); + // Subtract offsetParent scroll positions + parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ) - + offsetParent.scrollTop(); + parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ) - + offsetParent.scrollLeft(); } // Subtract parent offsets and element margins |