]> source.dussan.org Git - jquery.git/commitdiff
Tests: test element position outside view
authorOleg Gaidarenko <markelog@gmail.com>
Thu, 11 Feb 2016 19:31:49 +0000 (22:31 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Thu, 11 Feb 2016 19:59:09 +0000 (22:59 +0300)
Ref 49833f7795d665ff1d543c4f71f29fca95b567e9
Ref gh-2828
Ref gh-2836
Fixes gh-2909

test/data/testsuite.css
test/unit/dimensions.js

index 253bea9988c7b51ade12331921485a058fe0f2d5..4f2b289f4ecf2dbf59c979ae10908106b84a895e 100644 (file)
@@ -130,3 +130,15 @@ section { background:#f0f; display:block; }
 .inline { display: inline; }
 .list-item { display: list-item; }
 .hidden, .none { display: none; }
+
+#div-gh-2836 {
+       position: relative;
+       overflow: auto;
+       height: 100px;
+}
+#div-gh-2836 div {
+       position: relative;
+       height: 100%;
+       padding: 0;
+       margin: 0;
+}
index c681478a0010c1e06e04898c5f82b2e4a41add06..0b568dd860969d5fe686f6a78b352a010ec2ce64 100644 (file)
@@ -471,4 +471,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 );
+} );
+
 } )();