From b0447979f35fbdf018314cc32fbfb0720136d1c7 Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Wed, 17 Mar 2021 15:15:36 -0700 Subject: [PATCH 1/4] Fixed test "Events: Viewer: preventDefaultAction in dblClickHandler". Fixes #1372 --- changelog.txt | 1 + test/modules/events.js | 66 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 9 deletions(-) diff --git a/changelog.txt b/changelog.txt index 3e4c2d66..1c84c1b6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -41,6 +41,7 @@ OPENSEADRAGON CHANGELOG * Added setImageFormatsSupported function (#1954 @pandaxtc) * Added dragToPan to the GestureSettings class, implemented in Viewer (#1956 @msalsbery) * Added preventDefault option to MouseTracker handlers: scrollHandler, keyDownHandler, keyUpHandler, keyHandler (#1957 @msalsbery) +* Fixed test "Events: Viewer: preventDefaultAction in dblClickHandler". Fixes #1372 (#1959 @msalsbery) 2.4.2: diff --git a/test/modules/events.js b/test/modules/events.js index 5fdf9cbb..69a5c8a2 100644 --- a/test/modules/events.js +++ b/test/modules/events.js @@ -835,20 +835,67 @@ var done = assert.async(); var tracker = viewer.innerTracker; 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() { + // var touches = []; + // TouchUtil.reset(); + + // touches.push(TouchUtil.start([0,0])); + // TouchUtil.end( touches[0] ); + // touches.push(TouchUtil.start([0,0])); + // TouchUtil.end( touches[1] ); + // } function simulateDblTap() { - var touches = []; - TouchUtil.reset(); - - touches.push(TouchUtil.start([0,0])); - TouchUtil.end( touches[0] ); - touches.push(TouchUtil.start([0,0])); - TouchUtil.end( touches[1] ); + simulateEnter(2, 2); + simulateDown(2, 2); + simulateUp(2, 2); + simulateDown(2, 2); + simulateUp(2, 2); + simulateLeave(-1, -1); } var onOpen = function() { + var origClickSetting, + origDblClickSetting; + viewer.removeHandler('open', onOpen); + origClickSetting = viewer.gestureSettingsMouse.clickToZoom; + origDblClickSetting = viewer.gestureSettingsMouse.dblClickToZoom; + + viewer.gestureSettingsMouse.clickToZoom = false; + viewer.gestureSettingsMouse.dblClickToZoom = true; + var originalZoom = viewer.viewport.getZoom(); var onCanvasDblClick = function (event) { @@ -857,7 +904,6 @@ viewer.addHandler('canvas-double-click', onCanvasDblClick); - TouchUtil.initTracker(tracker); simulateDblTap(); var zoom = viewer.viewport.getZoom(); @@ -875,7 +921,9 @@ "Zoom on double tap should not be prevented"); - TouchUtil.resetTracker(tracker); + viewer.gestureSettingsMouse.clickToZoom = origClickSetting; + viewer.gestureSettingsMouse.dblClickToZoom = origDblClickSetting; + viewer.close(); done(); }; From 6b846249e446f86939ba039fd15f6e5d464d396e Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Wed, 17 Mar 2021 15:24:18 -0700 Subject: [PATCH 2/4] changelog update --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 1c84c1b6..6f84d1d1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -41,7 +41,7 @@ OPENSEADRAGON CHANGELOG * Added setImageFormatsSupported function (#1954 @pandaxtc) * Added dragToPan to the GestureSettings class, implemented in Viewer (#1956 @msalsbery) * Added preventDefault option to MouseTracker handlers: scrollHandler, keyDownHandler, keyUpHandler, keyHandler (#1957 @msalsbery) -* Fixed test "Events: Viewer: preventDefaultAction in dblClickHandler". Fixes #1372 (#1959 @msalsbery) +* Fixed test "Events: Viewer: preventDefaultAction in dblClickHandler". Fixes #1372 (#1960 @msalsbery) 2.4.2: From baeb70fdcc10bd3580e941cb95f0dae67ee167d1 Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Wed, 17 Mar 2021 16:15:22 -0700 Subject: [PATCH 3/4] code cleanup --- test/modules/events.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/modules/events.js b/test/modules/events.js index 69a5c8a2..b5f4b89a 100644 --- a/test/modules/events.js +++ b/test/modules/events.js @@ -833,7 +833,6 @@ // ---------- QUnit.test('Viewer: preventDefaultAction in dblClickHandler', function(assert) { var done = assert.async(); - var tracker = viewer.innerTracker; var epsilon = 0.0000001; var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ), simEvent = {}, @@ -866,15 +865,6 @@ $canvas.simulate( 'mouseup', simEvent ); }; - // function simulateDblTap() { - // var touches = []; - // TouchUtil.reset(); - - // touches.push(TouchUtil.start([0,0])); - // TouchUtil.end( touches[0] ); - // touches.push(TouchUtil.start([0,0])); - // TouchUtil.end( touches[1] ); - // } function simulateDblTap() { simulateEnter(2, 2); simulateDown(2, 2); From a0ff35a1532dab21413ce54d50cd66f6ccf5dc7b Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Wed, 17 Mar 2021 16:18:49 -0700 Subject: [PATCH 4/4] more code cleanup --- test/modules/events.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/modules/events.js b/test/modules/events.js index b5f4b89a..94e11da1 100644 --- a/test/modules/events.js +++ b/test/modules/events.js @@ -875,13 +875,10 @@ } var onOpen = function() { - var origClickSetting, - origDblClickSetting; - viewer.removeHandler('open', onOpen); - origClickSetting = viewer.gestureSettingsMouse.clickToZoom; - origDblClickSetting = viewer.gestureSettingsMouse.dblClickToZoom; + var origClickSetting = viewer.gestureSettingsMouse.clickToZoom; + var origDblClickSetting = viewer.gestureSettingsMouse.dblClickToZoom; viewer.gestureSettingsMouse.clickToZoom = false; viewer.gestureSettingsMouse.dblClickToZoom = true;