mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-24 22:26:10 +03:00
Consolidate viewer keyboard handling into keydown handler
This commit is contained in:
parent
ead728dc35
commit
f36d44dc67
@ -295,7 +295,6 @@ $.Viewer = function( options ) {
|
|||||||
dblClickDistThreshold: this.dblClickDistThreshold,
|
dblClickDistThreshold: this.dblClickDistThreshold,
|
||||||
contextMenuHandler: $.delegate( this, onCanvasContextMenu ),
|
contextMenuHandler: $.delegate( this, onCanvasContextMenu ),
|
||||||
keyDownHandler: $.delegate( this, onCanvasKeyDown ),
|
keyDownHandler: $.delegate( this, onCanvasKeyDown ),
|
||||||
keyHandler: $.delegate( this, onCanvasKeyPress ),
|
|
||||||
clickHandler: $.delegate( this, onCanvasClick ),
|
clickHandler: $.delegate( this, onCanvasClick ),
|
||||||
dblClickHandler: $.delegate( this, onCanvasDblClick ),
|
dblClickHandler: $.delegate( this, onCanvasDblClick ),
|
||||||
dragHandler: $.delegate( this, onCanvasDrag ),
|
dragHandler: $.delegate( this, onCanvasDrag ),
|
||||||
@ -2793,40 +2792,6 @@ function onCanvasKeyDown( event ) {
|
|||||||
}
|
}
|
||||||
event.preventDefault = true;
|
event.preventDefault = true;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
//console.log( 'navigator keycode %s', event.keyCode );
|
|
||||||
event.preventDefault = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
event.preventDefault = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function onCanvasKeyPress( event ) {
|
|
||||||
var canvasKeyPressEventArgs = {
|
|
||||||
originalEvent: event.originalEvent,
|
|
||||||
preventDefaultAction: false,
|
|
||||||
preventVerticalPan: event.preventVerticalPan || !this.panVertical,
|
|
||||||
preventHorizontalPan: event.preventHorizontalPan || !this.panHorizontal
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Raised when a keyboard key is pressed and the focus is on the {@link OpenSeadragon.Viewer#canvas} element.
|
|
||||||
*
|
|
||||||
* @event canvas-key-press
|
|
||||||
* @memberof OpenSeadragon.Viewer
|
|
||||||
* @type {object}
|
|
||||||
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
||||||
* @property {Object} originalEvent - The original DOM event.
|
|
||||||
* @property {Boolean} preventDefaultAction - Set to true to prevent default keyboard behaviour. Default: false.
|
|
||||||
* @property {Boolean} preventVerticalPan - Set to true to prevent keyboard vertical panning. Default: false.
|
|
||||||
* @property {Boolean} preventHorizontalPan - Set to true to prevent keyboard horizontal panning. Default: false.
|
|
||||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
||||||
*/
|
|
||||||
this.raiseEvent('canvas-key-press', canvasKeyPressEventArgs);
|
|
||||||
|
|
||||||
if ( !canvasKeyPressEventArgs.preventDefaultAction && !event.ctrl && !event.alt && !event.meta ) {
|
|
||||||
switch( event.keyCode ){
|
|
||||||
case 43://=|+
|
case 43://=|+
|
||||||
case 61://=|+
|
case 61://=|+
|
||||||
this.viewport.zoomBy(1.1);
|
this.viewport.zoomBy(1.1);
|
||||||
@ -2910,7 +2875,7 @@ function onCanvasKeyPress( event ) {
|
|||||||
this.goToNextPage();
|
this.goToNextPage();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// console.log( 'navigator keycode %s', event.keyCode );
|
//console.log( 'navigator keycode %s', event.keyCode );
|
||||||
event.preventDefault = false;
|
event.preventDefault = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2919,8 +2884,6 @@ function onCanvasKeyPress( event ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function onCanvasClick( event ) {
|
function onCanvasClick( event ) {
|
||||||
var gestureSettings;
|
var gestureSettings;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user