mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Added preventDefault option to MouseTracker.contextMenuHandler and Viewer 'canvas-contextmenu' event args
This commit is contained in:
parent
ab3f49abe3
commit
c38188927e
@ -36,6 +36,7 @@ OPENSEADRAGON CHANGELOG
|
||||
* Added additional documentation for the zoomPerSecond viewer option (#1872 @msalsbery)
|
||||
* MouseTracker: Per #1863, dropped support for Internet Explorer < 11 (#1872 @msalsbery)
|
||||
* Fixed simulated drag events in navigator tests (#1949 @msalsbery)
|
||||
* Added preventDefault option to MouseTracker.contextMenuHandler and Viewer 'canvas-contextmenu' event args (# @msalsbery)
|
||||
|
||||
2.4.2:
|
||||
|
||||
|
@ -280,7 +280,6 @@
|
||||
this.dragHandler || this.dragEndHandler ||
|
||||
this.pinchHandler );
|
||||
this.hasScrollHandler = !!this.scrollHandler;
|
||||
this.hasContextMenuHandler = !!this.contextMenuHandler;
|
||||
|
||||
if (this.exitHandler) {
|
||||
$.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead.");
|
||||
@ -402,6 +401,8 @@
|
||||
* The position of the event relative to the tracked element.
|
||||
* @param {Object} event.originalEvent
|
||||
* The original event object.
|
||||
* @param {Boolean} event.preventDefault
|
||||
* Set to true to prevent the default user-agent's handling of the contextmenu event.
|
||||
* @param {Object} event.userData
|
||||
* Arbitrary user-defined object.
|
||||
*/
|
||||
@ -1942,6 +1943,8 @@
|
||||
function onContextMenu( tracker, event ) {
|
||||
//$.console.log('contextmenu ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
||||
|
||||
var eventArgs = null;
|
||||
|
||||
var eventInfo = {
|
||||
originalEvent: event,
|
||||
eventType: 'contextmenu',
|
||||
@ -1952,17 +1955,18 @@
|
||||
|
||||
// ContextMenu
|
||||
if ( tracker.contextMenuHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
||||
tracker.contextMenuHandler(
|
||||
{
|
||||
eventArgs = {
|
||||
eventSource: tracker,
|
||||
position: getPointRelativeToAbsolute( getMouseAbsolute( event ), tracker.element ),
|
||||
originalEvent: eventInfo.originalEvent,
|
||||
preventDefault: eventInfo.preventDefault || eventInfo.defaultPrevented,
|
||||
userData: tracker.userData
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
tracker.contextMenuHandler( eventArgs );
|
||||
}
|
||||
|
||||
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
||||
if ( ( eventArgs && eventArgs.preventDefault ) || ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) ) {
|
||||
$.cancelEvent( event );
|
||||
}
|
||||
if ( eventInfo.stopPropagation ) {
|
||||
@ -2810,7 +2814,7 @@
|
||||
case 'pointerdown':
|
||||
eventInfo.isStopable = true;
|
||||
eventInfo.isCancelable = true;
|
||||
eventInfo.preventDefault = false;//tracker.hasGestureHandlers;
|
||||
eventInfo.preventDefault = false; // updatePointerDown() may set true (tracker.hasGestureHandlers)
|
||||
eventInfo.preventGesture = !tracker.hasGestureHandlers;
|
||||
eventInfo.stopPropagation = false;
|
||||
break;
|
||||
@ -2824,7 +2828,7 @@
|
||||
case 'wheel':
|
||||
eventInfo.isStopable = true;
|
||||
eventInfo.isCancelable = true;
|
||||
eventInfo.preventDefault = false;//tracker.hasScrollHandler;
|
||||
eventInfo.preventDefault = false; // handleWheelEvent() may set true (tracker.hasScrollHandler)
|
||||
eventInfo.preventGesture = !tracker.hasScrollHandler;
|
||||
eventInfo.stopPropagation = false;
|
||||
break;
|
||||
@ -2854,8 +2858,8 @@
|
||||
case 'contextmenu':
|
||||
eventInfo.isStopable = true;
|
||||
eventInfo.isCancelable = true;
|
||||
eventInfo.preventDefault = false;//tracker.hasContextMenuHandler;
|
||||
eventInfo.preventGesture = true;//!tracker.hasContextMenuHandler;
|
||||
eventInfo.preventDefault = false;
|
||||
eventInfo.preventGesture = false;
|
||||
eventInfo.stopPropagation = false;
|
||||
break;
|
||||
case 'pointerenter':
|
||||
|
@ -2546,6 +2546,13 @@ function onBlur(){
|
||||
}
|
||||
|
||||
function onCanvasContextMenu( event ) {
|
||||
var eventArgs = {
|
||||
tracker: event.eventSource,
|
||||
position: event.position,
|
||||
originalEvent: event.originalEvent,
|
||||
preventDefault: event.preventDefault
|
||||
};
|
||||
|
||||
/**
|
||||
* Raised when a contextmenu event occurs in the {@link OpenSeadragon.Viewer#canvas} element.
|
||||
*
|
||||
@ -2556,13 +2563,12 @@ function onCanvasContextMenu( event ) {
|
||||
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
||||
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
||||
* @property {Object} originalEvent - The original DOM event.
|
||||
* @property {Boolean} preventDefault - Set to true to prevent the default user-agent's handling of the contextmenu event.
|
||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||
*/
|
||||
this.raiseEvent( 'canvas-contextmenu', {
|
||||
tracker: event.eventSource,
|
||||
position: event.position,
|
||||
originalEvent: event.originalEvent
|
||||
});
|
||||
this.raiseEvent( 'canvas-contextmenu', eventArgs );
|
||||
|
||||
event.preventDefault = eventArgs.preventDefault;
|
||||
}
|
||||
|
||||
function onCanvasKeyDown( event ) {
|
||||
|
Loading…
Reference in New Issue
Block a user