Skip to content

Commit 30202be

Browse files
committed
Tests: test element position outside view
Ref ee0f616 Ref jquerygh-2828 Ref jquerygh-2836 Fixes jquerygh-2909
1 parent ee0f616 commit 30202be

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

test/data/testsuite.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,15 @@ section { background:#f0f; display:block; }
142142
#span-14824 { display: block; }
143143

144144
#display { display: list-item !important; }
145+
146+
#div-gh-2836 {
147+
position: relative;
148+
overflow: auto;
149+
height: 100px;
150+
}
151+
#div-gh-2836 div {
152+
position: relative;
153+
height: 100%;
154+
padding: 0;
155+
margin: 0;
156+
}

test/unit/dimensions.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,4 +473,34 @@ QUnit.test( "allow modification of coordinates argument (gh-1848)", function( as
473473
"coordinates are modified (got offset.top: " + offsetTop + ")" );
474474
} );
475475

476+
QUnit.test( "outside view position (gh-2836)", function( assert ) {
477+
478+
// This test ported from gh-2836 example
479+
assert.expect( 1 );
480+
481+
var parent,
482+
html = [
483+
"<div id=div-gh-2836>",
484+
"<div></div>",
485+
"<div></div>",
486+
"<div></div>",
487+
"<div></div>",
488+
"<div></div>",
489+
"</div>"
490+
].join( "" ),
491+
stop = assert.async();
492+
493+
parent = $( html );
494+
parent.appendTo( "#qunit-fixture" );
495+
496+
parent.one( "scroll", function() {
497+
var pos = parent.find( "div" ).eq( 3 ).position();
498+
499+
assert.strictEqual(pos.top, -100);
500+
stop();
501+
});
502+
503+
parent.scrollTop( 400 );
504+
} );
505+
476506
} )();

0 commit comments

Comments
 (0)