Skip to content

Commit

Permalink
Tests: test element position outside view
Browse files Browse the repository at this point in the history
Ref ee0f616
Ref gh-2828
Ref gh-2836
Fixes gh-2909
  • Loading branch information
markelog committed Feb 11, 2016
1 parent ee0f616 commit 30202be
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/data/testsuite.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,15 @@ section { background:#f0f; display:block; }
#span-14824 { display: block; }

#display { display: list-item !important; }

#div-gh-2836 {
position: relative;
overflow: auto;
height: 100px;
}
#div-gh-2836 div {
position: relative;
height: 100%;
padding: 0;
margin: 0;
}
30 changes: 30 additions & 0 deletions test/unit/dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,4 +473,34 @@ QUnit.test( "allow modification of coordinates argument (gh-1848)", function( as
"coordinates are modified (got offset.top: " + offsetTop + ")" );
} );

QUnit.test( "outside view position (gh-2836)", function( assert ) {

// This test ported from gh-2836 example
assert.expect( 1 );

var parent,
html = [
"<div id=div-gh-2836>",
"<div></div>",
"<div></div>",
"<div></div>",
"<div></div>",
"<div></div>",
"</div>"
].join( "" ),
stop = assert.async();

parent = $( html );
parent.appendTo( "#qunit-fixture" );

parent.one( "scroll", function() {
var pos = parent.find( "div" ).eq( 3 ).position();

assert.strictEqual(pos.top, -100);
stop();
});

parent.scrollTop( 400 );
} );

} )();

0 comments on commit 30202be

Please sign in to comment.