Skip to content
Permalink
Browse files

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.
  • Loading branch information
mikesherov committed Feb 18, 2014
1 parent f102529 commit dc1e63b4324e55fd0d120ec250a5f32f647dffdd
Showing with 12 additions and 5 deletions.
  1. +12 −5 tests/unit/draggable/draggable_options.js
@@ -835,7 +835,8 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() {

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

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

$( element ).one( "drag", function() {
equal( $( window ).scrollTop(), 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" );
});

element.simulate( "drag", {
dx: 1,
y: viewportHeight - scrollSensitivity - 1,
moves: 1
});

ok( $( window ).scrollTop() === 0, "scroll: true doesn't scroll when the element is dragged outside of scrollSensitivity" );

element.draggable( "option", "scrollSensitivity", scrollSensitivity + 10 );

element.offset({
top: viewportHeight - scrollSensitivity - 1,
left: 1
});

currentScrollTop = $( window ).scrollTop();

$( element ).one( "drag", function() {
ok( $( window ).scrollTop() - currentScrollTop, scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" );
});

element.simulate( "drag", {
dx: 1,
y: viewportHeight - scrollSensitivity - 1,
moves: 1
});

ok( $( window ).scrollTop() === scrollSpeed, "scroll: true scrolls when the element is dragged within scrollSensitivity" );

TestHelpers.draggable.restoreScroll( document );
});

0 comments on commit dc1e63b

Please sign in to comment.
You can’t perform that action at this time.