Added $.setElementTouchActionNone function

This commit is contained in:
Mark Salsbery 2014-08-05 16:57:54 -07:00
parent be13d25a26
commit e9b7634499
6 changed files with 21 additions and 31 deletions

View File

@ -137,11 +137,7 @@ $.Button = function( options ) {
this.tooltip; this.tooltip;
this.element.style.position = "relative"; this.element.style.position = "relative";
if ( typeof this.element.style.touchAction !== 'undefined' ) { $.setElementTouchActionNone( this.element );
this.element.style.touchAction = 'none';
} else if ( typeof this.element.style.msTouchAction !== 'undefined' ) {
this.element.style.msTouchAction = 'none';
}
this.imgGroup.style.position = this.imgGroup.style.position =
this.imgHover.style.position = this.imgHover.style.position =

View File

@ -80,11 +80,7 @@ $.ButtonGroup = function( options ) {
} }
} }
if ( typeof this.element.style.touchAction !== 'undefined' ) { $.setElementTouchActionNone( this.element );
this.element.style.touchAction = 'none';
} else if ( typeof this.element.style.msTouchAction !== 'undefined' ) {
this.element.style.msTouchAction = 'none';
}
/** /**
* Tracks mouse/touch/key events accross the group of buttons. * Tracks mouse/touch/key events accross the group of buttons.

View File

@ -112,11 +112,7 @@ $.Navigator = function( options ){
options.minPixelRatio = this.minPixelRatio = viewer.minPixelRatio; options.minPixelRatio = this.minPixelRatio = viewer.minPixelRatio;
if ( typeof this.element.style.touchAction !== 'undefined' ) { $.setElementTouchActionNone( this.element );
this.element.style.touchAction = 'none';
} else if ( typeof this.element.style.msTouchAction !== 'undefined' ) {
this.element.style.msTouchAction = 'none';
}
this.borderWidth = 2; this.borderWidth = 2;
//At some browser magnification levels the display regions lines up correctly, but at some there appears to //At some browser magnification levels the display regions lines up correctly, but at some there appears to

View File

@ -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. * Add the specified CSS class to the element if not present.
* @function * @function

View File

@ -114,11 +114,7 @@ $.ReferenceStrip = function ( options ) {
style.background = '#000'; style.background = '#000';
style.position = 'relative'; style.position = 'relative';
if ( typeof this.element.style.touchAction !== 'undefined' ) { $.setElementTouchActionNone( this.element );
this.element.style.touchAction = 'none';
} else if ( typeof this.element.style.msTouchAction !== 'undefined' ) {
this.element.style.msTouchAction = 'none';
}
$.setElementOpacity( this.element, 0.8 ); $.setElementOpacity( this.element, 0.8 );
@ -195,11 +191,7 @@ $.ReferenceStrip = function ( options ) {
element.style.cssFloat = 'left'; //Firefox element.style.cssFloat = 'left'; //Firefox
element.style.styleFloat = 'left'; //IE element.style.styleFloat = 'left'; //IE
element.style.padding = '2px'; element.style.padding = '2px';
if ( typeof element.style.touchAction !== 'undefined' ) { $.setElementTouchActionNone( element );
element.style.touchAction = 'none';
} else if ( typeof element.style.msTouchAction !== 'undefined' ) {
element.style.msTouchAction = 'none';
}
element.innerTracker = new $.MouseTracker( { element.innerTracker = new $.MouseTracker( {
element: element, element: element,

View File

@ -275,13 +275,8 @@ $.Viewer = function( options ) {
style.position = "absolute"; style.position = "absolute";
style.top = "0px"; style.top = "0px";
style.left = "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)); }(this.canvas.style));
$.setElementTouchActionNone( this.canvas );
//the container is created through applying the ControlDock constructor above //the container is created through applying the ControlDock constructor above
this.container.className = "openseadragon-container"; this.container.className = "openseadragon-container";