mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Added preventDefaultAction flag to MouseTracker
Added a boolean preventDefaultAction property (default false) to the event object passed to MouseTracker handler methods. Implemented in the following MouseTracker subscribers: * Viewer.keyboardCommandArea.innerTracker.focusHandler: preventDefaultAction == true prevents scrolling viewer into view * Viewer.keyboardCommandArea.innerTracker.keyHandler: preventDefaultAction == true prevents viewer keyboard navigation * Viewer.innerTracker.clickHandler: preventDefaultAction == true prevents viewer zoom on click * Viewer.innerTracker.dragHandler: preventDefaultAction == true prevents viewer panning with mouse/touch * Viewer.innerTracker.scrollHandler: preventDefaultAction == true prevents viewer zooming on mousewheel/pinch
This commit is contained in:
parent
dbb7cee76a
commit
8e325a3748
@ -37,6 +37,12 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* Fixed: IE 10 not reading DZI file correctly in certain circumstances (#218)
|
* Fixed: IE 10 not reading DZI file correctly in certain circumstances (#218)
|
||||||
* Added support for the 'wheel' DOM mousewheel event (#261)
|
* Added support for the 'wheel' DOM mousewheel event (#261)
|
||||||
* Fix for non-canvas tile rendering at large size (#264)
|
* Fix for non-canvas tile rendering at large size (#264)
|
||||||
|
* Added a boolean preventDefaultAction property (default false) to the event object passed to MouseTracker handler methods. Implemented in the following MouseTracker subscribers:
|
||||||
|
* Viewer.keyboardCommandArea.innerTracker.focusHandler: preventDefaultAction == true prevents scrolling viewer into view
|
||||||
|
* Viewer.keyboardCommandArea.innerTracker.keyHandler: preventDefaultAction == true prevents viewer keyboard navigation
|
||||||
|
* Viewer.innerTracker.clickHandler: preventDefaultAction == true prevents viewer zoom on click
|
||||||
|
* Viewer.innerTracker.dragHandler: preventDefaultAction == true prevents viewer panning with mouse/touch
|
||||||
|
* Viewer.innerTracker.scrollHandler: preventDefaultAction == true prevents viewer zooming on mousewheel/pinch
|
||||||
|
|
||||||
0.9.131:
|
0.9.131:
|
||||||
|
|
||||||
|
@ -243,6 +243,8 @@
|
|||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -266,6 +268,8 @@
|
|||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -284,6 +288,8 @@
|
|||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -307,6 +313,8 @@
|
|||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -325,6 +333,8 @@
|
|||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -347,6 +357,8 @@
|
|||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -369,6 +381,8 @@
|
|||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -391,6 +405,8 @@
|
|||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -409,6 +425,8 @@
|
|||||||
* True if the original event is a touch event, otherwise false.
|
* True if the original event is a touch event, otherwise false.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -427,6 +445,8 @@
|
|||||||
* True if the shift key was pressed during this event.
|
* True if the shift key was pressed during this event.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -441,6 +461,8 @@
|
|||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -455,6 +477,8 @@
|
|||||||
* A reference to the tracker instance.
|
* A reference to the tracker instance.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} [event.preventDefaultAction=false]
|
||||||
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent).
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -675,6 +699,7 @@
|
|||||||
{
|
{
|
||||||
eventSource: tracker,
|
eventSource: tracker,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -697,6 +722,7 @@
|
|||||||
{
|
{
|
||||||
eventSource: tracker,
|
eventSource: tracker,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -722,6 +748,7 @@
|
|||||||
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
||||||
shift: event.shiftKey,
|
shift: event.shiftKey,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -778,6 +805,7 @@
|
|||||||
buttonDownAny: IS_BUTTON_DOWN,
|
buttonDownAny: IS_BUTTON_DOWN,
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -834,6 +862,7 @@
|
|||||||
buttonDownAny: IS_BUTTON_DOWN,
|
buttonDownAny: IS_BUTTON_DOWN,
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -876,6 +905,7 @@
|
|||||||
position: getMouseRelative( eventOrTouchPoint, tracker.element ),
|
position: getMouseRelative( eventOrTouchPoint, tracker.element ),
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -973,6 +1003,7 @@
|
|||||||
insideElementReleased: insideElementReleased,
|
insideElementReleased: insideElementReleased,
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -1089,6 +1120,7 @@
|
|||||||
position: getMouseRelative( event, tracker.element ),
|
position: getMouseRelative( event, tracker.element ),
|
||||||
isTouchEvent: false,
|
isTouchEvent: false,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -1115,6 +1147,7 @@
|
|||||||
position: getMouseRelative( originalMoveEvent, tracker.element ),
|
position: getMouseRelative( originalMoveEvent, tracker.element ),
|
||||||
isTouchEvent: false,
|
isTouchEvent: false,
|
||||||
originalEvent: originalMoveEvent,
|
originalEvent: originalMoveEvent,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
@ -1206,6 +1239,7 @@
|
|||||||
shift: event.shiftKey,
|
shift: event.shiftKey,
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: originalEvent,
|
originalEvent: originalEvent,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -1249,6 +1283,7 @@
|
|||||||
shift: event.shiftKey,
|
shift: event.shiftKey,
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -1287,6 +1322,7 @@
|
|||||||
shift: event.shiftKey,
|
shift: event.shiftKey,
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -276,12 +276,15 @@ $.Viewer = function( options ) {
|
|||||||
this.keyboardCommandArea.innerTracker = new $.MouseTracker({
|
this.keyboardCommandArea.innerTracker = new $.MouseTracker({
|
||||||
_this : this,
|
_this : this,
|
||||||
element: this.keyboardCommandArea,
|
element: this.keyboardCommandArea,
|
||||||
focusHandler: function(){
|
focusHandler: function( event ){
|
||||||
|
if ( !event.preventDefaultAction ) {
|
||||||
var point = $.getElementPosition( this.element );
|
var point = $.getElementPosition( this.element );
|
||||||
window.scrollTo( 0, point.y );
|
window.scrollTo( 0, point.y );
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
keyHandler: function( event ){
|
keyHandler: function( event ){
|
||||||
|
if ( !event.preventDefaultAction ) {
|
||||||
switch( event.keyCode ){
|
switch( event.keyCode ){
|
||||||
case 61://=|+
|
case 61://=|+
|
||||||
_this.viewport.zoomBy(1.1);
|
_this.viewport.zoomBy(1.1);
|
||||||
@ -330,6 +333,7 @@ $.Viewer = function( options ) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}).setTracking( true ); // default state
|
}).setTracking( true ); // default state
|
||||||
|
|
||||||
|
|
||||||
@ -1474,7 +1478,7 @@ function onBlur(){
|
|||||||
function onCanvasClick( event ) {
|
function onCanvasClick( event ) {
|
||||||
var zoomPerClick,
|
var zoomPerClick,
|
||||||
factor;
|
factor;
|
||||||
if ( this.viewport && event.quick ) { // ignore clicks where mouse moved
|
if ( !event.preventDefaultAction && this.viewport && event.quick ) { // ignore clicks where mouse moved
|
||||||
zoomPerClick = this.zoomPerClick;
|
zoomPerClick = this.zoomPerClick;
|
||||||
factor = event.shift ? 1.0 / zoomPerClick : zoomPerClick;
|
factor = event.shift ? 1.0 / zoomPerClick : zoomPerClick;
|
||||||
this.viewport.zoomBy(
|
this.viewport.zoomBy(
|
||||||
@ -1493,7 +1497,7 @@ function onCanvasClick( event ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasDrag( event ) {
|
function onCanvasDrag( event ) {
|
||||||
if ( this.viewport ) {
|
if ( !event.preventDefaultAction && this.viewport ) {
|
||||||
if( !this.panHorizontal ){
|
if( !this.panHorizontal ){
|
||||||
event.delta.x = 0;
|
event.delta.x = 0;
|
||||||
}
|
}
|
||||||
@ -1533,7 +1537,7 @@ function onCanvasRelease( event ) {
|
|||||||
|
|
||||||
function onCanvasScroll( event ) {
|
function onCanvasScroll( event ) {
|
||||||
var factor;
|
var factor;
|
||||||
if ( this.viewport ) {
|
if ( !event.preventDefaultAction && this.viewport ) {
|
||||||
factor = Math.pow( this.zoomPerScroll, event.scroll );
|
factor = Math.pow( this.zoomPerScroll, event.scroll );
|
||||||
this.viewport.zoomBy(
|
this.viewport.zoomBy(
|
||||||
factor,
|
factor,
|
||||||
|
Loading…
Reference in New Issue
Block a user