diff --git a/src/mousetracker.js b/src/mousetracker.js
index 4aefd249..04796f28 100644
--- a/src/mousetracker.js
+++ b/src/mousetracker.js
@@ -494,8 +494,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -527,8 +525,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -560,8 +556,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -585,8 +579,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -613,8 +605,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -643,8 +633,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -671,8 +659,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -696,8 +682,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -722,8 +706,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead. Touch devices no longer generate scroll event.
* @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.
*/
@@ -748,8 +730,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -772,8 +752,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -805,8 +783,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -833,8 +809,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -863,8 +837,6 @@
* True if the shift key was pressed during this event.
* @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.
*/
@@ -888,8 +860,6 @@
* True if the original event is a touch event, otherwise false. Deprecated. Use pointerType and/or originalEvent instead.
* @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.
*/
@@ -914,8 +884,6 @@
* True if the meta key was pressed during this event.
* @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.
*/
@@ -940,8 +908,6 @@
* True if the meta key was pressed during this event.
* @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.
*/
@@ -966,8 +932,6 @@
* True if the meta key was pressed during this event.
* @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.
*/
@@ -982,8 +946,6 @@
* A reference to the tracker instance.
* @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.
*/
@@ -998,8 +960,6 @@
* A reference to the tracker instance.
* @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.
*/
@@ -1822,7 +1782,6 @@
alt: event.altKey,
meta: event.metaKey,
originalEvent: event,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -1850,7 +1809,6 @@
alt: event.altKey,
meta: event.metaKey,
originalEvent: event,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -1878,7 +1836,6 @@
alt: event.altKey,
meta: event.metaKey,
originalEvent: event,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -1901,7 +1858,6 @@
{
eventSource: tracker,
originalEvent: event,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -1924,7 +1880,6 @@
{
eventSource: tracker,
originalEvent: event,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -2052,7 +2007,6 @@
shift: event.shiftKey,
isTouchEvent: false,
originalEvent: originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3098,7 +3052,6 @@
buttonDownAny: pointsList.buttons !== 0,
isTouchEvent: gPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3144,7 +3097,6 @@
buttonDownAny: pointsList.buttons !== 0,
isTouchEvent: gPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
} );
}
@@ -3215,7 +3167,6 @@
buttons: pointsList.buttons,
isTouchEvent: gPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3270,7 +3221,6 @@
buttons: pointsList.buttons,
isTouchEvent: gPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3359,7 +3309,6 @@
buttons: pointsList.buttons,
isTouchEvent: gPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3425,7 +3374,6 @@
insideElementReleased: updateGPoint.insideElement,
isTouchEvent: updateGPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3443,7 +3391,6 @@
shift: eventInfo.originalEvent.shiftKey,
isTouchEvent: updateGPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3465,7 +3412,6 @@
shift: eventInfo.originalEvent.shiftKey,
isTouchEvent: updateGPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3493,7 +3439,6 @@
shift: eventInfo.originalEvent.shiftKey,
isTouchEvent: updateGPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3527,7 +3472,6 @@
insideElementReleased: updateGPoint.insideElement,
isTouchEvent: updateGPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3600,7 +3544,6 @@
buttons: pointsList.buttons,
isTouchEvent: gPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3617,7 +3560,6 @@
buttons: pointsList.buttons,
isTouchEvent: updateGPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3639,7 +3581,6 @@
shift: eventInfo.originalEvent.shiftKey,
isTouchEvent: updateGPoint.type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3657,7 +3598,6 @@
buttons: pointsList.buttons,
isTouchEvent: gPointArray[ 0 ].type === 'touch',
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3683,7 +3623,6 @@
distance: delegate.currentPinchDist,
shift: eventInfo.originalEvent.shiftKey,
originalEvent: eventInfo.originalEvent,
- preventDefaultAction: false,
userData: tracker.userData
}
);
@@ -3730,7 +3669,6 @@
buttons: tracker.getActivePointersListByType( pointerType ).buttons,
isTouchEvent: pointerType === 'touch',
originalEvent: originalMoveEvent,
- preventDefaultAction: false,
userData: tracker.userData
} );
}
diff --git a/src/viewer.js b/src/viewer.js
index db1e8a23..fa3dc044 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -3105,33 +3105,21 @@ function onCanvasPinch( event ) {
lastCenterPt,
panByPt;
- if ( !event.preventDefaultAction && this.viewport ) {
- gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
- if ( gestureSettings.pinchToZoom ) {
- centerPt = this.viewport.pointFromPixel( event.center, true );
- lastCenterPt = this.viewport.pointFromPixel( event.lastCenter, true );
- panByPt = lastCenterPt.minus( centerPt );
- if( !this.panHorizontal ) {
- panByPt.x = 0;
- }
- if( !this.panVertical ) {
- panByPt.y = 0;
- }
- this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true );
- if ( gestureSettings.zoomToRefPoint ) {
- this.viewport.panBy(panByPt, true);
- }
- this.viewport.applyConstraints();
- }
- if ( gestureSettings.pinchRotate ) {
- // Pinch rotate
- var angle1 = Math.atan2(event.gesturePoints[0].currentPos.y - event.gesturePoints[1].currentPos.y,
- event.gesturePoints[0].currentPos.x - event.gesturePoints[1].currentPos.x);
- var angle2 = Math.atan2(event.gesturePoints[0].lastPos.y - event.gesturePoints[1].lastPos.y,
- event.gesturePoints[0].lastPos.x - event.gesturePoints[1].lastPos.x);
- this.viewport.setRotation(this.viewport.getRotation() + ((angle1 - angle2) * (180 / Math.PI)));
- }
- }
+ var canvasPinchEventArgs = {
+ tracker: event.eventSource,
+ pointerType: event.pointerType,
+ gesturePoints: event.gesturePoints,
+ lastCenter: event.lastCenter,
+ center: event.center,
+ lastDistance: event.lastDistance,
+ distance: event.distance,
+ shift: event.shift,
+ originalEvent: event.originalEvent,
+ preventDefaultPanAction: false,
+ preventDefaultZoomAction: false,
+ preventDefaultRotateAction: false
+ };
+
/**
* Raised when a pinch event occurs on the {@link OpenSeadragon.Viewer#canvas} element.
*
@@ -3148,25 +3136,48 @@ function onCanvasPinch( event ) {
* @property {Number} distance - The distance between the two pinch contact points in CSS pixels.
* @property {Boolean} shift - True if the shift key was pressed during this event.
* @property {Object} originalEvent - The original DOM event.
+ * @property {Boolean} preventDefaultPanAction - Set to true to prevent default pinch to pan behaviour. Default: false.
+ * @property {Boolean} preventDefaultZoomAction - Set to true to prevent default pinch to zoom behaviour. Default: false.
+ * @property {Boolean} preventDefaultRotateAction - Set to true to prevent default pinch to rotate behaviour. Default: false.
* @property {?Object} userData - Arbitrary subscriber-defined object.
*/
- this.raiseEvent('canvas-pinch', {
- tracker: event.eventSource,
- pointerType: event.pointerType,
- gesturePoints: event.gesturePoints,
- lastCenter: event.lastCenter,
- center: event.center,
- lastDistance: event.lastDistance,
- distance: event.distance,
- shift: event.shift,
- originalEvent: event.originalEvent
- });
- //cancels event
- return false;
+ this.raiseEvent('canvas-pinch', canvasPinchEventArgs);
+
+ if ( this.viewport ) {
+ gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
+ if ( gestureSettings.pinchToZoom &&
+ (!canvasPinchEventArgs.preventDefaultPanAction || !canvasPinchEventArgs.preventDefaultZoomAction) ) {
+ centerPt = this.viewport.pointFromPixel( event.center, true );
+ if ( !canvasPinchEventArgs.preventDefaultZoomAction ) {
+ this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true );
+ }
+ if ( gestureSettings.zoomToRefPoint && !canvasPinchEventArgs.preventDefaultPanAction ) {
+ lastCenterPt = this.viewport.pointFromPixel( event.lastCenter, true );
+ panByPt = lastCenterPt.minus( centerPt );
+ if( !this.panHorizontal ) {
+ panByPt.x = 0;
+ }
+ if( !this.panVertical ) {
+ panByPt.y = 0;
+ }
+ this.viewport.panBy(panByPt, true);
+ }
+ this.viewport.applyConstraints();
+ }
+ if ( gestureSettings.pinchRotate && !canvasPinchEventArgs.preventDefaultRotateAction ) {
+ // Pinch rotate
+ var angle1 = Math.atan2(event.gesturePoints[0].currentPos.y - event.gesturePoints[1].currentPos.y,
+ event.gesturePoints[0].currentPos.x - event.gesturePoints[1].currentPos.x);
+ var angle2 = Math.atan2(event.gesturePoints[0].lastPos.y - event.gesturePoints[1].lastPos.y,
+ event.gesturePoints[0].lastPos.x - event.gesturePoints[1].lastPos.x);
+ this.viewport.setRotation(this.viewport.getRotation() + ((angle1 - angle2) * (180 / Math.PI)));
+ }
+ }
}
function onCanvasScroll( event ) {
- var gestureSettings,
+ var canvasScrollEventArgs,
+ gestureSettings,
factor,
thisScrollTime,
deltaScrollTime;
@@ -3179,21 +3190,15 @@ function onCanvasScroll( event ) {
if (deltaScrollTime > this.minScrollDeltaTime) {
this._lastScrollTime = thisScrollTime;
- if(this.viewport.flipped){
- event.position.x = this.viewport.getContainerSize().x - event.position.x;
- }
+ canvasScrollEventArgs = {
+ tracker: event.eventSource,
+ position: event.position,
+ scroll: event.scroll,
+ shift: event.shift,
+ originalEvent: event.originalEvent,
+ preventDefaultAction: false
+ };
- if ( !event.preventDefaultAction && this.viewport ) {
- gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
- if ( gestureSettings.scrollToZoom ) {
- factor = Math.pow( this.zoomPerScroll, event.scroll );
- this.viewport.zoomBy(
- factor,
- gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null
- );
- this.viewport.applyConstraints();
- }
- }
/**
* Raised when a scroll event occurs on the {@link OpenSeadragon.Viewer#canvas} element (mouse wheel).
*
@@ -3206,28 +3211,27 @@ function onCanvasScroll( event ) {
* @property {Number} scroll - The scroll delta for the event.
* @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 scroll to zoom behaviour. Default: false.
* @property {?Object} userData - Arbitrary subscriber-defined object.
*/
- this.raiseEvent( 'canvas-scroll', {
- tracker: event.eventSource,
- position: event.position,
- scroll: event.scroll,
- shift: event.shift,
- originalEvent: event.originalEvent
- });
- if (gestureSettings && gestureSettings.scrollToZoom) {
- //cancels event
- return false;
- }
- }
- else {
- gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
- if (gestureSettings && gestureSettings.scrollToZoom) {
- return false; // We are swallowing this event
- }
- }
+ this.raiseEvent('canvas-scroll', canvasScrollEventArgs );
- return undefined;
+ if ( !canvasScrollEventArgs.preventDefaultAction && this.viewport ) {
+ if(this.viewport.flipped){
+ event.position.x = this.viewport.getContainerSize().x - event.position.x;
+ }
+
+ gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
+ if ( gestureSettings.scrollToZoom ) {
+ factor = Math.pow( this.zoomPerScroll, event.scroll );
+ this.viewport.zoomBy(
+ factor,
+ gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null
+ );
+ this.viewport.applyConstraints();
+ }
+ }
+ }
}
function onContainerEnter( event ) {