From 6fa083d2e06066a877db23b329ec91bab774a62c Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Mon, 8 Mar 2021 13:33:05 -0800 Subject: [PATCH 1/5] Remove support for IE < 11 (#1863) --- changelog.txt | 2 + src/openseadragon.js | 161 +++--------------------------- test/helpers/legacy.mouse.shim.js | 12 +-- 3 files changed, 16 insertions(+), 159 deletions(-) diff --git a/changelog.txt b/changelog.txt index 0044fb07..d99b4d73 100644 --- a/changelog.txt +++ b/changelog.txt @@ -33,6 +33,8 @@ OPENSEADRAGON CHANGELOG * Viewer: added a canvas-contextmenu event (#1872 @msalsbery) * Added additional documentation for the zoomPerSecond viewer option (#1872 @msalsbery) * MouseTracker: Per #1863, dropped support for Internet Explorer < 11 (#1872 @msalsbery) +* Dropped support for older browsers (IE < 11) +* Removed deprecated OpenSeadragon.getEvent function 2.4.2: diff --git a/src/openseadragon.js b/src/openseadragon.js index 86320fdb..1f7fbe60 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -1577,29 +1577,6 @@ function OpenSeadragon( options ){ }, - /** - * Gets the latest event, really only useful internally since its - * specific to IE behavior. - * @function - * @param {Event} [event] - * @returns {Event} - * @deprecated For internal use only - * @private - */ - getEvent: function( event ) { - if( event ){ - $.getEvent = function( event ) { - return event; - }; - } else { - $.getEvent = function() { - return window.event; - }; - } - return $.getEvent( event ); - }, - - /** * Gets the position of the mouse on the screen for a given event. * @function @@ -1612,7 +1589,6 @@ function OpenSeadragon( options ){ $.getMousePosition = function( event ){ var result = new $.Point(); - event = $.getEvent( event ); result.x = event.pageX; result.y = event.pageY; @@ -1622,7 +1598,6 @@ function OpenSeadragon( options ){ $.getMousePosition = function( event ){ var result = new $.Point(); - event = $.getEvent( event ); result.x = event.clientX + document.body.scrollLeft + @@ -1858,51 +1833,16 @@ function OpenSeadragon( options ){ /** * Ensures an image is loaded correctly to support alpha transparency. - * Generally only IE has issues doing this correctly for formats like - * png. * @function * @param {String} src * @returns {Element} */ makeTransparentImage: function( src ) { + var img = $.makeNeutralElement( "img" ); - $.makeTransparentImage = function( src ){ - var img = $.makeNeutralElement( "img" ); + img.src = src; - img.src = src; - - return img; - }; - - if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 7 ) { - - $.makeTransparentImage = function( src ){ - var img = $.makeNeutralElement( "img" ), - element = null; - - element = $.makeNeutralElement("span"); - element.style.display = "inline-block"; - - img.onload = function() { - element.style.width = element.style.width || img.width + "px"; - element.style.height = element.style.height || img.height + "px"; - - img.onload = null; - img = null; // to prevent memory leaks in IE - }; - - img.src = src; - element.style.filter = - "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + - src + - "', sizingMethod='scale')"; - - return element; - }; - - } - - return $.makeTransparentImage( src ); + return img; }, @@ -2144,23 +2084,7 @@ function OpenSeadragon( options ){ * @param {Event} [event] */ cancelEvent: function( event ) { - event = $.getEvent( event ); - - if ( event.preventDefault ) { - $.cancelEvent = function( event ){ - // W3C for preventing default - event.preventDefault(); - }; - } else { - $.cancelEvent = function( event ){ - event = $.getEvent( event ); - // legacy for preventing default - event.cancel = true; - // IE < 9 for preventing default - event.returnValue = false; - }; - } - $.cancelEvent( event ); + event.preventDefault(); }, @@ -2171,28 +2095,7 @@ function OpenSeadragon( options ){ * @param {Event} [event] */ eventIsCanceled: function( event ) { - event = $.getEvent( event ); - - if ( event.preventDefault ) { - $.eventIsCanceled = function( event ){ - // W3C - return event.defaultPrevented; - }; - } else { - $.eventIsCanceled = function( event ){ - event = $.getEvent( event ); - if ( typeof event.returnValue !== 'undefined' ) { - // IE < 9 - return !event.returnValue; - } else if ( typeof event.cancel !== 'undefined' ) { - // legacy - return event.cancel; - } else { - return false; - } - }; - } - return $.eventIsCanceled( event ); + return event.defaultPrevented; }, @@ -2202,23 +2105,7 @@ function OpenSeadragon( options ){ * @param {Event} [event] */ stopEvent: function( event ) { - event = $.getEvent( event ); - - if ( event.stopPropagation ) { - // W3C for stopping propagation - $.stopEvent = function( event ){ - event.stopPropagation(); - }; - } else { - // IE < 9 for stopping propagation - $.stopEvent = function( event ){ - event = $.getEvent( event ); - event.cancelBubble = true; - }; - - } - - $.stopEvent( event ); + event.stopPropagation(); }, @@ -2407,25 +2294,7 @@ function OpenSeadragon( options ){ request.send(null); } catch (e) { - var msg = e.message; - - /* - IE < 10 does not support CORS and an XHR request to a different origin will fail as soon - as send() is called. This is particularly easy to miss during development and appear in - production if you use a CDN or domain sharding and the security policy is likely to break - exception handlers since any attempt to access a property of the request object will - raise an access denied TypeError inside the catch block. - - To be friendlier, we'll check for this specific error and add a documentation pointer - to point developers in the right direction. We test the exception number because IE's - error messages are localized. - */ - var oldIE = $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 10; - if ( oldIE && typeof ( e.number ) !== "undefined" && e.number === -2147024891 ) { - msg += "\nSee http://msdn.microsoft.com/en-us/library/ms537505(v=vs.85).aspx#xdomain"; - } - - $.console.log( "%s while making AJAX request: %s", e.name, msg ); + $.console.log( "%s while making AJAX request: %s", e.name, e.message ); request.onreadystatechange = function(){}; @@ -2772,21 +2641,15 @@ function OpenSeadragon( options ){ //determine if this browser supports image alpha transparency $.Browser.alpha = !( - ( - $.Browser.vendor === $.BROWSERS.IE && - $.Browser.version < 9 - ) || ( - $.Browser.vendor === $.BROWSERS.CHROME && - $.Browser.version < 2 - ) + $.Browser.vendor === $.BROWSERS.CHROME && $.Browser.version < 2 ); //determine if this browser supports element.style.opacity - $.Browser.opacity = !( - $.Browser.vendor === $.BROWSERS.IE && - $.Browser.version < 9 - ); + $.Browser.opacity = true; + if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 11 ) { + $.console.error('Internet Explorer versions < 11 are not supported by OpenSeadragon'); + } })(); diff --git a/test/helpers/legacy.mouse.shim.js b/test/helpers/legacy.mouse.shim.js index e4740138..19374147 100644 --- a/test/helpers/legacy.mouse.shim.js +++ b/test/helpers/legacy.mouse.shim.js @@ -6,21 +6,13 @@ $.MouseTracker.subscribeEvents = [ "click", "dblclick", "keypress", "focus", "blur", $.MouseTracker.wheelEventName ]; - if( $.MouseTracker.wheelEventName == "DOMMouseScroll" ) { + if( $.MouseTracker.wheelEventName === "DOMMouseScroll" ) { // Older Firefox $.MouseTracker.subscribeEvents.push( "MozMousePixelScroll" ); } $.MouseTracker.havePointerEvents = false; - $.MouseTracker.unprefixedPointerEvents = true; - $.MouseTracker.subscribeEvents.push( "mouseenter", "mouseleave" ); - if ( $.Browser.vendor !== $.BROWSERS.IE || $.Browser.version > 8 ) { - $.MouseTracker.subscribeEvents.push( "mouseover", "mouseout" ); - $.MouseTracker.havePointerOverOut = true; - } else { - $.MouseTracker.havePointerOverOut = false; - } - $.MouseTracker.subscribeEvents.push( "mousedown", "mouseup", "mousemove" ); + $.MouseTracker.subscribeEvents.push( "mouseenter", "mouseleave", "mouseover", "mouseout", "mousedown", "mouseup", "mousemove" ); $.MouseTracker.mousePointerId = "legacy-mouse"; // Legacy mouse events capture support (IE/Firefox only?) $.MouseTracker.havePointerCapture = (function () { From a520da0d559d6446b0fc8fb21c59e52dcca08fbc Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Mon, 8 Mar 2021 13:35:27 -0800 Subject: [PATCH 2/5] Changelog update --- changelog.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index d99b4d73..8caee8c4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -33,8 +33,8 @@ OPENSEADRAGON CHANGELOG * Viewer: added a canvas-contextmenu event (#1872 @msalsbery) * Added additional documentation for the zoomPerSecond viewer option (#1872 @msalsbery) * MouseTracker: Per #1863, dropped support for Internet Explorer < 11 (#1872 @msalsbery) -* Dropped support for older browsers (IE < 11) -* Removed deprecated OpenSeadragon.getEvent function +* Dropped support for older browsers (IE < 11) (#1949 @msalsbery) +* Removed deprecated OpenSeadragon.getEvent function (#1949 @msalsbery) 2.4.2: From 5eea11e2a527b3a3aab78b1f9d8685dc4d0b8762 Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Mon, 8 Mar 2021 15:42:12 -0800 Subject: [PATCH 3/5] 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 () { From 4f94de0ef6038a3a61a53a2f2ccb2a49fbda3281 Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Mon, 8 Mar 2021 16:10:15 -0800 Subject: [PATCH 4/5] Changelog update --- changelog.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 4e9ae9d0..1c325eba 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,8 @@ OPENSEADRAGON CHANGELOG 2.5.0: (In progress) +* BREAKING CHANGE: Dropped support for older browsers (IE < 11) (#1949 @msalsbery) +* BREAKING CHANGE: Removed deprecated OpenSeadragon.getEvent function (#1949 @msalsbery) * DEPRECATION: MouseTracker exitHandler deprecated for name change to leaveHandler for consistency with DOM event names (#1872 @msalsbery) * Now when "simple image" tile sources are removed from the viewer, they free the memory used by the pyramid they create (#1789 @TakumaKira) * Documentation fix (#1814 @kenanchristian) @@ -33,8 +35,6 @@ OPENSEADRAGON CHANGELOG * Viewer: added a canvas-contextmenu event (#1872 @msalsbery) * Added additional documentation for the zoomPerSecond viewer option (#1872 @msalsbery) * 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: From bf0b7842cac6a1fd2d30caa33c3ee07005686cce Mon Sep 17 00:00:00 2001 From: Mark Salsbery <> Date: Tue, 9 Mar 2021 11:22:34 -0800 Subject: [PATCH 5/5] Sane pointer coords for navigator tests drag simulations --- test/modules/navigator.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/modules/navigator.js b/test/modules/navigator.js index 67bfbd43..e55c5400 100644 --- a/test/modules/navigator.js +++ b/test/modules/navigator.js @@ -240,6 +240,8 @@ event.button = 0; $canvas.simulate( 'mouseup', event ); + event.clientX = offset.left - 1; + event.clientY = offset.top - 1; event.relatedTarget = document.body; $canvas.simulate( 'mouseleave', event ); };