Skip to content

Commit ee0f616

Browse files
committed
Revert "Offset: account for scroll when calculating position"
This reverts commit 2d71594. This commit provoked new issues: jquerygh-2836, jquerygh-2828. At the meeting, we decided to revert offending commit (in all three branches - 2.2-stable, 1.12-stable and master) and tackle this issue in 3.x. Fixes jquerygh-2828
1 parent 412c5df commit ee0f616

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/offset.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,8 @@ jQuery.fn.extend( {
134134
}
135135

136136
// Add offsetParent borders
137-
// Subtract offsetParent scroll positions
138-
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ) -
139-
offsetParent.scrollTop();
140-
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ) -
141-
offsetParent.scrollLeft();
137+
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
138+
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
142139
}
143140

144141
// Subtract parent offsets and element margins

test/unit/offset.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ testIframe( "offset/table", "table", function( $, window, document, assert ) {
415415
} );
416416

417417
testIframe( "offset/scroll", "scroll", function( $, win, doc, assert ) {
418-
assert.expect( 28 );
418+
assert.expect( 24 );
419419

420420
assert.equal( $( "#scroll-1" ).offset().top, 7, "jQuery('#scroll-1').offset().top" );
421421
assert.equal( $( "#scroll-1" ).offset().left, 7, "jQuery('#scroll-1').offset().left" );
@@ -487,17 +487,6 @@ testIframe( "offset/scroll", "scroll", function( $, win, doc, assert ) {
487487
assert.notEqual( $().scrollLeft( null ), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
488488
assert.strictEqual( $().scrollTop(), undefined, "jQuery().scrollTop() testing getter on empty jquery object" );
489489
assert.strictEqual( $().scrollLeft(), undefined, "jQuery().scrollLeft() testing getter on empty jquery object" );
490-
491-
// Tests position after parent scrolling (#15239)
492-
$( "#scroll-1" ).scrollTop( 0 );
493-
$( "#scroll-1" ).scrollLeft( 0 );
494-
assert.equal( $( "#scroll-1-1" ).position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
495-
assert.equal( $( "#scroll-1-1" ).position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
496-
497-
$( "#scroll-1" ).scrollTop( 5 );
498-
$( "#scroll-1" ).scrollLeft( 5 );
499-
assert.equal( $( "#scroll-1-1" ).position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
500-
assert.equal( $( "#scroll-1-1" ).position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
501490
} );
502491

503492
testIframe( "offset/body", "body", function( $, window, document, assert ) {
@@ -511,6 +500,7 @@ testIframe( "offset/body", "body", function( $, window, document, assert ) {
511500

512501
QUnit.test( "chaining", function( assert ) {
513502
assert.expect( 3 );
503+
514504
var coords = { "top": 1, "left": 1 };
515505
assert.equal( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
516506
assert.equal( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );

0 commit comments

Comments
 (0)