From 5eea11e2a527b3a3aab78b1f9d8685dc4d0b8762 Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Mon, 8 Mar 2021 15:42:12 -0800 Subject: [PATCH] Fixed simulated drag events in navigator tests --- changelog.txt | 1 + test/modules/navigator.js | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/changelog.txt b/changelog.txt index 8caee8c4..4e9ae9d0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -35,6 +35,7 @@ OPENSEADRAGON CHANGELOG * MouseTracker: Per #1863, dropped support for Internet Explorer < 11 (#1872 @msalsbery) * Dropped support for older browsers (IE < 11) (#1949 @msalsbery) * Removed deprecated OpenSeadragon.getEvent function (#1949 @msalsbery) +* Fixed simulated drag events in navigator tests (#1949 @msalsbery) 2.4.2: diff --git a/test/modules/navigator.js b/test/modules/navigator.js index d1f98dea..67bfbd43 100644 --- a/test/modules/navigator.js +++ b/test/modules/navigator.js @@ -222,13 +222,26 @@ }; var simulateNavigatorDrag = function (viewer, distanceX, distanceY) { - var $canvas = $(viewer.element).find('.displayregion'), - event = { - dx: Math.floor(distanceX), - dy: Math.floor(distanceY) - }; - $canvas - .simulate('drag', event); + var $canvas = $(viewer.element).find('.openseadragon-canvas'), + offset = $canvas.offset(), + event = {}; + + event.clientX = offset.left + 1; + event.clientY = offset.top + 1; + $canvas.simulate( 'mouseenter', event ); + + event.button = 0; + $canvas.simulate( 'mousedown', event ); + + event.clientX += distanceX; + event.clientY += distanceY; + $canvas.simulate( 'mousemove', event ); + + event.button = 0; + $canvas.simulate( 'mouseup', event ); + + event.relatedTarget = document.body; + $canvas.simulate( 'mouseleave', event ); }; var dragNavigatorBackToCenter = function () {