mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
Work in progress for being able to control when we cancel events.
This commit is contained in:
parent
00551e6c2b
commit
0571e31de4
@ -1963,7 +1963,7 @@
|
|||||||
currentTime: $.now()
|
currentTime: $.now()
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( updatePointersDown( tracker, event, [ gPoint ], getStandardizedButton( event.button ) ) ) {
|
if ( updatePointersDown( tracker, event, [ gPoint ], getStandardizedButton( event.button ) ).capture ) {
|
||||||
$.stopEvent( event );
|
$.stopEvent( event );
|
||||||
capturePointer( tracker, 'mouse' );
|
capturePointer( tracker, 'mouse' );
|
||||||
}
|
}
|
||||||
@ -2139,13 +2139,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( updatePointersDown( tracker, event, gPoints, 0 ) ) { // 0 means primary button press/release or touch contact
|
var result = updatePointersDown( tracker, event, gPoints, 0 ); // 0 means primary button press/release or touch contact
|
||||||
|
if ( result.capture && result.cancel ) {
|
||||||
$.stopEvent( event );
|
$.stopEvent( event );
|
||||||
capturePointer( tracker, 'touch', touchCount );
|
capturePointer( tracker, 'touch', touchCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result.cancel) {
|
||||||
$.cancelEvent( event );
|
$.cancelEvent( event );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2263,10 +2266,12 @@
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePointersMove( tracker, event, gPoints );
|
var result = updatePointersMove( tracker, event, gPoints );
|
||||||
|
|
||||||
|
if (result.cancel) {
|
||||||
$.cancelEvent( event );
|
$.cancelEvent( event );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2363,7 +2368,7 @@
|
|||||||
currentTime: $.now()
|
currentTime: $.now()
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( updatePointersDown( tracker, event, [ gPoint ], event.button ) ) {
|
if ( updatePointersDown( tracker, event, [ gPoint ], event.button ).capture ) {
|
||||||
$.stopEvent( event );
|
$.stopEvent( event );
|
||||||
capturePointer( tracker, gPoint.type );
|
capturePointer( tracker, gPoint.type );
|
||||||
}
|
}
|
||||||
@ -2696,7 +2701,8 @@
|
|||||||
* Note on chorded button presses (a button pressed when another button is already pressed): In the W3C Pointer Events model,
|
* Note on chorded button presses (a button pressed when another button is already pressed): In the W3C Pointer Events model,
|
||||||
* only one pointerdown/pointerup event combo is fired. Chorded button state changes instead fire pointermove events.
|
* only one pointerdown/pointerup event combo is fired. Chorded button state changes instead fire pointermove events.
|
||||||
*
|
*
|
||||||
* @returns {Boolean} True if pointers should be captured to the tracked element, otherwise false.
|
* @returns {Object} Properties: capture: True if pointers should be captured to the tracked element, otherwise false.
|
||||||
|
* TODO: Document cancel
|
||||||
*/
|
*/
|
||||||
function updatePointersDown( tracker, event, gPoints, buttonChanged ) {
|
function updatePointersDown( tracker, event, gPoints, buttonChanged ) {
|
||||||
var delegate = THIS[ tracker.hash ],
|
var delegate = THIS[ tracker.hash ],
|
||||||
@ -2707,6 +2713,11 @@
|
|||||||
curGPoint,
|
curGPoint,
|
||||||
updateGPoint;
|
updateGPoint;
|
||||||
|
|
||||||
|
var output = {
|
||||||
|
capture: false,
|
||||||
|
cancel: true
|
||||||
|
};
|
||||||
|
|
||||||
if ( typeof event.buttons !== 'undefined' ) {
|
if ( typeof event.buttons !== 'undefined' ) {
|
||||||
pointsList.buttons = event.buttons;
|
pointsList.buttons = event.buttons;
|
||||||
} else {
|
} else {
|
||||||
@ -2783,7 +2794,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = 0; i < gPointCount; i++ ) {
|
for ( i = 0; i < gPointCount; i++ ) {
|
||||||
@ -2821,8 +2832,7 @@
|
|||||||
if ( pointsList.contacts === 1 ) {
|
if ( pointsList.contacts === 1 ) {
|
||||||
// Press
|
// Press
|
||||||
if ( tracker.pressHandler ) {
|
if ( tracker.pressHandler ) {
|
||||||
propagate = tracker.pressHandler(
|
var outgoingEvent = {
|
||||||
{
|
|
||||||
eventSource: tracker,
|
eventSource: tracker,
|
||||||
pointerType: curGPoint.type,
|
pointerType: curGPoint.type,
|
||||||
position: getPointRelativeToAbsolute( curGPoint.contactPos, tracker.element ),
|
position: getPointRelativeToAbsolute( curGPoint.contactPos, tracker.element ),
|
||||||
@ -2831,11 +2841,16 @@
|
|||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
preventDefaultAction: false,
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
};
|
||||||
);
|
|
||||||
|
propagate = tracker.pressHandler(outgoingEvent);
|
||||||
if ( propagate === false ) {
|
if ( propagate === false ) {
|
||||||
$.cancelEvent( event );
|
$.cancelEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outgoingEvent.preventDefaultAction) {
|
||||||
|
output.cancel = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if ( pointsList.contacts === 2 ) {
|
} else if ( pointsList.contacts === 2 ) {
|
||||||
if ( tracker.pinchHandler && curGPoint.type === 'touch' ) {
|
if ( tracker.pinchHandler && curGPoint.type === 'touch' ) {
|
||||||
@ -2847,7 +2862,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
output.capture = true;
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3156,6 +3172,10 @@
|
|||||||
delta,
|
delta,
|
||||||
propagate;
|
propagate;
|
||||||
|
|
||||||
|
var output = {
|
||||||
|
cancel: true
|
||||||
|
};
|
||||||
|
|
||||||
if ( typeof event.buttons !== 'undefined' ) {
|
if ( typeof event.buttons !== 'undefined' ) {
|
||||||
pointsList.buttons = event.buttons;
|
pointsList.buttons = event.buttons;
|
||||||
}
|
}
|
||||||
@ -3234,8 +3254,7 @@
|
|||||||
if ( tracker.dragHandler ) {
|
if ( tracker.dragHandler ) {
|
||||||
updateGPoint = pointsList.asArray()[ 0 ];
|
updateGPoint = pointsList.asArray()[ 0 ];
|
||||||
delta = updateGPoint.currentPos.minus( updateGPoint.lastPos );
|
delta = updateGPoint.currentPos.minus( updateGPoint.lastPos );
|
||||||
propagate = tracker.dragHandler(
|
var outgoingEvent = {
|
||||||
{
|
|
||||||
eventSource: tracker,
|
eventSource: tracker,
|
||||||
pointerType: updateGPoint.type,
|
pointerType: updateGPoint.type,
|
||||||
position: getPointRelativeToAbsolute( updateGPoint.currentPos, tracker.element ),
|
position: getPointRelativeToAbsolute( updateGPoint.currentPos, tracker.element ),
|
||||||
@ -3248,11 +3267,14 @@
|
|||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
preventDefaultAction: false,
|
preventDefaultAction: false,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
};
|
||||||
);
|
propagate = tracker.dragHandler(outgoingEvent);
|
||||||
if ( propagate === false ) {
|
if ( propagate === false ) {
|
||||||
$.cancelEvent( event );
|
$.cancelEvent( event );
|
||||||
}
|
}
|
||||||
|
if (outgoingEvent.preventDefaultAction) {
|
||||||
|
output.cancel = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if ( pointsList.contacts === 2 ) {
|
} else if ( pointsList.contacts === 2 ) {
|
||||||
// Move (2 contacts, use center)
|
// Move (2 contacts, use center)
|
||||||
@ -3304,6 +3326,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2790,6 +2790,7 @@ function onCanvasDrag( event ) {
|
|||||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
*/
|
*/
|
||||||
this.raiseEvent( 'canvas-drag', canvasDragEventArgs);
|
this.raiseEvent( 'canvas-drag', canvasDragEventArgs);
|
||||||
|
event.preventDefaultAction = canvasDragEventArgs.preventDefaultAction;
|
||||||
|
|
||||||
if ( !canvasDragEventArgs.preventDefaultAction && this.viewport ) {
|
if ( !canvasDragEventArgs.preventDefaultAction && this.viewport ) {
|
||||||
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
||||||
@ -2942,6 +2943,15 @@ function onCanvasExit( event ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasPress( event ) {
|
function onCanvasPress( event ) {
|
||||||
|
var canvasPressEventArgs = {
|
||||||
|
tracker: event.eventSource,
|
||||||
|
pointerType: event.pointerType,
|
||||||
|
position: event.position,
|
||||||
|
insideElementPressed: event.insideElementPressed,
|
||||||
|
insideElementReleased: event.insideElementReleased,
|
||||||
|
originalEvent: event.originalEvent
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Raised when the primary mouse button is pressed or touch starts on the {@link OpenSeadragon.Viewer#canvas} element.
|
* Raised when the primary mouse button is pressed or touch starts on the {@link OpenSeadragon.Viewer#canvas} element.
|
||||||
*
|
*
|
||||||
@ -2957,14 +2967,9 @@ function onCanvasPress( event ) {
|
|||||||
* @property {Object} originalEvent - The original DOM event.
|
* @property {Object} originalEvent - The original DOM event.
|
||||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
*/
|
*/
|
||||||
this.raiseEvent( 'canvas-press', {
|
this.raiseEvent( 'canvas-press', canvasPressEventArgs);
|
||||||
tracker: event.eventSource,
|
|
||||||
pointerType: event.pointerType,
|
event.preventDefaultAction = canvasPressEventArgs.preventDefaultAction;
|
||||||
position: event.position,
|
|
||||||
insideElementPressed: event.insideElementPressed,
|
|
||||||
insideElementReleased: event.insideElementReleased,
|
|
||||||
originalEvent: event.originalEvent
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasRelease( event ) {
|
function onCanvasRelease( event ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user