mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Fixed preventDefaultAction functionality tests, removed unused preventDefaultAction instances from MouseTracker
This commit is contained in:
parent
0195c5a5ec
commit
57a98c5ec2
@ -36,6 +36,7 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* Added additional documentation for the zoomPerSecond viewer option (#1872 @msalsbery)
|
* Added additional documentation for the zoomPerSecond viewer option (#1872 @msalsbery)
|
||||||
* MouseTracker: Per #1863, dropped support for Internet Explorer < 11 (#1872 @msalsbery) (#1950 @rmontroy)
|
* MouseTracker: Per #1863, dropped support for Internet Explorer < 11 (#1872 @msalsbery) (#1950 @rmontroy)
|
||||||
* Fixed simulated drag events in navigator tests (#1949 @msalsbery)
|
* Fixed simulated drag events in navigator tests (#1949 @msalsbery)
|
||||||
|
* Fixed preventDefaultAction functionality in viewer events (# @msalsbery)
|
||||||
|
|
||||||
2.4.2:
|
2.4.2:
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ function onCanvasClick( event ) {
|
|||||||
quick: event.quick,
|
quick: event.quick,
|
||||||
shift: event.shift,
|
shift: event.shift,
|
||||||
originalEvent: event.originalEvent,
|
originalEvent: event.originalEvent,
|
||||||
preventDefaultAction: event.preventDefaultAction
|
preventDefaultAction: false
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Raised when a click event occurs on the {@link OpenSeadragon.Viewer#navigator} element.
|
* Raised when a click event occurs on the {@link OpenSeadragon.Viewer#navigator} element.
|
||||||
@ -523,7 +523,7 @@ function onCanvasDrag( event ) {
|
|||||||
direction: event.direction,
|
direction: event.direction,
|
||||||
shift: event.shift,
|
shift: event.shift,
|
||||||
originalEvent: event.originalEvent,
|
originalEvent: event.originalEvent,
|
||||||
preventDefaultAction: event.preventDefaultAction
|
preventDefaultAction: false
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Raised when a drag event occurs on the {@link OpenSeadragon.Viewer#navigator} element.
|
* Raised when a drag event occurs on the {@link OpenSeadragon.Viewer#navigator} element.
|
||||||
|
@ -524,7 +524,7 @@ function onStripLeave( event ) {
|
|||||||
function onKeyDown( event ) {
|
function onKeyDown( event ) {
|
||||||
//console.log( event.keyCode );
|
//console.log( event.keyCode );
|
||||||
|
|
||||||
if ( !event.preventDefaultAction && !event.ctrl && !event.alt && !event.meta ) {
|
if ( !event.ctrl && !event.alt && !event.meta ) {
|
||||||
switch ( event.keyCode ) {
|
switch ( event.keyCode ) {
|
||||||
case 38: //up arrow
|
case 38: //up arrow
|
||||||
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
||||||
@ -556,7 +556,7 @@ function onKeyDown( event ) {
|
|||||||
function onKeyPress( event ) {
|
function onKeyPress( event ) {
|
||||||
//console.log( event.keyCode );
|
//console.log( event.keyCode );
|
||||||
|
|
||||||
if ( !event.preventDefaultAction && !event.ctrl && !event.alt && !event.meta ) {
|
if ( !event.ctrl && !event.alt && !event.meta ) {
|
||||||
switch ( event.keyCode ) {
|
switch ( event.keyCode ) {
|
||||||
case 61: //=|+
|
case 61: //=|+
|
||||||
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
||||||
|
103
src/viewer.js
103
src/viewer.js
@ -2568,7 +2568,7 @@ function onCanvasContextMenu( event ) {
|
|||||||
function onCanvasKeyDown( event ) {
|
function onCanvasKeyDown( event ) {
|
||||||
var canvasKeyDownEventArgs = {
|
var canvasKeyDownEventArgs = {
|
||||||
originalEvent: event.originalEvent,
|
originalEvent: event.originalEvent,
|
||||||
preventDefaultAction: event.preventDefaultAction,
|
preventDefaultAction: false,
|
||||||
preventVerticalPan: event.preventVerticalPan,
|
preventVerticalPan: event.preventVerticalPan,
|
||||||
preventHorizontalPan: event.preventHorizontalPan
|
preventHorizontalPan: event.preventHorizontalPan
|
||||||
};
|
};
|
||||||
@ -2600,7 +2600,7 @@ function onCanvasKeyDown( event ) {
|
|||||||
}
|
}
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
return false;
|
break;
|
||||||
case 40://down arrow
|
case 40://down arrow
|
||||||
if (!canvasKeyDownEventArgs.preventVerticalPan) {
|
if (!canvasKeyDownEventArgs.preventVerticalPan) {
|
||||||
if ( event.shift ) {
|
if ( event.shift ) {
|
||||||
@ -2610,31 +2610,29 @@ function onCanvasKeyDown( event ) {
|
|||||||
}
|
}
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
return false;
|
break;
|
||||||
case 37://left arrow
|
case 37://left arrow
|
||||||
if (!canvasKeyDownEventArgs.preventHorizontalPan) {
|
if (!canvasKeyDownEventArgs.preventHorizontalPan) {
|
||||||
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(-this.pixelsPerArrowPress, 0)));
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(-this.pixelsPerArrowPress, 0)));
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
return false;
|
break;
|
||||||
case 39://right arrow
|
case 39://right arrow
|
||||||
if (!canvasKeyDownEventArgs.preventHorizontalPan) {
|
if (!canvasKeyDownEventArgs.preventHorizontalPan) {
|
||||||
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(this.pixelsPerArrowPress, 0)));
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(this.pixelsPerArrowPress, 0)));
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
return false;
|
break;
|
||||||
default:
|
default:
|
||||||
//console.log( 'navigator keycode %s', event.keyCode );
|
//console.log( 'navigator keycode %s', event.keyCode );
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onCanvasKeyPress( event ) {
|
function onCanvasKeyPress( event ) {
|
||||||
var canvasKeyPressEventArgs = {
|
var canvasKeyPressEventArgs = {
|
||||||
originalEvent: event.originalEvent,
|
originalEvent: event.originalEvent,
|
||||||
preventDefaultAction: event.preventDefaultAction,
|
preventDefaultAction: false,
|
||||||
preventVerticalPan: event.preventVerticalPan,
|
preventVerticalPan: event.preventVerticalPan,
|
||||||
preventHorizontalPan: event.preventHorizontalPan
|
preventHorizontalPan: event.preventHorizontalPan
|
||||||
};
|
};
|
||||||
@ -2648,15 +2646,15 @@ function onCanvasKeyPress( event ) {
|
|||||||
case 61://=|+
|
case 61://=|+
|
||||||
this.viewport.zoomBy(1.1);
|
this.viewport.zoomBy(1.1);
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
return false;
|
break;
|
||||||
case 45://-|_
|
case 45://-|_
|
||||||
this.viewport.zoomBy(0.9);
|
this.viewport.zoomBy(0.9);
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
return false;
|
break;
|
||||||
case 48://0|)
|
case 48://0|)
|
||||||
this.viewport.goHome();
|
this.viewport.goHome();
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
return false;
|
break;
|
||||||
case 119://w
|
case 119://w
|
||||||
case 87://W
|
case 87://W
|
||||||
if (!canvasKeyPressEventArgs.preventVerticalPan) {
|
if (!canvasKeyPressEventArgs.preventVerticalPan) {
|
||||||
@ -2667,7 +2665,7 @@ function onCanvasKeyPress( event ) {
|
|||||||
}
|
}
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
return false;
|
break;
|
||||||
case 115://s
|
case 115://s
|
||||||
case 83://S
|
case 83://S
|
||||||
if (!canvasKeyPressEventArgs.preventVerticalPan) {
|
if (!canvasKeyPressEventArgs.preventVerticalPan) {
|
||||||
@ -2678,19 +2676,19 @@ function onCanvasKeyPress( event ) {
|
|||||||
}
|
}
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
return false;
|
break;
|
||||||
case 97://a
|
case 97://a
|
||||||
if (!canvasKeyPressEventArgs.preventHorizontalPan) {
|
if (!canvasKeyPressEventArgs.preventHorizontalPan) {
|
||||||
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(-40, 0)));
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(-40, 0)));
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
return false;
|
break;
|
||||||
case 100://d
|
case 100://d
|
||||||
if (!canvasKeyPressEventArgs.preventHorizontalPan) {
|
if (!canvasKeyPressEventArgs.preventHorizontalPan) {
|
||||||
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(40, 0)));
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(40, 0)));
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
return false;
|
break;
|
||||||
case 114: //r - clockwise rotation
|
case 114: //r - clockwise rotation
|
||||||
if(this.viewport.flipped){
|
if(this.viewport.flipped){
|
||||||
this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360));
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360));
|
||||||
@ -2698,7 +2696,7 @@ function onCanvasKeyPress( event ) {
|
|||||||
this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360));
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360));
|
||||||
}
|
}
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
return false;
|
break;
|
||||||
case 82: //R - counterclockwise rotation
|
case 82: //R - counterclockwise rotation
|
||||||
if(this.viewport.flipped){
|
if(this.viewport.flipped){
|
||||||
this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360));
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360));
|
||||||
@ -2706,16 +2704,14 @@ function onCanvasKeyPress( event ) {
|
|||||||
this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360));
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360));
|
||||||
}
|
}
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
return false;
|
break;
|
||||||
case 102: //f
|
case 102: //f
|
||||||
this.viewport.toggleFlip();
|
this.viewport.toggleFlip();
|
||||||
return false;
|
break;
|
||||||
default:
|
default:
|
||||||
// console.log( 'navigator keycode %s', event.keyCode );
|
// console.log( 'navigator keycode %s', event.keyCode );
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2738,7 +2734,7 @@ function onCanvasClick( event ) {
|
|||||||
quick: event.quick,
|
quick: event.quick,
|
||||||
shift: event.shift,
|
shift: event.shift,
|
||||||
originalEvent: event.originalEvent,
|
originalEvent: event.originalEvent,
|
||||||
preventDefaultAction: event.preventDefaultAction
|
preventDefaultAction: false
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2778,7 +2774,7 @@ function onCanvasDblClick( event ) {
|
|||||||
position: event.position,
|
position: event.position,
|
||||||
shift: event.shift,
|
shift: event.shift,
|
||||||
originalEvent: event.originalEvent,
|
originalEvent: event.originalEvent,
|
||||||
preventDefaultAction: event.preventDefaultAction
|
preventDefaultAction: false
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2821,7 +2817,7 @@ function onCanvasDrag( event ) {
|
|||||||
direction: event.direction,
|
direction: event.direction,
|
||||||
shift: event.shift,
|
shift: event.shift,
|
||||||
originalEvent: event.originalEvent,
|
originalEvent: event.originalEvent,
|
||||||
preventDefaultAction: event.preventDefaultAction
|
preventDefaultAction: false
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2882,7 +2878,37 @@ function onCanvasDrag( event ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasDragEnd( event ) {
|
function onCanvasDragEnd( event ) {
|
||||||
if (!event.preventDefaultAction && this.viewport) {
|
var canvasDragEndEventArgs = {
|
||||||
|
tracker: event.eventSource,
|
||||||
|
pointerType: event.pointerType,
|
||||||
|
position: event.position,
|
||||||
|
speed: event.speed,
|
||||||
|
direction: event.direction,
|
||||||
|
shift: event.shift,
|
||||||
|
originalEvent: event.originalEvent,
|
||||||
|
preventDefaultAction: false
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raised when a mouse or touch drag operation ends on the {@link OpenSeadragon.Viewer#canvas} element.
|
||||||
|
*
|
||||||
|
* @event canvas-drag-end
|
||||||
|
* @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 {String} pointerType - "mouse", "touch", "pen", etc.
|
||||||
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
||||||
|
* @property {Number} speed - Speed at the end of a drag gesture, in pixels per second.
|
||||||
|
* @property {Number} direction - Direction at the end of a drag gesture, expressed as an angle counterclockwise relative to the positive X axis (-pi to pi, in radians). Only valid if speed > 0.
|
||||||
|
* @property {Boolean} shift - True if the shift key was pressed during this event.
|
||||||
|
* @property {Object} originalEvent - The original DOM event.
|
||||||
|
* @property {Boolean} preventDefaultAction - Set to true to prevent default drag-end flick behaviour. Default: false.
|
||||||
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
|
*/
|
||||||
|
this.raiseEvent('canvas-drag-end', canvasDragEndEventArgs);
|
||||||
|
|
||||||
|
if (!canvasDragEndEventArgs.preventDefaultAction && this.viewport) {
|
||||||
var gestureSettings = this.gestureSettingsByDeviceType(event.pointerType);
|
var gestureSettings = this.gestureSettingsByDeviceType(event.pointerType);
|
||||||
if (gestureSettings.flickEnabled &&
|
if (gestureSettings.flickEnabled &&
|
||||||
event.speed >= gestureSettings.flickMinSpeed) {
|
event.speed >= gestureSettings.flickMinSpeed) {
|
||||||
@ -2904,31 +2930,6 @@ function onCanvasDragEnd( event ) {
|
|||||||
}
|
}
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Raised when a mouse or touch drag operation ends on the {@link OpenSeadragon.Viewer#canvas} element.
|
|
||||||
*
|
|
||||||
* @event canvas-drag-end
|
|
||||||
* @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 {String} pointerType - "mouse", "touch", "pen", etc.
|
|
||||||
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
||||||
* @property {Number} speed - Speed at the end of a drag gesture, in pixels per second.
|
|
||||||
* @property {Number} direction - Direction at the end of a drag gesture, expressed as an angle counterclockwise relative to the positive X axis (-pi to pi, in radians). Only valid if speed > 0.
|
|
||||||
* @property {Boolean} shift - True if the shift key was pressed during this event.
|
|
||||||
* @property {Object} originalEvent - The original DOM event.
|
|
||||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
||||||
*/
|
|
||||||
this.raiseEvent('canvas-drag-end', {
|
|
||||||
tracker: event.eventSource,
|
|
||||||
pointerType: event.pointerType,
|
|
||||||
position: event.position,
|
|
||||||
speed: event.speed,
|
|
||||||
direction: event.direction,
|
|
||||||
shift: event.shift,
|
|
||||||
originalEvent: event.originalEvent
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasEnter( event ) {
|
function onCanvasEnter( event ) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user