This commit is contained in:
Geoff Harper 2023-11-06 11:48:25 -07:00 committed by GitHub
commit fdd8ed8320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 18 deletions

View File

@ -69,6 +69,9 @@
* @param {Number} [options.dblClickDistThreshold=20]
* The maximum distance allowed between two pointer click events
* to be treated as a click gesture.
* @param {Boolean} options.flipPrimaryMouseButton
* Configure which mouse button should control panning. If enabled, button 2 will be used
* for panning instead of 0.
* @param {Number} [options.stopDelay=50]
* The number of milliseconds without pointer move before the stop
* event is fired.
@ -129,9 +132,10 @@
if ( !$.isPlainObject( options ) ) {
options = {
element: args[ 0 ],
clickTimeThreshold: args[ 1 ],
clickDistThreshold: args[ 2 ]
element: args[ 0 ],
clickTimeThreshold: args[ 1 ],
clickDistThreshold: args[ 2 ],
flipPrimaryMouseButton: args[ 3 ]
};
}
@ -170,6 +174,14 @@
* @memberof OpenSeadragon.MouseTracker#
*/
this.dblClickDistThreshold = options.dblClickDistThreshold || $.DEFAULT_SETTINGS.dblClickDistThreshold;
/**
* Configure which mouse button should control panning. If enabled, button 2 will be used
* for panning instead of 0.
* @member {Boolean} flipPrimaryMouseButton
* @memberof OpenSeadragon.MouseTracker#
*/
this.flipPrimaryMouseButton = options.flipPrimaryMouseButton || $.DEFAULT_SETTINGS.flipPrimaryMouseButton;
/*eslint-disable no-multi-spaces*/
this.userData = options.userData || null;
this.stopDelay = options.stopDelay || 50;
@ -3216,16 +3228,18 @@
pointsList = tracker.getActivePointersListByType( gPoint.type ),
updateGPoint;
var primarySecondaryButtons = tracker.flipPrimaryMouseButton ? [2, 0] : [0, 2];
if ( typeof eventInfo.originalEvent.buttons !== 'undefined' ) {
pointsList.buttons = eventInfo.originalEvent.buttons;
} else {
if ( buttonChanged === 0 ) {
if ( buttonChanged === primarySecondaryButtons[0] ) {
// Primary
pointsList.buttons |= 1;
} else if ( buttonChanged === 1 ) {
// Aux
pointsList.buttons |= 4;
} else if ( buttonChanged === 2 ) {
} else if ( buttonChanged === primarySecondaryButtons[1] ) {
// Secondary
pointsList.buttons |= 2;
} else if ( buttonChanged === 3 ) {
@ -3241,7 +3255,7 @@
}
// Only capture and track primary button, pen, and touch contacts
if ( buttonChanged !== 0 ) {
if ( buttonChanged !== primarySecondaryButtons[0] ) {
eventInfo.shouldCapture = false;
eventInfo.shouldReleaseCapture = false;
@ -3360,16 +3374,18 @@
wasCaptured = false,
quick;
var primarySecondaryButtons = tracker.flipPrimaryMouseButton ? [2, 0] : [0, 2];
if ( typeof eventInfo.originalEvent.buttons !== 'undefined' ) {
pointsList.buttons = eventInfo.originalEvent.buttons;
} else {
if ( buttonChanged === 0 ) {
if ( buttonChanged === primarySecondaryButtons[0] ) {
// Primary
pointsList.buttons ^= ~1;
} else if ( buttonChanged === 1 ) {
// Aux
pointsList.buttons ^= ~4;
} else if ( buttonChanged === 2 ) {
} else if ( buttonChanged === primarySecondaryButtons[1] ) {
// Secondary
pointsList.buttons ^= ~2;
} else if ( buttonChanged === 3 ) {
@ -3387,7 +3403,7 @@
eventInfo.shouldCapture = false;
// Only capture and track primary button, pen, and touch contacts
if ( buttonChanged !== 0 ) {
if ( buttonChanged !== primarySecondaryButtons[0] ) {
eventInfo.shouldReleaseCapture = false;
// Aux Release

View File

@ -334,6 +334,10 @@
* The maximum distance allowed between two pointer click events
* to be treated as a double-click gesture.
*
* @property {Boolean} [flipPrimaryMouseButton=false]
* Configure which mouse button should control panning. If enabled,
* button 2 will be used for panning instead of 0.
*
* @property {Number} [springStiffness=6.5]
*
* @property {Number} [animationTime=1.2]
@ -1222,6 +1226,7 @@ function OpenSeadragon( options ){
clickDistThreshold: 5,
dblClickTimeThreshold: 300,
dblClickDistThreshold: 20,
flipPrimaryMouseButton: false,
springStiffness: 6.5,
animationTime: 1.2,
gestureSettingsMouse: {

View File

@ -293,6 +293,7 @@ $.Viewer = function( options ) {
clickDistThreshold: this.clickDistThreshold,
dblClickTimeThreshold: this.dblClickTimeThreshold,
dblClickDistThreshold: this.dblClickDistThreshold,
flipPrimaryMouseButton: this.flipPrimaryMouseButton,
contextMenuHandler: $.delegate( this, onCanvasContextMenu ),
keyDownHandler: $.delegate( this, onCanvasKeyDown ),
keyHandler: $.delegate( this, onCanvasKeyPress ),
@ -313,15 +314,16 @@ $.Viewer = function( options ) {
});
this.outerTracker = new $.MouseTracker({
userData: 'Viewer.outerTracker',
element: this.container,
startDisabled: !this.mouseNavEnabled,
clickTimeThreshold: this.clickTimeThreshold,
clickDistThreshold: this.clickDistThreshold,
dblClickTimeThreshold: this.dblClickTimeThreshold,
dblClickDistThreshold: this.dblClickDistThreshold,
enterHandler: $.delegate( this, onContainerEnter ),
leaveHandler: $.delegate( this, onContainerLeave )
userData: 'Viewer.outerTracker',
element: this.container,
startDisabled: !this.mouseNavEnabled,
clickTimeThreshold: this.clickTimeThreshold,
clickDistThreshold: this.clickDistThreshold,
dblClickTimeThreshold: this.dblClickTimeThreshold,
dblClickDistThreshold: this.dblClickDistThreshold,
flipPrimaryMouseButton: this.flipPrimaryMouseButton,
enterHandler: $.delegate( this, onContainerEnter ),
leaveHandler: $.delegate( this, onContainerLeave )
});
if( this.toolbar ){

View File

@ -1027,6 +1027,7 @@
clickDistThreshold: OpenSeadragon.DEFAULT_SETTINGS.clickDistThreshold,
dblClickTimeThreshold: OpenSeadragon.DEFAULT_SETTINGS.dblClickTimeThreshold,
dblClickDistThreshold: OpenSeadragon.DEFAULT_SETTINGS.dblClickDistThreshold,
flipPrimaryMouseButton: OpenSeadragon.DEFAULT_SETTINGS.flipPrimaryMouseButton,
focusHandler: onMouseTrackerFocus,
blurHandler: onMouseTrackerBlur,
enterHandler: onMouseTrackerEnter,