Offset: account for scroll when calculating position

Fixes gh-1708
Close gh-1714
This commit is contained in:
Richard McDaniel
2014-10-16 15:32:46 -04:00
committed by Timmy Willison
parent c252c5fac2
commit 2d715940b9
2 changed files with 17 additions and 3 deletions

View File

@@ -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