mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 21:26:10 +03:00
MouseTracker Original Events in Handlers
Touch events bug fix. Now uses touch object(s) properly when calculating positions.
This commit is contained in:
parent
13415b36f3
commit
1dc2d7e011
@ -675,24 +675,26 @@
|
|||||||
|
|
||||||
event = $.getEvent( event );
|
event = $.getEvent( event );
|
||||||
|
|
||||||
if ( $.Browser.vendor == $.BROWSERS.IE &&
|
if ( !isTouch ) {
|
||||||
$.Browser.version < 9 &&
|
if ( $.Browser.vendor == $.BROWSERS.IE &&
|
||||||
delegate.capturing &&
|
$.Browser.version < 9 &&
|
||||||
!isChild( event.srcElement, tracker.element ) ) {
|
delegate.capturing &&
|
||||||
|
!isChild( event.srcElement, tracker.element ) ) {
|
||||||
|
|
||||||
triggerOthers( tracker, onMouseOver, event, isTouch );
|
triggerOthers( tracker, onMouseOver, event, isTouch );
|
||||||
}
|
}
|
||||||
|
|
||||||
var to = event.target ?
|
var to = event.target ?
|
||||||
event.target :
|
event.target :
|
||||||
event.srcElement,
|
event.srcElement,
|
||||||
from = event.relatedTarget ?
|
from = event.relatedTarget ?
|
||||||
event.relatedTarget :
|
event.relatedTarget :
|
||||||
event.fromElement;
|
event.fromElement;
|
||||||
|
|
||||||
if ( !isChild( tracker.element, to ) ||
|
if ( !isChild( tracker.element, to ) ||
|
||||||
isChild( tracker.element, from ) ) {
|
isChild( tracker.element, from ) ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate.insideElement = true;
|
delegate.insideElement = true;
|
||||||
@ -701,7 +703,7 @@
|
|||||||
propagate = tracker.enterHandler(
|
propagate = tracker.enterHandler(
|
||||||
tracker,
|
tracker,
|
||||||
{
|
{
|
||||||
position: getMouseRelative( event, tracker.element ),
|
position: getMouseRelative( isTouch ? event.changedTouches[ 0 ] : event, tracker.element ),
|
||||||
insideElementPressed: delegate.insideElementPressed,
|
insideElementPressed: delegate.insideElementPressed,
|
||||||
buttonDownAny: IS_BUTTON_DOWN,
|
buttonDownAny: IS_BUTTON_DOWN,
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
@ -728,25 +730,27 @@
|
|||||||
|
|
||||||
event = $.getEvent( event );
|
event = $.getEvent( event );
|
||||||
|
|
||||||
if ( $.Browser.vendor == $.BROWSERS.IE &&
|
if ( !isTouch ) {
|
||||||
$.Browser.version < 9 &&
|
if ( $.Browser.vendor == $.BROWSERS.IE &&
|
||||||
delegate.capturing &&
|
$.Browser.version < 9 &&
|
||||||
!isChild( event.srcElement, tracker.element ) ) {
|
delegate.capturing &&
|
||||||
|
!isChild( event.srcElement, tracker.element ) ) {
|
||||||
|
|
||||||
triggerOthers( tracker, onMouseOut, event, isTouch );
|
triggerOthers( tracker, onMouseOut, event, isTouch );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var from = event.target ?
|
var from = event.target ?
|
||||||
event.target :
|
event.target :
|
||||||
event.srcElement,
|
event.srcElement,
|
||||||
to = event.relatedTarget ?
|
to = event.relatedTarget ?
|
||||||
event.relatedTarget :
|
event.relatedTarget :
|
||||||
event.toElement;
|
event.toElement;
|
||||||
|
|
||||||
if ( !isChild( tracker.element, from ) ||
|
if ( !isChild( tracker.element, from ) ||
|
||||||
isChild( tracker.element, to ) ) {
|
isChild( tracker.element, to ) ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate.insideElement = false;
|
delegate.insideElement = false;
|
||||||
@ -755,7 +759,7 @@
|
|||||||
propagate = tracker.exitHandler(
|
propagate = tracker.exitHandler(
|
||||||
tracker,
|
tracker,
|
||||||
{
|
{
|
||||||
position: getMouseRelative( event, tracker.element ),
|
position: getMouseRelative( isTouch ? event.changedTouches[ 0 ] : event, tracker.element ),
|
||||||
insideElementPressed: delegate.insideElementPressed,
|
insideElementPressed: delegate.insideElementPressed,
|
||||||
buttonDownAny: IS_BUTTON_DOWN,
|
buttonDownAny: IS_BUTTON_DOWN,
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
@ -781,7 +785,9 @@
|
|||||||
|
|
||||||
isTouch = isTouch || false;
|
isTouch = isTouch || false;
|
||||||
|
|
||||||
event = $.getEvent( event );
|
var originalEvent = $.getEvent(event);
|
||||||
|
|
||||||
|
event = isTouch ? event.touches[ 0 ] : event;
|
||||||
|
|
||||||
if ( event.button == 2 ) {
|
if ( event.button == 2 ) {
|
||||||
return;
|
return;
|
||||||
@ -799,24 +805,25 @@
|
|||||||
{
|
{
|
||||||
position: getMouseRelative( event, tracker.element ),
|
position: getMouseRelative( event, tracker.element ),
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: originalEvent,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( propagate === false ) {
|
if ( propagate === false ) {
|
||||||
$.cancelEvent( event );
|
$.cancelEvent( originalEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tracker.pressHandler || tracker.dragHandler ) {
|
if ( tracker.pressHandler || tracker.dragHandler ) {
|
||||||
$.cancelEvent( event );
|
$.cancelEvent( originalEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( noCapture ) {
|
if ( noCapture ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !( $.Browser.vendor == $.BROWSERS.IE && $.Browser.version < 9 ) ||
|
if ( isTouch ||
|
||||||
|
!( $.Browser.vendor == $.BROWSERS.IE && $.Browser.version < 9 ) ||
|
||||||
!IS_CAPTURING ) {
|
!IS_CAPTURING ) {
|
||||||
captureMouse( tracker );
|
captureMouse( tracker );
|
||||||
IS_CAPTURING = true;
|
IS_CAPTURING = true;
|
||||||
@ -879,7 +886,9 @@
|
|||||||
|
|
||||||
isTouch = isTouch || false;
|
isTouch = isTouch || false;
|
||||||
|
|
||||||
event = $.getEvent( event );
|
var originalEvent = $.getEvent(event);
|
||||||
|
|
||||||
|
event = isTouch ? event.changedTouches[ 0 ] : event;
|
||||||
|
|
||||||
if ( event.button == 2 ) {
|
if ( event.button == 2 ) {
|
||||||
return;
|
return;
|
||||||
@ -895,17 +904,17 @@
|
|||||||
insideElementPressed: insideElementPressed,
|
insideElementPressed: insideElementPressed,
|
||||||
insideElementRelease: insideElementRelease,
|
insideElementRelease: insideElementRelease,
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: originalEvent,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( propagate === false ) {
|
if ( propagate === false ) {
|
||||||
$.cancelEvent( event );
|
$.cancelEvent( originalEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( insideElementPressed && insideElementRelease ) {
|
if ( insideElementPressed && insideElementRelease ) {
|
||||||
handleMouseClick( tracker, event );
|
handleMouseClick( tracker, originalEvent, isTouch );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1064,6 +1073,9 @@
|
|||||||
propagate = tracker.scrollHandler(
|
propagate = tracker.scrollHandler(
|
||||||
tracker,
|
tracker,
|
||||||
{
|
{
|
||||||
|
// Note: Ok to call getMouseRelative on passed event for isTouch==true since
|
||||||
|
// event.pageX/event.pageY are added to the original touchmove event in
|
||||||
|
// onTouchMove().
|
||||||
position: getMouseRelative( event, tracker.element ),
|
position: getMouseRelative( event, tracker.element ),
|
||||||
scroll: nDelta,
|
scroll: nDelta,
|
||||||
shift: event.shiftKey,
|
shift: event.shiftKey,
|
||||||
@ -1083,11 +1095,15 @@
|
|||||||
* @private
|
* @private
|
||||||
* @inner
|
* @inner
|
||||||
*/
|
*/
|
||||||
function handleMouseClick( tracker, event ) {
|
function handleMouseClick( tracker, event, isTouch ) {
|
||||||
var delegate = THIS[tracker.hash],
|
var delegate = THIS[tracker.hash],
|
||||||
propagate;
|
propagate;
|
||||||
|
|
||||||
event = $.getEvent( event );
|
isTouch = isTouch || false;
|
||||||
|
|
||||||
|
var originalEvent = $.getEvent( event );
|
||||||
|
|
||||||
|
event = isTouch ? event.changedTouches[0] : event;
|
||||||
|
|
||||||
if ( event.button == 2 ) {
|
if ( event.button == 2 ) {
|
||||||
return;
|
return;
|
||||||
@ -1105,14 +1121,14 @@
|
|||||||
{
|
{
|
||||||
position: getMouseRelative( event, tracker.element ),
|
position: getMouseRelative( event, tracker.element ),
|
||||||
quick: quick,
|
quick: quick,
|
||||||
shift: event.shiftKey,
|
shift: originalEvent.shiftKey,
|
||||||
isTouchEvent: false,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: originalEvent,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( propagate === false ) {
|
if ( propagate === false ) {
|
||||||
$.cancelEvent( event );
|
$.cancelEvent( originalEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1130,7 +1146,8 @@
|
|||||||
|
|
||||||
isTouch = isTouch || false;
|
isTouch = isTouch || false;
|
||||||
|
|
||||||
event = $.getEvent( event );
|
var originalEvent = $.getEvent(event);
|
||||||
|
event = isTouch ? event.touches[0] : event;
|
||||||
point = getMouseAbsolute( event );
|
point = getMouseAbsolute( event );
|
||||||
delta = point.minus( delegate.lastPoint );
|
delta = point.minus( delegate.lastPoint );
|
||||||
|
|
||||||
@ -1142,14 +1159,14 @@
|
|||||||
{
|
{
|
||||||
position: getMouseRelative( event, tracker.element ),
|
position: getMouseRelative( event, tracker.element ),
|
||||||
delta: delta,
|
delta: delta,
|
||||||
shift: event.shiftKey,
|
shift: originalEvent.shiftKey,
|
||||||
isTouchEvent: isTouch,
|
isTouchEvent: isTouch,
|
||||||
originalEvent: event,
|
originalEvent: originalEvent,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( propagate === false ) {
|
if ( propagate === false ) {
|
||||||
$.cancelEvent( event );
|
$.cancelEvent( originalEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user