mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
Merge pull request #1960 from openseadragon/ms-firefox-test
Fixed test "Events: Viewer: preventDefaultAction in dblClickHandler".…
This commit is contained in:
commit
58a90f7c39
@ -41,6 +41,7 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* Added setImageFormatsSupported function (#1954 @pandaxtc)
|
* Added setImageFormatsSupported function (#1954 @pandaxtc)
|
||||||
* Added dragToPan to the GestureSettings class, implemented in Viewer (#1956 @msalsbery)
|
* Added dragToPan to the GestureSettings class, implemented in Viewer (#1956 @msalsbery)
|
||||||
* Added preventDefault option to MouseTracker handlers: scrollHandler, keyDownHandler, keyUpHandler, keyHandler (#1957 @msalsbery)
|
* Added preventDefault option to MouseTracker handlers: scrollHandler, keyDownHandler, keyUpHandler, keyHandler (#1957 @msalsbery)
|
||||||
|
* Fixed test "Events: Viewer: preventDefaultAction in dblClickHandler". Fixes #1372 (#1960 @msalsbery)
|
||||||
* ReferenceStrip: Fixed issue where its element was being removed from its parent element twice on destroy, causing an exception (#1958 @msalsbery)
|
* ReferenceStrip: Fixed issue where its element was being removed from its parent element twice on destroy, causing an exception (#1958 @msalsbery)
|
||||||
* ReferenceStrip: Made its element focusable for keyboard navigation (#1958 @msalsbery)
|
* ReferenceStrip: Made its element focusable for keyboard navigation (#1958 @msalsbery)
|
||||||
|
|
||||||
|
@ -833,22 +833,56 @@
|
|||||||
// ----------
|
// ----------
|
||||||
QUnit.test('Viewer: preventDefaultAction in dblClickHandler', function(assert) {
|
QUnit.test('Viewer: preventDefaultAction in dblClickHandler', function(assert) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
var tracker = viewer.innerTracker;
|
|
||||||
var epsilon = 0.0000001;
|
var epsilon = 0.0000001;
|
||||||
|
var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ),
|
||||||
|
simEvent = {},
|
||||||
|
offset = $canvas.offset();
|
||||||
|
|
||||||
|
var simulateEnter = function (x, y) {
|
||||||
|
simEvent.clientX = offset.left + x;
|
||||||
|
simEvent.clientY = offset.top + y;
|
||||||
|
$canvas.simulate( 'mouseenter', simEvent );
|
||||||
|
};
|
||||||
|
|
||||||
|
var simulateLeave = function (x, y) {
|
||||||
|
simEvent.clientX = offset.left + x;
|
||||||
|
simEvent.clientY = offset.top + y;
|
||||||
|
simEvent.relatedTarget = document.body;
|
||||||
|
$canvas.simulate( 'mouseleave', simEvent );
|
||||||
|
};
|
||||||
|
|
||||||
|
var simulateDown = function (x, y) {
|
||||||
|
simEvent.button = 0;
|
||||||
|
simEvent.clientX = offset.left + x;
|
||||||
|
simEvent.clientY = offset.top + y;
|
||||||
|
$canvas.simulate( 'mousedown', simEvent );
|
||||||
|
};
|
||||||
|
|
||||||
|
var simulateUp = function (x, y) {
|
||||||
|
simEvent.button = 0;
|
||||||
|
simEvent.clientX = offset.left + x;
|
||||||
|
simEvent.clientY = offset.top + y;
|
||||||
|
$canvas.simulate( 'mouseup', simEvent );
|
||||||
|
};
|
||||||
|
|
||||||
function simulateDblTap() {
|
function simulateDblTap() {
|
||||||
var touches = [];
|
simulateEnter(2, 2);
|
||||||
TouchUtil.reset();
|
simulateDown(2, 2);
|
||||||
|
simulateUp(2, 2);
|
||||||
touches.push(TouchUtil.start([0,0]));
|
simulateDown(2, 2);
|
||||||
TouchUtil.end( touches[0] );
|
simulateUp(2, 2);
|
||||||
touches.push(TouchUtil.start([0,0]));
|
simulateLeave(-1, -1);
|
||||||
TouchUtil.end( touches[1] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var onOpen = function() {
|
var onOpen = function() {
|
||||||
viewer.removeHandler('open', onOpen);
|
viewer.removeHandler('open', onOpen);
|
||||||
|
|
||||||
|
var origClickSetting = viewer.gestureSettingsMouse.clickToZoom;
|
||||||
|
var origDblClickSetting = viewer.gestureSettingsMouse.dblClickToZoom;
|
||||||
|
|
||||||
|
viewer.gestureSettingsMouse.clickToZoom = false;
|
||||||
|
viewer.gestureSettingsMouse.dblClickToZoom = true;
|
||||||
|
|
||||||
var originalZoom = viewer.viewport.getZoom();
|
var originalZoom = viewer.viewport.getZoom();
|
||||||
|
|
||||||
var onCanvasDblClick = function (event) {
|
var onCanvasDblClick = function (event) {
|
||||||
@ -857,7 +891,6 @@
|
|||||||
|
|
||||||
viewer.addHandler('canvas-double-click', onCanvasDblClick);
|
viewer.addHandler('canvas-double-click', onCanvasDblClick);
|
||||||
|
|
||||||
TouchUtil.initTracker(tracker);
|
|
||||||
simulateDblTap();
|
simulateDblTap();
|
||||||
|
|
||||||
var zoom = viewer.viewport.getZoom();
|
var zoom = viewer.viewport.getZoom();
|
||||||
@ -875,7 +908,9 @@
|
|||||||
"Zoom on double tap should not be prevented");
|
"Zoom on double tap should not be prevented");
|
||||||
|
|
||||||
|
|
||||||
TouchUtil.resetTracker(tracker);
|
viewer.gestureSettingsMouse.clickToZoom = origClickSetting;
|
||||||
|
viewer.gestureSettingsMouse.dblClickToZoom = origDblClickSetting;
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user