Skip to content

Commit dc1e63b

Browse files
committed
Draggable Tests: fix IE scroll tests affected by focus issues.
Calling element.focus() causes scroll in IE. In order to correctly test scroll behavior, we must calculate scrollTop on the drag event, before .focus is called.
1 parent f102529 commit dc1e63b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tests/unit/draggable/draggable_options.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,8 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() {
835835

836836
TestHelpers.draggable.setScrollable( "#main", false );
837837

838-
var viewportHeight = $( window ).height(),
838+
var currentScrollTop,
839+
viewportHeight = $( window ).height(),
839840
element = $( "#draggable1" ).draggable({ scroll: true }).appendTo( "#qunit-fixture" ),
840841
scrollSensitivity = element.draggable( "option", "scrollSensitivity" ),
841842
scrollSpeed = element.draggable( "option", "scrollSpeed" );
@@ -845,29 +846,35 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() {
845846
left: 1
846847
});
847848

849+
$( element ).one( "drag", function() {
850+
equal( $( window ).scrollTop(), 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" );
851+
});
852+
848853
element.simulate( "drag", {
849854
dx: 1,
850855
y: viewportHeight - scrollSensitivity - 1,
851856
moves: 1
852857
});
853858

854-
ok( $( window ).scrollTop() === 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" );
855-
856859
element.draggable( "option", "scrollSensitivity", scrollSensitivity + 10 );
857860

858861
element.offset({
859862
top: viewportHeight - scrollSensitivity - 1,
860863
left: 1
861864
});
862865

866+
currentScrollTop = $( window ).scrollTop();
867+
868+
$( element ).one( "drag", function() {
869+
ok( $( window ).scrollTop() - currentScrollTop, scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" );
870+
});
871+
863872
element.simulate( "drag", {
864873
dx: 1,
865874
y: viewportHeight - scrollSensitivity - 1,
866875
moves: 1
867876
});
868877

869-
ok( $( window ).scrollTop() === scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" );
870-
871878
TestHelpers.draggable.restoreScroll( document );
872879
});
873880

0 commit comments

Comments
 (0)