mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
MouseTracker Improvements
* Exposed secondary pointer button (middle, right, etc.) events from MouseTracker and through viewer (#479) * MouseTracker - Improved IE 8 compatibility
This commit is contained in:
parent
8ff70dd54f
commit
30b5ec04c6
@ -3,6 +3,9 @@ OPENSEADRAGON CHANGELOG
|
|||||||
|
|
||||||
1.2.1: (in progress)
|
1.2.1: (in progress)
|
||||||
|
|
||||||
|
* Exposed secondary pointer button (middle, right, etc.) events from MouseTracker and through viewer (#479)
|
||||||
|
* MouseTracker - Improved IE 8 compatibility
|
||||||
|
|
||||||
1.2.0:
|
1.2.0:
|
||||||
|
|
||||||
* New combined IIIF TileSource for 1.0 through 2.0 (#441)
|
* New combined IIIF TileSource for 1.0 through 2.0 (#441)
|
||||||
|
@ -72,8 +72,12 @@
|
|||||||
* An optional handler for pointer exit.
|
* An optional handler for pointer exit.
|
||||||
* @param {OpenSeadragon.EventHandler} [options.pressHandler=null]
|
* @param {OpenSeadragon.EventHandler} [options.pressHandler=null]
|
||||||
* An optional handler for pointer press.
|
* An optional handler for pointer press.
|
||||||
|
* @param {OpenSeadragon.EventHandler} [options.auxPressHandler=null]
|
||||||
|
* An optional handler for pointer non-primary button press.
|
||||||
* @param {OpenSeadragon.EventHandler} [options.releaseHandler=null]
|
* @param {OpenSeadragon.EventHandler} [options.releaseHandler=null]
|
||||||
* An optional handler for pointer release.
|
* An optional handler for pointer release.
|
||||||
|
* @param {OpenSeadragon.EventHandler} [options.auxReleaseHandler=null]
|
||||||
|
* An optional handler for pointer non-primary button release.
|
||||||
* @param {OpenSeadragon.EventHandler} [options.moveHandler=null]
|
* @param {OpenSeadragon.EventHandler} [options.moveHandler=null]
|
||||||
* An optional handler for pointer move.
|
* An optional handler for pointer move.
|
||||||
* @param {OpenSeadragon.EventHandler} [options.scrollHandler=null]
|
* @param {OpenSeadragon.EventHandler} [options.scrollHandler=null]
|
||||||
@ -144,24 +148,26 @@
|
|||||||
* @memberof OpenSeadragon.MouseTracker#
|
* @memberof OpenSeadragon.MouseTracker#
|
||||||
*/
|
*/
|
||||||
this.dblClickDistThreshold = options.dblClickDistThreshold || $.DEFAULT_SETTINGS.dblClickDistThreshold;
|
this.dblClickDistThreshold = options.dblClickDistThreshold || $.DEFAULT_SETTINGS.dblClickDistThreshold;
|
||||||
this.userData = options.userData || null;
|
this.userData = options.userData || null;
|
||||||
this.stopDelay = options.stopDelay || 50;
|
this.stopDelay = options.stopDelay || 50;
|
||||||
|
|
||||||
this.enterHandler = options.enterHandler || null;
|
this.enterHandler = options.enterHandler || null;
|
||||||
this.exitHandler = options.exitHandler || null;
|
this.exitHandler = options.exitHandler || null;
|
||||||
this.pressHandler = options.pressHandler || null;
|
this.pressHandler = options.pressHandler || null;
|
||||||
this.releaseHandler = options.releaseHandler || null;
|
this.auxPressHandler = options.auxPressHandler || null;
|
||||||
this.moveHandler = options.moveHandler || null;
|
this.releaseHandler = options.releaseHandler || null;
|
||||||
this.scrollHandler = options.scrollHandler || null;
|
this.auxReleaseHandler = options.auxReleaseHandler || null;
|
||||||
this.clickHandler = options.clickHandler || null;
|
this.moveHandler = options.moveHandler || null;
|
||||||
this.dblClickHandler = options.dblClickHandler || null;
|
this.scrollHandler = options.scrollHandler || null;
|
||||||
this.dragHandler = options.dragHandler || null;
|
this.clickHandler = options.clickHandler || null;
|
||||||
this.dragEndHandler = options.dragEndHandler || null;
|
this.dblClickHandler = options.dblClickHandler || null;
|
||||||
this.pinchHandler = options.pinchHandler || null;
|
this.dragHandler = options.dragHandler || null;
|
||||||
this.stopHandler = options.stopHandler || null;
|
this.dragEndHandler = options.dragEndHandler || null;
|
||||||
this.keyHandler = options.keyHandler || null;
|
this.pinchHandler = options.pinchHandler || null;
|
||||||
this.focusHandler = options.focusHandler || null;
|
this.stopHandler = options.stopHandler || null;
|
||||||
this.blurHandler = options.blurHandler || null;
|
this.keyHandler = options.keyHandler || null;
|
||||||
|
this.focusHandler = options.focusHandler || null;
|
||||||
|
this.blurHandler = options.blurHandler || null;
|
||||||
|
|
||||||
//Store private properties in a scope sealed hash map
|
//Store private properties in a scope sealed hash map
|
||||||
var _this = this;
|
var _this = this;
|
||||||
@ -183,6 +189,8 @@
|
|||||||
DOMMouseScroll: function ( event ) { onMouseWheel( _this, event ); },
|
DOMMouseScroll: function ( event ) { onMouseWheel( _this, event ); },
|
||||||
MozMousePixelScroll: function ( event ) { onMouseWheel( _this, event ); },
|
MozMousePixelScroll: function ( event ) { onMouseWheel( _this, event ); },
|
||||||
|
|
||||||
|
mouseenter: function ( event ) { onMouseEnter( _this, event ); }, // Used on IE8 only
|
||||||
|
mouseleave: function ( event ) { onMouseLeave( _this, event ); }, // Used on IE8 only
|
||||||
mouseover: function ( event ) { onMouseOver( _this, event ); },
|
mouseover: function ( event ) { onMouseOver( _this, event ); },
|
||||||
mouseout: function ( event ) { onMouseOut( _this, event ); },
|
mouseout: function ( event ) { onMouseOut( _this, event ); },
|
||||||
mousedown: function ( event ) { onMouseDown( _this, event ); },
|
mousedown: function ( event ) { onMouseDown( _this, event ); },
|
||||||
@ -390,6 +398,34 @@
|
|||||||
*/
|
*/
|
||||||
pressHandler: function () { },
|
pressHandler: function () { },
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement or assign implementation to these handlers during or after
|
||||||
|
* calling the constructor.
|
||||||
|
* @function
|
||||||
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
|
* A reference to the tracker instance.
|
||||||
|
* @param {String} event.pointerType
|
||||||
|
* "mouse", "touch", "pen", etc.
|
||||||
|
* @param {OpenSeadragon.Point} event.position
|
||||||
|
* The position of the event relative to the tracked element.
|
||||||
|
* @param {Number} event.button
|
||||||
|
* Button which caused the event.
|
||||||
|
* -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
||||||
|
* @param {Number} event.buttons
|
||||||
|
* Current buttons pressed.
|
||||||
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
||||||
|
* @param {Boolean} event.isTouchEvent
|
||||||
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
||||||
|
* @param {Object} event.originalEvent
|
||||||
|
* The original event object.
|
||||||
|
* @param {Boolean} event.preventDefaultAction
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
||||||
|
* @param {Object} event.userData
|
||||||
|
* Arbitrary user-defined object.
|
||||||
|
*/
|
||||||
|
auxPressHandler: function () { },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement or assign implementation to these handlers during or after
|
* Implement or assign implementation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
@ -420,6 +456,34 @@
|
|||||||
*/
|
*/
|
||||||
releaseHandler: function () { },
|
releaseHandler: function () { },
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement or assign implementation to these handlers during or after
|
||||||
|
* calling the constructor.
|
||||||
|
* @function
|
||||||
|
* @param {Object} event
|
||||||
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
||||||
|
* A reference to the tracker instance.
|
||||||
|
* @param {String} event.pointerType
|
||||||
|
* "mouse", "touch", "pen", etc.
|
||||||
|
* @param {OpenSeadragon.Point} event.position
|
||||||
|
* The position of the event relative to the tracked element.
|
||||||
|
* @param {Number} event.button
|
||||||
|
* Button which caused the event.
|
||||||
|
* -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
||||||
|
* @param {Number} event.buttons
|
||||||
|
* Current buttons pressed.
|
||||||
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
||||||
|
* @param {Boolean} event.isTouchEvent
|
||||||
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
||||||
|
* @param {Object} event.originalEvent
|
||||||
|
* The original event object.
|
||||||
|
* @param {Boolean} event.preventDefaultAction
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
||||||
|
* @param {Object} event.userData
|
||||||
|
* Arbitrary user-defined object.
|
||||||
|
*/
|
||||||
|
auxReleaseHandler: function () { },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement or assign implementation to these handlers during or after
|
* Implement or assign implementation to these handlers during or after
|
||||||
* calling the constructor.
|
* calling the constructor.
|
||||||
@ -838,8 +902,14 @@
|
|||||||
$.MouseTracker.haveMouseEnter = false;
|
$.MouseTracker.haveMouseEnter = false;
|
||||||
} else {
|
} else {
|
||||||
// Legacy W3C mouse events
|
// Legacy W3C mouse events
|
||||||
$.MouseTracker.subscribeEvents.push( "mouseover", "mouseout", "mousedown", "mouseup", "mousemove" );
|
if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 9 ) {
|
||||||
$.MouseTracker.haveMouseEnter = false;
|
$.MouseTracker.subscribeEvents.push( "mouseenter", "mouseleave" );
|
||||||
|
$.MouseTracker.haveMouseEnter = true;
|
||||||
|
} else {
|
||||||
|
$.MouseTracker.subscribeEvents.push( "mouseover", "mouseout" );
|
||||||
|
$.MouseTracker.haveMouseEnter = false;
|
||||||
|
}
|
||||||
|
$.MouseTracker.subscribeEvents.push( "mousedown", "mouseup", "mousemove" );
|
||||||
if ( 'ontouchstart' in window ) {
|
if ( 'ontouchstart' in window ) {
|
||||||
// iOS, Android, and other W3c Touch Event implementations (see http://www.w3.org/TR/2011/WD-touch-events-20110505)
|
// iOS, Android, and other W3c Touch Event implementations (see http://www.w3.org/TR/2011/WD-touch-events-20110505)
|
||||||
$.MouseTracker.subscribeEvents.push( "touchstart", "touchend", "touchmove", "touchcancel" );
|
$.MouseTracker.subscribeEvents.push( "touchstart", "touchend", "touchmove", "touchcancel" );
|
||||||
@ -1181,27 +1251,31 @@
|
|||||||
* @inner
|
* @inner
|
||||||
*/
|
*/
|
||||||
function capturePointer( tracker, pointerType ) {
|
function capturePointer( tracker, pointerType ) {
|
||||||
var delegate = THIS[ tracker.hash ],
|
var pointsList = tracker.getActivePointersListByType( pointerType ),
|
||||||
pointsList = tracker.getActivePointersListByType( pointerType ),
|
eventParams;
|
||||||
eventParams = getCaptureEventParams( tracker, pointerType );
|
|
||||||
|
|
||||||
pointsList.captureCount++;
|
pointsList.captureCount++;
|
||||||
|
|
||||||
if ( pointsList.captureCount === 1 ) {
|
if ( pointsList.captureCount === 1 ) {
|
||||||
// We emulate mouse capture by hanging listeners on the window object.
|
if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 9 ) {
|
||||||
// (Note we listen on the capture phase so the captured handlers will get called first)
|
tracker.element.setCapture( true );
|
||||||
$.addEvent(
|
} else {
|
||||||
$.MouseTracker.captureElement,
|
eventParams = getCaptureEventParams( tracker, pointerType );
|
||||||
eventParams.upName,
|
// We emulate mouse capture by hanging listeners on the document object.
|
||||||
eventParams.upHandler,
|
// (Note we listen on the capture phase so the captured handlers will get called first)
|
||||||
true
|
$.addEvent(
|
||||||
);
|
$.MouseTracker.captureElement,
|
||||||
$.addEvent(
|
eventParams.upName,
|
||||||
$.MouseTracker.captureElement,
|
eventParams.upHandler,
|
||||||
eventParams.moveName,
|
true
|
||||||
eventParams.moveHandler,
|
);
|
||||||
true
|
$.addEvent(
|
||||||
);
|
$.MouseTracker.captureElement,
|
||||||
|
eventParams.moveName,
|
||||||
|
eventParams.moveHandler,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1212,27 +1286,31 @@
|
|||||||
* @inner
|
* @inner
|
||||||
*/
|
*/
|
||||||
function releasePointer( tracker, pointerType ) {
|
function releasePointer( tracker, pointerType ) {
|
||||||
var delegate = THIS[ tracker.hash ],
|
var pointsList = tracker.getActivePointersListByType( pointerType ),
|
||||||
pointsList = tracker.getActivePointersListByType( pointerType ),
|
eventParams;
|
||||||
eventParams = getCaptureEventParams( tracker, pointerType );
|
|
||||||
|
|
||||||
pointsList.captureCount--;
|
pointsList.captureCount--;
|
||||||
|
|
||||||
if ( pointsList.captureCount === 0 ) {
|
if ( pointsList.captureCount === 0 ) {
|
||||||
// We emulate mouse capture by hanging listeners on the window object.
|
if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 9 ) {
|
||||||
// (Note we listen on the capture phase so the captured handlers will get called first)
|
tracker.element.releaseCapture();
|
||||||
$.removeEvent(
|
} else {
|
||||||
$.MouseTracker.captureElement,
|
eventParams = getCaptureEventParams( tracker, pointerType );
|
||||||
eventParams.moveName,
|
// We emulate mouse capture by hanging listeners on the document object.
|
||||||
eventParams.moveHandler,
|
// (Note we listen on the capture phase so the captured handlers will get called first)
|
||||||
true
|
$.removeEvent(
|
||||||
);
|
$.MouseTracker.captureElement,
|
||||||
$.removeEvent(
|
eventParams.moveName,
|
||||||
$.MouseTracker.captureElement,
|
eventParams.moveHandler,
|
||||||
eventParams.upName,
|
true
|
||||||
eventParams.upHandler,
|
);
|
||||||
true
|
$.removeEvent(
|
||||||
);
|
$.MouseTracker.captureElement,
|
||||||
|
eventParams.upName,
|
||||||
|
eventParams.upHandler,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1506,20 +1584,40 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only used on IE 8
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
*/
|
||||||
|
function onMouseEnter( tracker, event ) {
|
||||||
|
event = $.getEvent( event );
|
||||||
|
|
||||||
|
handleMouseEnter( tracker, event );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @inner
|
* @inner
|
||||||
*/
|
*/
|
||||||
function onMouseOver( tracker, event ) {
|
function onMouseOver( tracker, event ) {
|
||||||
var gPoint;
|
|
||||||
|
|
||||||
event = $.getEvent( event );
|
event = $.getEvent( event );
|
||||||
|
|
||||||
if ( this === event.relatedTarget || isParentChild( event.currentTarget, event.relatedTarget ) ) {
|
if ( this === event.relatedTarget || isParentChild( event.currentTarget, event.relatedTarget ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gPoint = {
|
handleMouseEnter( tracker, event );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
*/
|
||||||
|
function handleMouseEnter( tracker, event ) {
|
||||||
|
var gPoint = {
|
||||||
id: $.MouseTracker.mousePointerId,
|
id: $.MouseTracker.mousePointerId,
|
||||||
type: 'mouse',
|
type: 'mouse',
|
||||||
isPrimary: true,
|
isPrimary: true,
|
||||||
@ -1531,20 +1629,40 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only used on IE 8
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
*/
|
||||||
|
function onMouseLeave( tracker, event ) {
|
||||||
|
event = $.getEvent( event );
|
||||||
|
|
||||||
|
handleMouseExit( tracker, event );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @inner
|
* @inner
|
||||||
*/
|
*/
|
||||||
function onMouseOut( tracker, event ) {
|
function onMouseOut( tracker, event ) {
|
||||||
var gPoint;
|
|
||||||
|
|
||||||
event = $.getEvent( event );
|
event = $.getEvent( event );
|
||||||
|
|
||||||
if ( this === event.relatedTarget || isParentChild( event.currentTarget, event.relatedTarget ) ) {
|
if ( this === event.relatedTarget || isParentChild( event.currentTarget, event.relatedTarget ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gPoint = {
|
handleMouseExit( tracker, event );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
*/
|
||||||
|
function handleMouseExit( tracker, event ) {
|
||||||
|
var gPoint = {
|
||||||
id: $.MouseTracker.mousePointerId,
|
id: $.MouseTracker.mousePointerId,
|
||||||
type: 'mouse',
|
type: 'mouse',
|
||||||
isPrimary: true,
|
isPrimary: true,
|
||||||
@ -1556,6 +1674,31 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a W3C DOM level 3 standard button value given an event.button property:
|
||||||
|
* -1 == none, 0 == primary/left, 1 == middle, 2 == secondary/right, 3 == X1/back, 4 == X2/forward, 5 == eraser (pen)
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
*/
|
||||||
|
function getStandardizedButton( button ) {
|
||||||
|
if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 9 ) {
|
||||||
|
// On IE 8, 0 == none, 1 == left, 2 == right, 3 == left and right, 4 == middle, 5 == left and middle, 6 == right and middle, 7 == all three
|
||||||
|
// TODO: Support chorded (multiple) button presses on IE 8?
|
||||||
|
if ( button === 1 ) {
|
||||||
|
return 0;
|
||||||
|
} else if ( button === 2 ) {
|
||||||
|
return 2;
|
||||||
|
} else if ( button === 4 ) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @inner
|
* @inner
|
||||||
@ -1573,7 +1716,7 @@
|
|||||||
currentTime: $.now()
|
currentTime: $.now()
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( updatePointersDown( tracker, event, [ gPoint ], event.button ) ) {
|
if ( updatePointersDown( tracker, event, [ gPoint ], getStandardizedButton( event.button ) ) ) {
|
||||||
$.stopEvent( event );
|
$.stopEvent( event );
|
||||||
capturePointer( tracker, 'mouse' );
|
capturePointer( tracker, 'mouse' );
|
||||||
}
|
}
|
||||||
@ -1622,11 +1765,12 @@
|
|||||||
currentTime: $.now()
|
currentTime: $.now()
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( updatePointersUp( tracker, event, [ gPoint ], event.button ) ) {
|
if ( updatePointersUp( tracker, event, [ gPoint ], getStandardizedButton( event.button ) ) ) {
|
||||||
releasePointer( tracker, 'mouse' );
|
releasePointer( tracker, 'mouse' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @inner
|
* @inner
|
||||||
@ -2286,7 +2430,7 @@
|
|||||||
* @param {Array.<OpenSeadragon.MouseTracker.GesturePoint>} gPoints
|
* @param {Array.<OpenSeadragon.MouseTracker.GesturePoint>} gPoints
|
||||||
* Gesture points associated with the event.
|
* Gesture points associated with the event.
|
||||||
* @param {Number} buttonChanged
|
* @param {Number} buttonChanged
|
||||||
* The button involved in the event: -1: none, 0: primary, 1: aux, 2: secondary, 3: X1, 4: X2, 5: pen eraser.
|
* The button involved in the event: -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
||||||
* Note on chorded button presses (a button pressed when another button is already pressed): In the W3C Pointer Events model,
|
* Note on chorded button presses (a button pressed when another button is already pressed): In the W3C Pointer Events model,
|
||||||
* only one pointerdown/pointerup event combo is fired. Chorded button state changes instead fire pointermove events.
|
* only one pointerdown/pointerup event combo is fired. Chorded button state changes instead fire pointermove events.
|
||||||
*
|
*
|
||||||
@ -2304,30 +2448,71 @@
|
|||||||
if ( typeof event.buttons !== 'undefined' ) {
|
if ( typeof event.buttons !== 'undefined' ) {
|
||||||
pointsList.buttons = event.buttons;
|
pointsList.buttons = event.buttons;
|
||||||
} else {
|
} else {
|
||||||
if ( buttonChanged === 0 ) {
|
if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 9 ) {
|
||||||
// Primary
|
if ( buttonChanged === 0 ) {
|
||||||
pointsList.buttons |= 1;
|
// Primary
|
||||||
} else if ( buttonChanged === 1 ) {
|
pointsList.buttons += 1;
|
||||||
// Aux
|
} else if ( buttonChanged === 1 ) {
|
||||||
pointsList.buttons |= 4;
|
// Aux
|
||||||
} else if ( buttonChanged === 2 ) {
|
pointsList.buttons += 4;
|
||||||
// Secondary
|
} else if ( buttonChanged === 2 ) {
|
||||||
pointsList.buttons |= 2;
|
// Secondary
|
||||||
} else if ( buttonChanged === 3 ) {
|
pointsList.buttons += 2;
|
||||||
// X1 (Back)
|
} else if ( buttonChanged === 3 ) {
|
||||||
pointsList.buttons |= 8;
|
// X1 (Back)
|
||||||
} else if ( buttonChanged === 4 ) {
|
pointsList.buttons += 8;
|
||||||
// X2 (Forward)
|
} else if ( buttonChanged === 4 ) {
|
||||||
pointsList.buttons |= 16;
|
// X2 (Forward)
|
||||||
} else if ( buttonChanged === 5 ) {
|
pointsList.buttons += 16;
|
||||||
// Pen Eraser
|
} else if ( buttonChanged === 5 ) {
|
||||||
pointsList.buttons |= 32;
|
// Pen Eraser
|
||||||
|
pointsList.buttons += 32;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( buttonChanged === 0 ) {
|
||||||
|
// Primary
|
||||||
|
pointsList.buttons |= 1;
|
||||||
|
} else if ( buttonChanged === 1 ) {
|
||||||
|
// Aux
|
||||||
|
pointsList.buttons |= 4;
|
||||||
|
} else if ( buttonChanged === 2 ) {
|
||||||
|
// Secondary
|
||||||
|
pointsList.buttons |= 2;
|
||||||
|
} else if ( buttonChanged === 3 ) {
|
||||||
|
// X1 (Back)
|
||||||
|
pointsList.buttons |= 8;
|
||||||
|
} else if ( buttonChanged === 4 ) {
|
||||||
|
// X2 (Forward)
|
||||||
|
pointsList.buttons |= 16;
|
||||||
|
} else if ( buttonChanged === 5 ) {
|
||||||
|
// Pen Eraser
|
||||||
|
pointsList.buttons |= 32;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only capture and track primary button, pen, and touch contacts
|
// Only capture and track primary button, pen, and touch contacts
|
||||||
//if ( buttonChanged !== 0 ) {
|
if ( buttonChanged !== 0 ) {
|
||||||
if ( buttonChanged !== 0 && buttonChanged !== 1 ) { //TODO Remove this IE8 compatibility and use the commented line above
|
// Aux Press
|
||||||
|
if ( tracker.auxPressHandler ) {
|
||||||
|
propagate = tracker.auxPressHandler(
|
||||||
|
{
|
||||||
|
eventSource: tracker,
|
||||||
|
pointerType: gPoints[ 0 ].type,
|
||||||
|
position: getPointRelativeToAbsolute( gPoints[ 0 ].currentPos, tracker.element ),
|
||||||
|
button: buttonChanged,
|
||||||
|
buttons: pointsList.buttons,
|
||||||
|
isTouchEvent: gPoints[ 0 ].type === 'touch',
|
||||||
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
|
userData: tracker.userData
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if ( propagate === false ) {
|
||||||
|
$.cancelEvent( event );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2407,7 +2592,7 @@
|
|||||||
* @param {Array.<OpenSeadragon.MouseTracker.GesturePoint>} gPoints
|
* @param {Array.<OpenSeadragon.MouseTracker.GesturePoint>} gPoints
|
||||||
* Gesture points associated with the event.
|
* Gesture points associated with the event.
|
||||||
* @param {Number} buttonChanged
|
* @param {Number} buttonChanged
|
||||||
* The button involved in the event: -1: none, 0: primary, 1: aux, 2: secondary, 3: X1, 4: X2, 5: pen eraser.
|
* The button involved in the event: -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
||||||
* Note on chorded button presses (a button pressed when another button is already pressed): In the W3C Pointer Events model,
|
* Note on chorded button presses (a button pressed when another button is already pressed): In the W3C Pointer Events model,
|
||||||
* only one pointerdown/pointerup event combo is fired. Chorded button state changes instead fire pointermove events.
|
* only one pointerdown/pointerup event combo is fired. Chorded button state changes instead fire pointermove events.
|
||||||
*
|
*
|
||||||
@ -2431,30 +2616,71 @@
|
|||||||
if ( typeof event.buttons !== 'undefined' ) {
|
if ( typeof event.buttons !== 'undefined' ) {
|
||||||
pointsList.buttons = event.buttons;
|
pointsList.buttons = event.buttons;
|
||||||
} else {
|
} else {
|
||||||
if ( buttonChanged === 0 ) {
|
if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 9 ) {
|
||||||
// Primary
|
if ( buttonChanged === 0 ) {
|
||||||
pointsList.buttons ^= ~1;
|
// Primary
|
||||||
} else if ( buttonChanged === 1 ) {
|
pointsList.buttons -= 1;
|
||||||
// Aux
|
} else if ( buttonChanged === 1 ) {
|
||||||
pointsList.buttons ^= ~4;
|
// Aux
|
||||||
} else if ( buttonChanged === 2 ) {
|
pointsList.buttons -= 4;
|
||||||
// Secondary
|
} else if ( buttonChanged === 2 ) {
|
||||||
pointsList.buttons ^= ~2;
|
// Secondary
|
||||||
} else if ( buttonChanged === 3 ) {
|
pointsList.buttons -= 2;
|
||||||
// X1 (Back)
|
} else if ( buttonChanged === 3 ) {
|
||||||
pointsList.buttons ^= ~8;
|
// X1 (Back)
|
||||||
} else if ( buttonChanged === 4 ) {
|
pointsList.buttons -= 8;
|
||||||
// X2 (Forward)
|
} else if ( buttonChanged === 4 ) {
|
||||||
pointsList.buttons ^= ~16;
|
// X2 (Forward)
|
||||||
} else if ( buttonChanged === 5 ) {
|
pointsList.buttons -= 16;
|
||||||
// Pen Eraser
|
} else if ( buttonChanged === 5 ) {
|
||||||
pointsList.buttons ^= ~32;
|
// Pen Eraser
|
||||||
|
pointsList.buttons -= 32;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ( buttonChanged === 0 ) {
|
||||||
|
// Primary
|
||||||
|
pointsList.buttons ^= ~1;
|
||||||
|
} else if ( buttonChanged === 1 ) {
|
||||||
|
// Aux
|
||||||
|
pointsList.buttons ^= ~4;
|
||||||
|
} else if ( buttonChanged === 2 ) {
|
||||||
|
// Secondary
|
||||||
|
pointsList.buttons ^= ~2;
|
||||||
|
} else if ( buttonChanged === 3 ) {
|
||||||
|
// X1 (Back)
|
||||||
|
pointsList.buttons ^= ~8;
|
||||||
|
} else if ( buttonChanged === 4 ) {
|
||||||
|
// X2 (Forward)
|
||||||
|
pointsList.buttons ^= ~16;
|
||||||
|
} else if ( buttonChanged === 5 ) {
|
||||||
|
// Pen Eraser
|
||||||
|
pointsList.buttons ^= ~32;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only capture and track primary button, pen, and touch contacts
|
// Only capture and track primary button, pen, and touch contacts
|
||||||
//if ( buttonChanged !== 0 ) {
|
if ( buttonChanged !== 0 ) {
|
||||||
if ( buttonChanged !== 0 && buttonChanged !== 1 ) { //TODO Remove this IE8 compatibility and use the commented line above
|
// Aux Release
|
||||||
|
if ( tracker.auxReleaseHandler ) {
|
||||||
|
propagate = tracker.auxReleaseHandler(
|
||||||
|
{
|
||||||
|
eventSource: tracker,
|
||||||
|
pointerType: gPoints[ 0 ].type,
|
||||||
|
position: getPointRelativeToAbsolute( gPoints[ 0 ].currentPos, tracker.element ),
|
||||||
|
button: buttonChanged,
|
||||||
|
buttons: pointsList.buttons,
|
||||||
|
isTouchEvent: gPoints[ 0 ].type === 'touch',
|
||||||
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
|
userData: tracker.userData
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if ( propagate === false ) {
|
||||||
|
$.cancelEvent( event );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,6 +390,8 @@ $.Viewer = function( options ) {
|
|||||||
dragHandler: $.delegate( this, onCanvasDrag ),
|
dragHandler: $.delegate( this, onCanvasDrag ),
|
||||||
dragEndHandler: $.delegate( this, onCanvasDragEnd ),
|
dragEndHandler: $.delegate( this, onCanvasDragEnd ),
|
||||||
releaseHandler: $.delegate( this, onCanvasRelease ),
|
releaseHandler: $.delegate( this, onCanvasRelease ),
|
||||||
|
auxPressHandler: $.delegate( this, onCanvasAuxPress ),
|
||||||
|
auxReleaseHandler: $.delegate( this, onCanvasAuxRelease ),
|
||||||
scrollHandler: $.delegate( this, onCanvasScroll ),
|
scrollHandler: $.delegate( this, onCanvasScroll ),
|
||||||
pinchHandler: $.delegate( this, onCanvasPinch )
|
pinchHandler: $.delegate( this, onCanvasPinch )
|
||||||
}).setTracking( this.mouseNavEnabled ? true : false ); // default state
|
}).setTracking( this.mouseNavEnabled ? true : false ); // default state
|
||||||
@ -2422,7 +2424,7 @@ function onCanvasDragEnd( event ) {
|
|||||||
|
|
||||||
function onCanvasRelease( event ) {
|
function onCanvasRelease( event ) {
|
||||||
/**
|
/**
|
||||||
* Raised when the mouse button is released or touch ends on the {@link OpenSeadragon.Viewer#canvas} element.
|
* Raised when the primary mouse button is released or touch ends on the {@link OpenSeadragon.Viewer#canvas} element.
|
||||||
*
|
*
|
||||||
* @event canvas-release
|
* @event canvas-release
|
||||||
* @memberof OpenSeadragon.Viewer
|
* @memberof OpenSeadragon.Viewer
|
||||||
@ -2444,6 +2446,62 @@ function onCanvasRelease( event ) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onCanvasAuxPress( event ) {
|
||||||
|
/**
|
||||||
|
* Raised when any non-primary pointer button is pressed on the {@link OpenSeadragon.Viewer#canvas} element.
|
||||||
|
*
|
||||||
|
* @event canvas-aux-press
|
||||||
|
* @memberof OpenSeadragon.Viewer
|
||||||
|
* @type {object}
|
||||||
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
||||||
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
||||||
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
||||||
|
* @property {String} pointerType - "mouse", "touch", "pen", etc.
|
||||||
|
* @property {Number} button - Button which caused the event.
|
||||||
|
* -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
||||||
|
* @property {Number} buttons - Current buttons pressed.
|
||||||
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
||||||
|
* @property {Object} originalEvent - The original DOM event.
|
||||||
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
|
*/
|
||||||
|
this.raiseEvent( 'canvas-aux-press', {
|
||||||
|
tracker: event.eventSource,
|
||||||
|
position: event.position,
|
||||||
|
pointerType: event.pointerType,
|
||||||
|
button: event.button,
|
||||||
|
buttons: event.buttons,
|
||||||
|
originalEvent: event.originalEvent
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCanvasAuxRelease( event ) {
|
||||||
|
/**
|
||||||
|
* Raised when any non-primary pointer button is released on the {@link OpenSeadragon.Viewer#canvas} element.
|
||||||
|
*
|
||||||
|
* @event canvas-aux-release
|
||||||
|
* @memberof OpenSeadragon.Viewer
|
||||||
|
* @type {object}
|
||||||
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
||||||
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
||||||
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
||||||
|
* @property {String} pointerType - "mouse", "touch", "pen", etc.
|
||||||
|
* @property {Number} button - Button which caused the event.
|
||||||
|
* -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
||||||
|
* @property {Number} buttons - Current buttons pressed.
|
||||||
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
||||||
|
* @property {Object} originalEvent - The original DOM event.
|
||||||
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
|
*/
|
||||||
|
this.raiseEvent( 'canvas-aux-release', {
|
||||||
|
tracker: event.eventSource,
|
||||||
|
position: event.position,
|
||||||
|
pointerType: event.pointerType,
|
||||||
|
button: event.button,
|
||||||
|
buttons: event.buttons,
|
||||||
|
originalEvent: event.originalEvent
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function onCanvasPinch( event ) {
|
function onCanvasPinch( event ) {
|
||||||
var gestureSettings,
|
var gestureSettings,
|
||||||
centerPt,
|
centerPt,
|
||||||
@ -2593,7 +2651,7 @@ function onContainerRelease( event ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Raised when the mouse button is released or touch ends on the {@link OpenSeadragon.Viewer#container} element.
|
* Raised when the primary mouse button is released or touch ends on the {@link OpenSeadragon.Viewer#container} element.
|
||||||
*
|
*
|
||||||
* @event container-release
|
* @event container-release
|
||||||
* @memberof OpenSeadragon.Viewer
|
* @memberof OpenSeadragon.Viewer
|
||||||
|
Loading…
Reference in New Issue
Block a user