aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard McDaniel <rm0026@uah.edu>2014-10-16 15:32:46 -0400
committerTimmy Willison <timmywillisn@gmail.com>2015-05-12 10:34:57 -0400
commit2d715940b9b6fdeed005cd006c8bf63951cf7fb2 (patch)
tree37bb8dc950bf7876fb22e52299667a05281c61d4 /src
parentc252c5fac2a25869524c2eba2e93d4230e6af25c (diff)
downloadjquery-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.js7
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