diff --git a/src/button.js b/src/button.js index 60eb450d..104955e0 100644 --- a/src/button.js +++ b/src/button.js @@ -137,11 +137,7 @@ $.Button = function( options ) { this.tooltip; this.element.style.position = "relative"; - if ( typeof this.element.style.touchAction !== 'undefined' ) { - this.element.style.touchAction = 'none'; - } else if ( typeof this.element.style.msTouchAction !== 'undefined' ) { - this.element.style.msTouchAction = 'none'; - } + $.setElementTouchActionNone( this.element ); this.imgGroup.style.position = this.imgHover.style.position = diff --git a/src/buttongroup.js b/src/buttongroup.js index 977d616a..2837805a 100644 --- a/src/buttongroup.js +++ b/src/buttongroup.js @@ -80,11 +80,7 @@ $.ButtonGroup = function( options ) { } } - if ( typeof this.element.style.touchAction !== 'undefined' ) { - this.element.style.touchAction = 'none'; - } else if ( typeof this.element.style.msTouchAction !== 'undefined' ) { - this.element.style.msTouchAction = 'none'; - } + $.setElementTouchActionNone( this.element ); /** * Tracks mouse/touch/key events accross the group of buttons. diff --git a/src/navigator.js b/src/navigator.js index 410f99b8..24d35a3d 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -112,11 +112,7 @@ $.Navigator = function( options ){ options.minPixelRatio = this.minPixelRatio = viewer.minPixelRatio; - if ( typeof this.element.style.touchAction !== 'undefined' ) { - this.element.style.touchAction = 'none'; - } else if ( typeof this.element.style.msTouchAction !== 'undefined' ) { - this.element.style.msTouchAction = 'none'; - } + $.setElementTouchActionNone( this.element ); this.borderWidth = 2; //At some browser magnification levels the display regions lines up correctly, but at some there appears to diff --git a/src/openseadragon.js b/src/openseadragon.js index e628ff88..5bccc84b 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -1585,6 +1585,21 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ }, + /** + * Sets the specified element's touch-action style attribute to 'none'. + * @function + * @param {Element|String} element + */ + setElementTouchActionNone: function( element ) { + element = $.getElement( element ); + if ( typeof element.style.touchAction !== 'undefined' ) { + element.style.touchAction = 'none'; + } else if ( typeof element.style.msTouchAction !== 'undefined' ) { + element.style.msTouchAction = 'none'; + } + }, + + /** * Add the specified CSS class to the element if not present. * @function diff --git a/src/referencestrip.js b/src/referencestrip.js index 6a70c634..f68744b2 100644 --- a/src/referencestrip.js +++ b/src/referencestrip.js @@ -114,11 +114,7 @@ $.ReferenceStrip = function ( options ) { style.background = '#000'; style.position = 'relative'; - if ( typeof this.element.style.touchAction !== 'undefined' ) { - this.element.style.touchAction = 'none'; - } else if ( typeof this.element.style.msTouchAction !== 'undefined' ) { - this.element.style.msTouchAction = 'none'; - } + $.setElementTouchActionNone( this.element ); $.setElementOpacity( this.element, 0.8 ); @@ -195,11 +191,7 @@ $.ReferenceStrip = function ( options ) { element.style.cssFloat = 'left'; //Firefox element.style.styleFloat = 'left'; //IE element.style.padding = '2px'; - if ( typeof element.style.touchAction !== 'undefined' ) { - element.style.touchAction = 'none'; - } else if ( typeof element.style.msTouchAction !== 'undefined' ) { - element.style.msTouchAction = 'none'; - } + $.setElementTouchActionNone( element ); element.innerTracker = new $.MouseTracker( { element: element, diff --git a/src/viewer.js b/src/viewer.js index 6558480b..46d6a527 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -275,13 +275,8 @@ $.Viewer = function( options ) { style.position = "absolute"; style.top = "0px"; style.left = "0px"; - // Disable browser default touch handling - if ( typeof style.touchAction !== 'undefined' ) { - style.touchAction = 'none'; - } else if ( typeof style.msTouchAction !== 'undefined' ) { - style.msTouchAction = 'none'; - } }(this.canvas.style)); + $.setElementTouchActionNone( this.canvas ); //the container is created through applying the ControlDock constructor above this.container.className = "openseadragon-container";