2013-05-01 08:46:16 +04:00
|
|
|
/*
|
2013-05-14 08:00:24 +04:00
|
|
|
* OpenSeadragon - MouseTracker
|
2013-05-01 08:46:16 +04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 CodePlex Foundation
|
2013-05-14 07:32:09 +04:00
|
|
|
* Copyright (C) 2010-2013 OpenSeadragon contributors
|
2013-05-01 08:46:16 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* - Neither the name of CodePlex Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2013-09-06 04:20:17 +04:00
|
|
|
(function ( $ ) {
|
|
|
|
|
2015-01-15 23:15:22 +03:00
|
|
|
// All MouseTracker instances
|
|
|
|
var MOUSETRACKERS = [];
|
|
|
|
|
|
|
|
// dictionary from hash to private properties
|
2014-04-15 05:17:18 +04:00
|
|
|
var THIS = {};
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2014-03-21 22:45:20 +04:00
|
|
|
|
2012-01-25 23:14:02 +04:00
|
|
|
/**
|
2013-11-16 10:19:53 +04:00
|
|
|
* @class MouseTracker
|
2014-04-22 20:23:56 +04:00
|
|
|
* @classdesc Provides simplified handling of common pointer device (mouse, touch, pen, etc.) gestures
|
|
|
|
* and keyboard events on a specified element.
|
2013-11-16 10:19:53 +04:00
|
|
|
* @memberof OpenSeadragon
|
2013-09-06 21:43:39 +04:00
|
|
|
* @param {Object} options
|
|
|
|
* Allows configurable properties to be entirely specified by passing
|
|
|
|
* an options object to the constructor. The constructor also supports
|
2013-11-25 20:48:44 +04:00
|
|
|
* the original positional arguments 'element', 'clickTimeThreshold',
|
2013-09-06 21:43:39 +04:00
|
|
|
* and 'clickDistThreshold' in that order.
|
|
|
|
* @param {Element|String} options.element
|
2014-04-01 20:32:04 +04:00
|
|
|
* A reference to an element or an element id for which the pointer/key
|
2013-09-06 21:43:39 +04:00
|
|
|
* events will be monitored.
|
2015-01-21 05:35:58 +03:00
|
|
|
* @param {Boolean} [options.startDisabled=false]
|
|
|
|
* If true, event tracking on the element will not start until
|
|
|
|
* {@link OpenSeadragon.MouseTracker.setTracking|setTracking} is called.
|
2013-09-06 21:43:39 +04:00
|
|
|
* @param {Number} options.clickTimeThreshold
|
2014-04-22 20:23:56 +04:00
|
|
|
* The number of milliseconds within which a pointer down-up event combination
|
|
|
|
* will be treated as a click gesture.
|
2013-09-06 21:43:39 +04:00
|
|
|
* @param {Number} options.clickDistThreshold
|
2014-04-22 20:23:56 +04:00
|
|
|
* The maximum distance allowed between a pointer down event and a pointer up event
|
|
|
|
* to be treated as a click gesture.
|
|
|
|
* @param {Number} options.dblClickTimeThreshold
|
|
|
|
* The number of milliseconds within which two pointer down-up event combinations
|
|
|
|
* will be treated as a double-click gesture.
|
|
|
|
* @param {Number} options.dblClickDistThreshold
|
|
|
|
* The maximum distance allowed between two pointer click events
|
|
|
|
* to be treated as a click gesture.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {Number} [options.stopDelay=50]
|
2014-04-01 20:32:04 +04:00
|
|
|
* The number of milliseconds without pointer move before the stop
|
2013-10-23 00:54:04 +04:00
|
|
|
* event is fired.
|
2020-08-13 07:22:48 +03:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.preProcessEventHandler=null]
|
|
|
|
* An optional handler for controlling DOM event propagation and processing.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.enterHandler=null]
|
2014-04-01 20:32:04 +04:00
|
|
|
* An optional handler for pointer enter.
|
2020-07-25 06:05:39 +03:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.leaveHandler=null]
|
|
|
|
* An optional handler for pointer leave.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.exitHandler=null]
|
2020-07-25 06:05:39 +03:00
|
|
|
* An optional handler for pointer leave. <span style="color:red;">Deprecated. Use leaveHandler instead.</span>
|
|
|
|
* @param {OpenSeadragon.EventHandler} [options.overHandler=null]
|
|
|
|
* An optional handler for pointer over.
|
|
|
|
* @param {OpenSeadragon.EventHandler} [options.outHandler=null]
|
|
|
|
* An optional handler for pointer out.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.pressHandler=null]
|
2014-04-01 20:32:04 +04:00
|
|
|
* An optional handler for pointer press.
|
2015-01-12 22:02:54 +03:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.nonPrimaryPressHandler=null]
|
2015-01-11 01:49:02 +03:00
|
|
|
* An optional handler for pointer non-primary button press.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.releaseHandler=null]
|
2014-04-01 20:32:04 +04:00
|
|
|
* An optional handler for pointer release.
|
2015-01-12 22:02:54 +03:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.nonPrimaryReleaseHandler=null]
|
2015-01-11 01:49:02 +03:00
|
|
|
* An optional handler for pointer non-primary button release.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.moveHandler=null]
|
2014-04-01 20:32:04 +04:00
|
|
|
* An optional handler for pointer move.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.scrollHandler=null]
|
2014-04-01 20:32:04 +04:00
|
|
|
* An optional handler for mouse wheel scroll.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.clickHandler=null]
|
2014-04-01 20:32:04 +04:00
|
|
|
* An optional handler for pointer click.
|
2014-04-22 20:23:56 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.dblClickHandler=null]
|
|
|
|
* An optional handler for pointer double-click.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.dragHandler=null]
|
2014-03-10 22:49:51 +04:00
|
|
|
* An optional handler for the drag gesture.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.dragEndHandler=null]
|
|
|
|
* An optional handler for after a drag gesture.
|
2014-03-10 22:49:51 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.pinchHandler=null]
|
|
|
|
* An optional handler for the pinch gesture.
|
2015-01-17 03:26:30 +03:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.keyDownHandler=null]
|
|
|
|
* An optional handler for keydown.
|
|
|
|
* @param {OpenSeadragon.EventHandler} [options.keyUpHandler=null]
|
|
|
|
* An optional handler for keyup.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.keyHandler=null]
|
2013-09-06 21:43:39 +04:00
|
|
|
* An optional handler for keypress.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.focusHandler=null]
|
2013-09-06 21:43:39 +04:00
|
|
|
* An optional handler for focus.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.blurHandler=null]
|
2013-09-06 21:43:39 +04:00
|
|
|
* An optional handler for blur.
|
2013-09-12 21:05:50 +04:00
|
|
|
* @param {Object} [options.userData=null]
|
|
|
|
* Arbitrary object to be passed unchanged to any attached handler methods.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2012-02-03 04:12:45 +04:00
|
|
|
$.MouseTracker = function ( options ) {
|
|
|
|
|
2015-01-15 23:15:22 +03:00
|
|
|
MOUSETRACKERS.push( this );
|
|
|
|
|
2013-09-06 04:20:17 +04:00
|
|
|
var args = arguments;
|
2012-02-03 04:12:45 +04:00
|
|
|
|
2013-09-06 04:20:17 +04:00
|
|
|
if ( !$.isPlainObject( options ) ) {
|
2012-02-03 04:12:45 +04:00
|
|
|
options = {
|
2013-09-20 20:58:18 +04:00
|
|
|
element: args[ 0 ],
|
|
|
|
clickTimeThreshold: args[ 1 ],
|
|
|
|
clickDistThreshold: args[ 2 ]
|
2012-02-03 04:12:45 +04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-11-25 20:48:44 +04:00
|
|
|
this.hash = Math.random(); // An unique hash for this tracker.
|
|
|
|
/**
|
2014-04-01 20:32:04 +04:00
|
|
|
* The element for which pointer events are being monitored.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @member {Element} element
|
|
|
|
* @memberof OpenSeadragon.MouseTracker#
|
|
|
|
*/
|
2012-02-03 04:12:45 +04:00
|
|
|
this.element = $.getElement( options.element );
|
2013-11-25 20:48:44 +04:00
|
|
|
/**
|
2015-06-08 17:38:16 +03:00
|
|
|
* The number of milliseconds within which a pointer down-up event combination
|
2014-04-22 20:23:56 +04:00
|
|
|
* will be treated as a click gesture.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @member {Number} clickTimeThreshold
|
|
|
|
* @memberof OpenSeadragon.MouseTracker#
|
|
|
|
*/
|
2014-08-06 00:56:18 +04:00
|
|
|
this.clickTimeThreshold = options.clickTimeThreshold || $.DEFAULT_SETTINGS.clickTimeThreshold;
|
2013-11-25 20:48:44 +04:00
|
|
|
/**
|
2014-04-22 20:23:56 +04:00
|
|
|
* The maximum distance allowed between a pointer down event and a pointer up event
|
|
|
|
* to be treated as a click gesture.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @member {Number} clickDistThreshold
|
|
|
|
* @memberof OpenSeadragon.MouseTracker#
|
|
|
|
*/
|
2014-08-06 00:56:18 +04:00
|
|
|
this.clickDistThreshold = options.clickDistThreshold || $.DEFAULT_SETTINGS.clickDistThreshold;
|
2014-04-22 20:23:56 +04:00
|
|
|
/**
|
|
|
|
* The number of milliseconds within which two pointer down-up event combinations
|
|
|
|
* will be treated as a double-click gesture.
|
|
|
|
* @member {Number} dblClickTimeThreshold
|
|
|
|
* @memberof OpenSeadragon.MouseTracker#
|
|
|
|
*/
|
2014-08-06 00:56:18 +04:00
|
|
|
this.dblClickTimeThreshold = options.dblClickTimeThreshold || $.DEFAULT_SETTINGS.dblClickTimeThreshold;
|
2014-04-22 20:23:56 +04:00
|
|
|
/**
|
|
|
|
* The maximum distance allowed between two pointer click events
|
|
|
|
* to be treated as a click gesture.
|
|
|
|
* @member {Number} clickDistThreshold
|
|
|
|
* @memberof OpenSeadragon.MouseTracker#
|
|
|
|
*/
|
2014-08-06 00:56:18 +04:00
|
|
|
this.dblClickDistThreshold = options.dblClickDistThreshold || $.DEFAULT_SETTINGS.dblClickDistThreshold;
|
2017-01-08 17:52:57 +03:00
|
|
|
/*eslint-disable no-multi-spaces*/
|
2015-01-12 22:02:54 +03:00
|
|
|
this.userData = options.userData || null;
|
|
|
|
this.stopDelay = options.stopDelay || 50;
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
this.preProcessEventHandler = options.preProcessEventHandler || null;
|
2015-01-12 22:02:54 +03:00
|
|
|
this.enterHandler = options.enterHandler || null;
|
2020-07-25 06:05:39 +03:00
|
|
|
this.leaveHandler = options.leaveHandler || null;
|
2020-08-14 03:21:32 +03:00
|
|
|
this.exitHandler = options.exitHandler || null; // Deprecated v2.5.0
|
2020-07-25 06:05:39 +03:00
|
|
|
this.overHandler = options.overHandler || null;
|
|
|
|
this.outHandler = options.outHandler || null;
|
2015-01-12 22:02:54 +03:00
|
|
|
this.pressHandler = options.pressHandler || null;
|
|
|
|
this.nonPrimaryPressHandler = options.nonPrimaryPressHandler || null;
|
|
|
|
this.releaseHandler = options.releaseHandler || null;
|
|
|
|
this.nonPrimaryReleaseHandler = options.nonPrimaryReleaseHandler || null;
|
|
|
|
this.moveHandler = options.moveHandler || null;
|
|
|
|
this.scrollHandler = options.scrollHandler || null;
|
|
|
|
this.clickHandler = options.clickHandler || null;
|
|
|
|
this.dblClickHandler = options.dblClickHandler || null;
|
|
|
|
this.dragHandler = options.dragHandler || null;
|
|
|
|
this.dragEndHandler = options.dragEndHandler || null;
|
|
|
|
this.pinchHandler = options.pinchHandler || null;
|
|
|
|
this.stopHandler = options.stopHandler || null;
|
2015-01-17 03:26:30 +03:00
|
|
|
this.keyDownHandler = options.keyDownHandler || null;
|
|
|
|
this.keyUpHandler = options.keyUpHandler || null;
|
2015-01-12 22:02:54 +03:00
|
|
|
this.keyHandler = options.keyHandler || null;
|
|
|
|
this.focusHandler = options.focusHandler || null;
|
|
|
|
this.blurHandler = options.blurHandler || null;
|
2017-01-08 17:52:57 +03:00
|
|
|
/*eslint-enable no-multi-spaces*/
|
2012-02-03 04:12:45 +04:00
|
|
|
|
|
|
|
//Store private properties in a scope sealed hash map
|
|
|
|
var _this = this;
|
2012-02-10 07:16:09 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @property {Boolean} tracking
|
2014-04-15 05:17:18 +04:00
|
|
|
* Are we currently tracking pointer events for this element.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-20 20:58:18 +04:00
|
|
|
THIS[ this.hash ] = {
|
2014-03-10 22:49:51 +04:00
|
|
|
click: function ( event ) { onClick( _this, event ); },
|
2014-04-22 20:23:56 +04:00
|
|
|
dblclick: function ( event ) { onDblClick( _this, event ); },
|
2015-01-17 03:26:30 +03:00
|
|
|
keydown: function ( event ) { onKeyDown( _this, event ); },
|
|
|
|
keyup: function ( event ) { onKeyUp( _this, event ); },
|
2014-03-10 22:49:51 +04:00
|
|
|
keypress: function ( event ) { onKeyPress( _this, event ); },
|
|
|
|
focus: function ( event ) { onFocus( _this, event ); },
|
|
|
|
blur: function ( event ) { onBlur( _this, event ); },
|
2014-03-21 22:45:20 +04:00
|
|
|
|
2013-10-23 23:58:36 +04:00
|
|
|
wheel: function ( event ) { onWheel( _this, event ); },
|
|
|
|
mousewheel: function ( event ) { onMouseWheel( _this, event ); },
|
|
|
|
DOMMouseScroll: function ( event ) { onMouseWheel( _this, event ); },
|
2013-10-25 00:39:00 +04:00
|
|
|
MozMousePixelScroll: function ( event ) { onMouseWheel( _this, event ); },
|
2014-03-21 22:45:20 +04:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
losecapture: function ( event ) { onLoseCapture( _this, event ); },
|
2020-07-25 06:05:39 +03:00
|
|
|
mouseenter: function ( event ) { onMouseEnter( _this, event ); },
|
|
|
|
mouseleave: function ( event ) { onMouseLeave( _this, event ); },
|
2020-07-26 04:30:06 +03:00
|
|
|
mouseover: function ( event ) { onMouseOver( _this, event ); }, // IE9+ only
|
|
|
|
mouseout: function ( event ) { onMouseOut( _this, event ); }, // IE9+ only
|
2014-03-21 22:45:20 +04:00
|
|
|
mousedown: function ( event ) { onMouseDown( _this, event ); },
|
|
|
|
mouseup: function ( event ) { onMouseUp( _this, event ); },
|
|
|
|
mouseupcaptured: function ( event ) { onMouseUpCaptured( _this, event ); },
|
|
|
|
mousemove: function ( event ) { onMouseMove( _this, event ); },
|
|
|
|
mousemovecaptured: function ( event ) { onMouseMoveCaptured( _this, event ); },
|
2014-09-13 03:22:55 +04:00
|
|
|
|
2014-03-21 22:45:20 +04:00
|
|
|
touchstart: function ( event ) { onTouchStart( _this, event ); },
|
|
|
|
touchend: function ( event ) { onTouchEnd( _this, event ); },
|
|
|
|
touchmove: function ( event ) { onTouchMove( _this, event ); },
|
|
|
|
touchcancel: function ( event ) { onTouchCancel( _this, event ); },
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
gesturestart: function ( event ) { onGestureStart( _this, event ); }, // Safari/Safari iOS
|
|
|
|
gesturechange: function ( event ) { onGestureChange( _this, event ); }, // Safari/Safari iOS
|
|
|
|
|
|
|
|
MSGestureStart: function ( event ) { onGestureStart( _this, event ); }, // IE10
|
|
|
|
MSGestureChange: function ( event ) { onGestureChange( _this, event ); }, // IE10
|
2014-03-21 22:45:20 +04:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
gotpointercapture: function ( event ) { onGotPointerCapture( _this, event ); },
|
|
|
|
MSGotPointerCapture: function ( event ) { onGotPointerCapture( _this, event ); },
|
|
|
|
lostpointercapture: function ( event ) { onLostPointerCapture( _this, event ); },
|
|
|
|
MSLostPointerCapture: function ( event ) { onLostPointerCapture( _this, event ); },
|
2020-07-26 04:30:06 +03:00
|
|
|
pointerenter: function ( event ) { onPointerEnter( _this, event ); },
|
|
|
|
pointerleave: function ( event ) { onPointerLeave( _this, event ); },
|
2014-08-05 08:41:07 +04:00
|
|
|
pointerover: function ( event ) { onPointerOver( _this, event ); },
|
|
|
|
MSPointerOver: function ( event ) { onPointerOver( _this, event ); },
|
|
|
|
pointerout: function ( event ) { onPointerOut( _this, event ); },
|
|
|
|
MSPointerOut: function ( event ) { onPointerOut( _this, event ); },
|
2014-03-10 22:49:51 +04:00
|
|
|
pointerdown: function ( event ) { onPointerDown( _this, event ); },
|
|
|
|
MSPointerDown: function ( event ) { onPointerDown( _this, event ); },
|
|
|
|
pointerup: function ( event ) { onPointerUp( _this, event ); },
|
|
|
|
MSPointerUp: function ( event ) { onPointerUp( _this, event ); },
|
|
|
|
pointermove: function ( event ) { onPointerMove( _this, event ); },
|
|
|
|
MSPointerMove: function ( event ) { onPointerMove( _this, event ); },
|
|
|
|
pointercancel: function ( event ) { onPointerCancel( _this, event ); },
|
|
|
|
MSPointerCancel: function ( event ) { onPointerCancel( _this, event ); },
|
2014-08-05 08:41:07 +04:00
|
|
|
pointerupcaptured: function ( event ) { onPointerUpCaptured( _this, event ); },
|
|
|
|
pointermovecaptured: function ( event ) { onPointerMoveCaptured( _this, event ); },
|
2014-03-21 22:45:20 +04:00
|
|
|
|
|
|
|
tracking: false,
|
2014-04-15 05:17:18 +04:00
|
|
|
|
|
|
|
// Active pointers lists. Array of GesturePointList objects, one for each pointer device type.
|
|
|
|
// GesturePointList objects are added each time a pointer is tracked by a new pointer device type (see getActivePointersListByType()).
|
2015-06-08 17:38:16 +03:00
|
|
|
// Active pointers are any pointer being tracked for this element which are in the hit-test area
|
2014-04-15 05:17:18 +04:00
|
|
|
// of the element (for hover-capable devices) and/or have contact or a button press initiated in the element.
|
|
|
|
activePointersLists: [],
|
|
|
|
|
2014-04-22 20:23:56 +04:00
|
|
|
// Tracking for double-click gesture
|
|
|
|
lastClickPos: null,
|
|
|
|
dblClickTimeOut: null,
|
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
// Tracking for pinch gesture
|
2014-03-21 22:45:20 +04:00
|
|
|
pinchGPoints: [],
|
2014-03-10 22:49:51 +04:00
|
|
|
lastPinchDist: 0,
|
|
|
|
currentPinchDist: 0,
|
2014-03-15 01:15:09 +04:00
|
|
|
lastPinchCenter: null,
|
2014-03-30 04:02:24 +04:00
|
|
|
currentPinchCenter: null
|
2012-02-02 01:56:04 +04:00
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
this.hasGestureHandlers = !!( this.pressHandler || this.nonPrimaryPressHandler ||
|
|
|
|
this.releaseHandler || this.nonPrimaryReleaseHandler ||
|
|
|
|
this.clickHandler || this.dblClickHandler ||
|
|
|
|
this.dragHandler || this.dragEndHandler ||
|
|
|
|
this.pinchHandler );
|
|
|
|
this.hasScrollHandler = !!this.scrollHandler;
|
|
|
|
|
2015-01-21 05:35:58 +03:00
|
|
|
if ( !options.startDisabled ) {
|
|
|
|
this.setTracking( true );
|
|
|
|
}
|
2012-02-02 01:56:04 +04:00
|
|
|
};
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2016-01-25 00:09:18 +03:00
|
|
|
/** @lends OpenSeadragon.MouseTracker.prototype */
|
|
|
|
$.MouseTracker.prototype = {
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2013-08-08 11:49:24 +04:00
|
|
|
/**
|
2014-04-01 20:32:04 +04:00
|
|
|
* Clean up any events or objects created by the tracker.
|
2013-09-06 21:43:39 +04:00
|
|
|
* @function
|
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
destroy: function () {
|
2015-01-15 23:15:22 +03:00
|
|
|
var i;
|
|
|
|
|
2013-08-08 11:49:24 +04:00
|
|
|
stopTracking( this );
|
|
|
|
this.element = null;
|
2014-06-18 21:35:23 +04:00
|
|
|
|
2015-01-15 23:15:22 +03:00
|
|
|
for ( i = 0; i < MOUSETRACKERS.length; i++ ) {
|
|
|
|
if ( MOUSETRACKERS[ i ] === this ) {
|
|
|
|
MOUSETRACKERS.splice( i, 1 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-18 21:35:23 +04:00
|
|
|
THIS[ this.hash ] = null;
|
|
|
|
delete THIS[ this.hash ];
|
2013-08-08 11:49:24 +04:00
|
|
|
},
|
|
|
|
|
2012-02-02 01:56:04 +04:00
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* Are we currently tracking events on this element.
|
|
|
|
* @deprecated Just use this.tracking
|
|
|
|
* @function
|
|
|
|
* @returns {Boolean} Are we currently tracking events on this element.
|
|
|
|
*/
|
2012-02-02 01:56:04 +04:00
|
|
|
isTracking: function () {
|
2013-09-20 20:58:18 +04:00
|
|
|
return THIS[ this.hash ].tracking;
|
2012-02-02 01:56:04 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* Enable or disable whether or not we are tracking events on this element.
|
|
|
|
* @function
|
|
|
|
* @param {Boolean} track True to start tracking, false to stop tracking.
|
|
|
|
* @returns {OpenSeadragon.MouseTracker} Chainable.
|
|
|
|
*/
|
2012-02-02 01:56:04 +04:00
|
|
|
setTracking: function ( track ) {
|
|
|
|
if ( track ) {
|
2012-02-03 04:12:45 +04:00
|
|
|
startTracking( this );
|
2011-12-14 05:04:38 +04:00
|
|
|
} else {
|
2012-02-03 04:12:45 +04:00
|
|
|
stopTracking( this );
|
2011-12-14 05:04:38 +04:00
|
|
|
}
|
2012-02-03 04:12:45 +04:00
|
|
|
//chain
|
|
|
|
return this;
|
2012-02-02 01:56:04 +04:00
|
|
|
},
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2020-08-14 02:43:49 +03:00
|
|
|
// //TODO Revisit this if there's still an issue. The PointerEvent model should have no problems
|
|
|
|
// // like the issue this code attempts to fix.
|
|
|
|
// /**
|
|
|
|
// * Returns the {@link OpenSeadragon.MouseTracker.GesturePointList|GesturePointList} for all but the given pointer device type.
|
|
|
|
// * @function
|
|
|
|
// * @param {String} type - The pointer device type: "mouse", "touch", "pen", etc.
|
|
|
|
// * @returns {Array.<OpenSeadragon.MouseTracker.GesturePointList>}
|
|
|
|
// */
|
|
|
|
// getActivePointersListsExceptType: function ( type ) {
|
|
|
|
// var delegate = THIS[ this.hash ];
|
|
|
|
// var listArray = [];
|
|
|
|
|
|
|
|
// for (var i = 0; i < delegate.activePointersLists.length; ++i) {
|
|
|
|
// if (delegate.activePointersLists[i].type !== type) {
|
|
|
|
// listArray.push(delegate.activePointersLists[i]);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return listArray;
|
|
|
|
// },
|
2017-07-08 01:50:03 +03:00
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
/**
|
|
|
|
* Returns the {@link OpenSeadragon.MouseTracker.GesturePointList|GesturePointList} for the given pointer device type,
|
|
|
|
* creating and caching a new {@link OpenSeadragon.MouseTracker.GesturePointList|GesturePointList} if one doesn't already exist for the type.
|
|
|
|
* @function
|
|
|
|
* @param {String} type - The pointer device type: "mouse", "touch", "pen", etc.
|
|
|
|
* @returns {OpenSeadragon.MouseTracker.GesturePointList}
|
|
|
|
*/
|
|
|
|
getActivePointersListByType: function ( type ) {
|
|
|
|
var delegate = THIS[ this.hash ],
|
|
|
|
i,
|
|
|
|
len = delegate.activePointersLists.length,
|
|
|
|
list;
|
|
|
|
|
|
|
|
for ( i = 0; i < len; i++ ) {
|
|
|
|
if ( delegate.activePointersLists[ i ].type === type ) {
|
|
|
|
return delegate.activePointersLists[ i ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
list = new $.MouseTracker.GesturePointList( type );
|
|
|
|
delegate.activePointersLists.push( list );
|
|
|
|
return list;
|
|
|
|
},
|
|
|
|
|
2015-01-15 23:15:22 +03:00
|
|
|
/**
|
|
|
|
* Returns the total number of pointers currently active on the tracked element.
|
|
|
|
* @function
|
|
|
|
* @returns {Number}
|
|
|
|
*/
|
|
|
|
getActivePointerCount: function () {
|
|
|
|
var delegate = THIS[ this.hash ],
|
|
|
|
i,
|
|
|
|
len = delegate.activePointersLists.length,
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
for ( i = 0; i < len; i++ ) {
|
|
|
|
count += delegate.activePointersLists[ i ].getLength();
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
},
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
|
|
|
* @param {OpenSeadragon.MouseTracker.EventProcessInfo} eventInfo
|
|
|
|
*/
|
|
|
|
preProcessEventHandler: function () { },
|
|
|
|
|
2012-02-02 01:56:04 +04:00
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.position
|
2013-09-12 21:05:50 +04:00
|
|
|
* The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
2015-01-15 23:15:22 +03:00
|
|
|
* @param {Number} event.pointers
|
|
|
|
* Number of pointers (all types) active in the tracked element.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.insideElementPressed
|
2013-09-12 21:05:50 +04:00
|
|
|
* True if the left mouse button is currently being pressed and was
|
|
|
|
* initiated inside the tracked element, otherwise false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.buttonDownAny
|
2014-04-15 05:17:18 +04:00
|
|
|
* Was the button down anywhere in the screen during the event. <span style="color:red;">Deprecated. Use buttons instead.</span>
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.isTouchEvent
|
2014-03-21 22:45:20 +04:00
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
enterHandler: function () { },
|
|
|
|
|
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2020-08-14 03:21:32 +03:00
|
|
|
* @since v2.5.0
|
2020-07-25 06:05:39 +03:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
|
|
|
* @param {String} event.pointerType
|
|
|
|
* "mouse", "touch", "pen", etc.
|
|
|
|
* @param {OpenSeadragon.Point} event.position
|
|
|
|
* The position of the event relative to the tracked element.
|
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
|
|
|
* @param {Number} event.pointers
|
|
|
|
* Number of pointers (all types) active in the tracked element.
|
|
|
|
* @param {Boolean} event.insideElementPressed
|
|
|
|
* True if the left mouse button is currently being pressed and was
|
|
|
|
* initiated inside the tracked element, otherwise false.
|
|
|
|
* @param {Boolean} event.buttonDownAny
|
|
|
|
* Was the button down anywhere in the screen during the event. <span style="color:red;">Deprecated. Use buttons instead.</span>
|
|
|
|
* @param {Boolean} event.isTouchEvent
|
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
|
|
|
* @param {Object} event.originalEvent
|
|
|
|
* The original event object.
|
|
|
|
* @param {Object} event.userData
|
|
|
|
* Arbitrary user-defined object.
|
|
|
|
*/
|
|
|
|
leaveHandler: function () { },
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2020-08-14 03:21:32 +03:00
|
|
|
* @deprecated v2.5.0 Use leaveHandler instead
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.position
|
2013-09-12 21:05:50 +04:00
|
|
|
* The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
2015-01-15 23:15:22 +03:00
|
|
|
* @param {Number} event.pointers
|
|
|
|
* Number of pointers (all types) active in the tracked element.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.insideElementPressed
|
2013-09-12 21:05:50 +04:00
|
|
|
* True if the left mouse button is currently being pressed and was
|
|
|
|
* initiated inside the tracked element, otherwise false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.buttonDownAny
|
2014-04-15 05:17:18 +04:00
|
|
|
* Was the button down anywhere in the screen during the event. <span style="color:red;">Deprecated. Use buttons instead.</span>
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.isTouchEvent
|
2014-03-21 22:45:20 +04:00
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
exitHandler: function () { },
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2020-07-25 06:05:39 +03:00
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2020-08-14 03:21:32 +03:00
|
|
|
* @since v2.5.0
|
2020-07-25 06:05:39 +03:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
|
|
|
* @param {String} event.pointerType
|
|
|
|
* "mouse", "touch", "pen", etc.
|
|
|
|
* @param {OpenSeadragon.Point} event.position
|
|
|
|
* The position of the event relative to the tracked element.
|
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
|
|
|
* @param {Number} event.pointers
|
|
|
|
* Number of pointers (all types) active in the tracked element.
|
|
|
|
* @param {Boolean} event.insideElementPressed
|
|
|
|
* True if the left mouse button is currently being pressed and was
|
|
|
|
* initiated inside the tracked element, otherwise false.
|
|
|
|
* @param {Boolean} event.buttonDownAny
|
|
|
|
* Was the button down anywhere in the screen during the event. <span style="color:red;">Deprecated. Use buttons instead.</span>
|
|
|
|
* @param {Boolean} event.isTouchEvent
|
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
overHandler: function () { },
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2020-08-14 03:21:32 +03:00
|
|
|
* @since v2.5.0
|
2020-07-25 06:05:39 +03:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
|
|
|
* @param {String} event.pointerType
|
|
|
|
* "mouse", "touch", "pen", etc.
|
|
|
|
* @param {OpenSeadragon.Point} event.position
|
|
|
|
* The position of the event relative to the tracked element.
|
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
|
|
|
* @param {Number} event.pointers
|
|
|
|
* Number of pointers (all types) active in the tracked element.
|
|
|
|
* @param {Boolean} event.insideElementPressed
|
|
|
|
* True if the left mouse button is currently being pressed and was
|
|
|
|
* initiated inside the tracked element, otherwise false.
|
|
|
|
* @param {Boolean} event.buttonDownAny
|
|
|
|
* Was the button down anywhere in the screen during the event. <span style="color:red;">Deprecated. Use buttons instead.</span>
|
|
|
|
* @param {Boolean} event.isTouchEvent
|
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
outHandler: function () { },
|
|
|
|
|
2012-02-02 01:56:04 +04:00
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.position
|
2013-09-12 21:05:50 +04:00
|
|
|
* The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.isTouchEvent
|
2014-03-21 22:45:20 +04:00
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
pressHandler: function () { },
|
2012-02-02 01:56:04 +04:00
|
|
|
|
2015-01-11 01:49:02 +03:00
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
|
|
|
* @param {String} event.pointerType
|
|
|
|
* "mouse", "touch", "pen", etc.
|
|
|
|
* @param {OpenSeadragon.Point} event.position
|
|
|
|
* The position of the event relative to the tracked element.
|
|
|
|
* @param {Number} event.button
|
|
|
|
* Button which caused the event.
|
|
|
|
* -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
|
|
|
* @param {Boolean} event.isTouchEvent
|
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
|
|
|
* @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.
|
|
|
|
*/
|
2015-01-12 22:02:54 +03:00
|
|
|
nonPrimaryPressHandler: function () { },
|
2015-01-11 01:49:02 +03:00
|
|
|
|
2012-02-02 01:56:04 +04:00
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.position
|
2013-09-12 21:05:50 +04:00
|
|
|
* The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.insideElementPressed
|
2013-09-12 21:05:50 +04:00
|
|
|
* True if the left mouse button is currently being pressed and was
|
|
|
|
* initiated inside the tracked element, otherwise false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.insideElementReleased
|
2014-04-15 05:17:18 +04:00
|
|
|
* True if the cursor inside the tracked element when the button was released.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.isTouchEvent
|
2014-03-21 22:45:20 +04:00
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
releaseHandler: function () { },
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2015-01-11 01:49:02 +03:00
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
|
|
|
* @param {String} event.pointerType
|
|
|
|
* "mouse", "touch", "pen", etc.
|
|
|
|
* @param {OpenSeadragon.Point} event.position
|
|
|
|
* The position of the event relative to the tracked element.
|
|
|
|
* @param {Number} event.button
|
|
|
|
* Button which caused the event.
|
|
|
|
* -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
|
|
|
* @param {Boolean} event.isTouchEvent
|
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
|
|
|
* @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.
|
|
|
|
*/
|
2015-01-12 22:02:54 +03:00
|
|
|
nonPrimaryReleaseHandler: function () { },
|
2015-01-11 01:49:02 +03:00
|
|
|
|
2012-02-02 01:56:04 +04:00
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.position
|
2013-09-12 21:05:50 +04:00
|
|
|
* The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.isTouchEvent
|
2014-03-21 22:45:20 +04:00
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
moveHandler: function () { },
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-02 01:56:04 +04:00
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.position
|
2013-09-12 21:05:50 +04:00
|
|
|
* The position of the event relative to the tracked element.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Number} event.scroll
|
2013-09-12 21:05:50 +04:00
|
|
|
* The scroll delta for the event.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.shift
|
2013-09-12 21:05:50 +04:00
|
|
|
* True if the shift key was pressed during this event.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.isTouchEvent
|
2014-03-21 22:45:20 +04:00
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead. Touch devices no longer generate scroll event.</span>
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
scrollHandler: function () { },
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-02 01:56:04 +04:00
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.position
|
2013-09-12 21:05:50 +04:00
|
|
|
* The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Boolean} event.quick
|
2014-04-22 20:23:56 +04:00
|
|
|
* True only if the clickDistThreshold and clickTimeThreshold are both passed. Useful for ignoring drag events.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.shift
|
2013-09-12 21:05:50 +04:00
|
|
|
* True if the shift key was pressed during this event.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.isTouchEvent
|
2014-03-21 22:45:20 +04:00
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
clickHandler: function () { },
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2014-04-22 20:23:56 +04:00
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
|
|
|
* @param {String} event.pointerType
|
|
|
|
* "mouse", "touch", "pen", etc.
|
|
|
|
* @param {OpenSeadragon.Point} event.position
|
|
|
|
* The position of the event relative to the tracked element.
|
|
|
|
* @param {Boolean} event.shift
|
|
|
|
* True if the shift key was pressed during this event.
|
|
|
|
* @param {Boolean} event.isTouchEvent
|
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
dblClickHandler: function () { },
|
|
|
|
|
2012-02-02 01:56:04 +04:00
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.position
|
2013-09-12 21:05:50 +04:00
|
|
|
* The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.delta
|
2014-03-30 04:02:24 +04:00
|
|
|
* The x,y components of the difference between the current position and the last drag event position. Useful for ignoring or weighting the events.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.speed
|
2014-03-30 04:02:24 +04:00
|
|
|
* Current computed speed, in pixels per second.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.direction
|
2014-03-30 04:02:24 +04:00
|
|
|
* Current computed direction, expressed as an angle counterclockwise relative to the positive X axis (-pi to pi, in radians). Only valid if speed > 0.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.shift
|
2013-09-12 21:05:50 +04:00
|
|
|
* True if the shift key was pressed during this event.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.isTouchEvent
|
2014-03-21 22:45:20 +04:00
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
dragHandler: function () { },
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2014-03-10 22:49:51 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.position
|
|
|
|
* The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.speed
|
2014-03-30 04:02:24 +04:00
|
|
|
* Speed at the end of a drag gesture, in pixels per second.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.direction
|
2014-03-30 04:02:24 +04:00
|
|
|
* Direction at the end of a drag gesture, expressed as an angle counterclockwise relative to the positive X axis (-pi to pi, in radians). Only valid if speed > 0.
|
2014-03-10 22:49:51 +04:00
|
|
|
* @param {Boolean} event.shift
|
|
|
|
* True if the shift key was pressed during this event.
|
|
|
|
* @param {Boolean} event.isTouchEvent
|
2014-03-21 22:45:20 +04:00
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
2014-03-10 22:49:51 +04:00
|
|
|
* @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.
|
|
|
|
*/
|
2014-03-30 04:02:24 +04:00
|
|
|
dragEndHandler: function () { },
|
2014-03-10 22:49:51 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {Array.<OpenSeadragon.MouseTracker.GesturePoint>} event.gesturePoints
|
|
|
|
* Gesture points associated with the gesture. Velocity data can be found here.
|
|
|
|
* @param {OpenSeadragon.Point} event.lastCenter
|
|
|
|
* The previous center point of the two pinch contact points relative to the tracked element.
|
|
|
|
* @param {OpenSeadragon.Point} event.center
|
|
|
|
* The center point of the two pinch contact points relative to the tracked element.
|
|
|
|
* @param {Number} event.lastDistance
|
|
|
|
* The previous distance between the two pinch contact points in CSS pixels.
|
|
|
|
* @param {Number} event.distance
|
|
|
|
* The distance between the two pinch contact points in CSS pixels.
|
2014-03-10 22:49:51 +04:00
|
|
|
* @param {Boolean} event.shift
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-03-30 04:02:24 +04:00
|
|
|
pinchHandler: function () { },
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2012-03-16 19:36:28 +04:00
|
|
|
/**
|
2013-10-23 00:54:04 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @param {String} event.pointerType
|
2014-04-15 05:17:18 +04:00
|
|
|
* "mouse", "touch", "pen", etc.
|
2013-10-23 00:54:04 +04:00
|
|
|
* @param {OpenSeadragon.Point} event.position
|
|
|
|
* The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} event.buttons
|
|
|
|
* Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
2013-10-23 00:54:04 +04:00
|
|
|
* @param {Boolean} event.isTouchEvent
|
2014-03-21 22:45:20 +04:00
|
|
|
* True if the original event is a touch event, otherwise false. <span style="color:red;">Deprecated. Use pointerType and/or originalEvent instead.</span>
|
2013-10-23 00:54:04 +04:00
|
|
|
* @param {Object} event.originalEvent
|
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-23 00:54:04 +04:00
|
|
|
* @param {Object} event.userData
|
|
|
|
* Arbitrary user-defined object.
|
|
|
|
*/
|
|
|
|
stopHandler: function () { },
|
|
|
|
|
2012-03-16 19:36:28 +04:00
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Number} event.keyCode
|
2013-09-12 21:05:50 +04:00
|
|
|
* The key code that was pressed.
|
2015-01-17 03:26:30 +03:00
|
|
|
* @param {Boolean} event.ctrl
|
|
|
|
* True if the ctrl key was pressed during this event.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Boolean} event.shift
|
2013-09-12 21:05:50 +04:00
|
|
|
* True if the shift key was pressed during this event.
|
2015-01-17 03:26:30 +03:00
|
|
|
* @param {Boolean} event.alt
|
|
|
|
* True if the alt key was pressed during this event.
|
|
|
|
* @param {Boolean} event.meta
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
keyDownHandler: function () { },
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
|
|
|
* @param {Number} event.keyCode
|
|
|
|
* The key code that was pressed.
|
|
|
|
* @param {Boolean} event.ctrl
|
|
|
|
* True if the ctrl key was pressed during this event.
|
|
|
|
* @param {Boolean} event.shift
|
|
|
|
* True if the shift key was pressed during this event.
|
|
|
|
* @param {Boolean} event.alt
|
|
|
|
* True if the alt key was pressed during this event.
|
|
|
|
* @param {Boolean} event.meta
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
keyUpHandler: function () { },
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement or assign implementation to these handlers during or after
|
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
|
|
|
* A reference to the tracker instance.
|
|
|
|
* @param {Number} event.keyCode
|
|
|
|
* The key code that was pressed.
|
|
|
|
* @param {Boolean} event.ctrl
|
|
|
|
* True if the ctrl key was pressed during this event.
|
|
|
|
* @param {Boolean} event.shift
|
|
|
|
* True if the shift key was pressed during this event.
|
|
|
|
* @param {Boolean} event.alt
|
|
|
|
* True if the alt key was pressed during this event.
|
|
|
|
* @param {Boolean} event.meta
|
|
|
|
* True if the meta key was pressed during this event.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
keyHandler: function () { },
|
|
|
|
|
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
focusHandler: function () { },
|
|
|
|
|
|
|
|
/**
|
2013-10-31 05:28:10 +04:00
|
|
|
* Implement or assign implementation to these handlers during or after
|
2013-09-06 21:43:39 +04:00
|
|
|
* calling the constructor.
|
|
|
|
* @function
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event
|
|
|
|
* @param {OpenSeadragon.MouseTracker} event.eventSource
|
2013-09-06 21:43:39 +04:00
|
|
|
* A reference to the tracker instance.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.originalEvent
|
2013-09-12 21:05:50 +04:00
|
|
|
* The original event object.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @param {Boolean} event.preventDefaultAction
|
|
|
|
* Set to true to prevent the tracker subscriber from performing its default action (subscriber implementation dependent). Default: false.
|
2013-10-11 04:00:15 +04:00
|
|
|
* @param {Object} event.userData
|
2013-09-12 21:05:50 +04:00
|
|
|
* Arbitrary user-defined object.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
blurHandler: function () { }
|
2012-02-03 04:12:45 +04:00
|
|
|
};
|
2012-02-02 01:56:04 +04:00
|
|
|
|
2020-08-14 02:43:49 +03:00
|
|
|
// https://github.com/openseadragon/openseadragon/pull/790
|
2017-02-19 19:36:53 +03:00
|
|
|
/**
|
2020-07-31 07:08:02 +03:00
|
|
|
* True if inside an iframe, otherwise false.
|
|
|
|
* @member {Boolean} isInIframe
|
2017-02-19 19:36:53 +03:00
|
|
|
* @private
|
2020-07-31 07:08:02 +03:00
|
|
|
* @inner
|
2017-02-19 19:36:53 +03:00
|
|
|
*/
|
2020-07-31 07:08:02 +03:00
|
|
|
var isInIframe = (function() {
|
|
|
|
try {
|
|
|
|
return window.self !== window.top;
|
|
|
|
} catch (e) {
|
|
|
|
return true;
|
2017-02-20 22:23:25 +03:00
|
|
|
}
|
2020-07-31 07:08:02 +03:00
|
|
|
})();
|
|
|
|
|
2020-08-14 02:43:49 +03:00
|
|
|
// https://github.com/openseadragon/openseadragon/pull/790
|
2020-07-31 07:08:02 +03:00
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @returns {Boolean} True if the target supports DOM Level 2 event subscription methods, otherwise false.
|
|
|
|
*/
|
|
|
|
function canAccessEvents (target) {
|
|
|
|
try {
|
|
|
|
return target.addEventListener && target.removeEventListener;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO Revisit this if there's still an issue. The PointerEvent model should have no problems
|
|
|
|
// like the issue this code attempts to fix.
|
|
|
|
// /**
|
|
|
|
// * Resets all active mousetrakers. (Added to patch issue #697 "Mouse up outside map will cause "canvas-drag" event to stick")
|
|
|
|
// *
|
|
|
|
// * @private
|
|
|
|
// * @member resetAllMouseTrackers
|
|
|
|
// * @memberof OpenSeadragon.MouseTracker
|
|
|
|
// */
|
|
|
|
// $.MouseTracker.resetAllMouseTrackers = function(){
|
|
|
|
// for(var i = 0; i < MOUSETRACKERS.length; i++){
|
|
|
|
// if (MOUSETRACKERS[i].isTracking()){
|
|
|
|
// MOUSETRACKERS[i].setTracking(false);
|
|
|
|
// MOUSETRACKERS[i].setTracking(true);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// };
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2014-03-30 04:02:24 +04:00
|
|
|
/**
|
|
|
|
* Provides continuous computation of velocity (speed and direction) of active pointers.
|
2014-04-15 05:17:18 +04:00
|
|
|
* This is a singleton, used by all MouseTracker instances, as it is unlikely there will ever be more than
|
2014-03-30 04:02:24 +04:00
|
|
|
* two active gesture pointers at a time.
|
2014-04-01 20:32:04 +04:00
|
|
|
*
|
2014-04-15 05:17:18 +04:00
|
|
|
* @private
|
2014-04-01 20:32:04 +04:00
|
|
|
* @member gesturePointVelocityTracker
|
|
|
|
* @memberof OpenSeadragon.MouseTracker
|
2014-03-30 04:02:24 +04:00
|
|
|
*/
|
|
|
|
$.MouseTracker.gesturePointVelocityTracker = (function () {
|
|
|
|
var trackerPoints = [],
|
|
|
|
intervalId = 0,
|
|
|
|
lastTime = 0;
|
|
|
|
|
|
|
|
// Generates a unique identifier for a tracked gesture point
|
|
|
|
var _generateGuid = function ( tracker, gPoint ) {
|
|
|
|
return tracker.hash.toString() + gPoint.type + gPoint.id.toString();
|
|
|
|
};
|
|
|
|
|
|
|
|
// Interval timer callback. Computes velocity for all tracked gesture points.
|
|
|
|
var _doTracking = function () {
|
|
|
|
var i,
|
|
|
|
len = trackerPoints.length,
|
|
|
|
trackPoint,
|
|
|
|
gPoint,
|
|
|
|
now = $.now(),
|
|
|
|
elapsedTime,
|
|
|
|
distance,
|
|
|
|
speed;
|
|
|
|
|
|
|
|
elapsedTime = now - lastTime;
|
|
|
|
lastTime = now;
|
|
|
|
|
|
|
|
for ( i = 0; i < len; i++ ) {
|
|
|
|
trackPoint = trackerPoints[ i ];
|
|
|
|
gPoint = trackPoint.gPoint;
|
|
|
|
// Math.atan2 gives us just what we need for a velocity vector, as we can simply
|
|
|
|
// use cos()/sin() to extract the x/y velocity components.
|
|
|
|
gPoint.direction = Math.atan2( gPoint.currentPos.y - trackPoint.lastPos.y, gPoint.currentPos.x - trackPoint.lastPos.x );
|
|
|
|
// speed = distance / elapsed time
|
|
|
|
distance = trackPoint.lastPos.distanceTo( gPoint.currentPos );
|
|
|
|
trackPoint.lastPos = gPoint.currentPos;
|
|
|
|
speed = 1000 * distance / ( elapsedTime + 1 );
|
|
|
|
// Simple biased average, favors the most recent speed computation. Smooths out erratic gestures a bit.
|
|
|
|
gPoint.speed = 0.75 * speed + 0.25 * gPoint.speed;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Public. Add a gesture point to be tracked
|
|
|
|
var addPoint = function ( tracker, gPoint ) {
|
|
|
|
var guid = _generateGuid( tracker, gPoint );
|
|
|
|
|
|
|
|
trackerPoints.push(
|
|
|
|
{
|
|
|
|
guid: guid,
|
|
|
|
gPoint: gPoint,
|
|
|
|
lastPos: gPoint.currentPos
|
|
|
|
} );
|
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
// Only fire up the interval timer when there's gesture pointers to track
|
2014-03-30 04:02:24 +04:00
|
|
|
if ( trackerPoints.length === 1 ) {
|
|
|
|
lastTime = $.now();
|
|
|
|
intervalId = window.setInterval( _doTracking, 50 );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Public. Stop tracking a gesture point
|
|
|
|
var removePoint = function ( tracker, gPoint ) {
|
|
|
|
var guid = _generateGuid( tracker, gPoint ),
|
|
|
|
i,
|
|
|
|
len = trackerPoints.length;
|
|
|
|
for ( i = 0; i < len; i++ ) {
|
|
|
|
if ( trackerPoints[ i ].guid === guid ) {
|
|
|
|
trackerPoints.splice( i, 1 );
|
2014-04-15 05:17:18 +04:00
|
|
|
// Only run the interval timer if theres gesture pointers to track
|
2014-03-30 04:02:24 +04:00
|
|
|
len--;
|
|
|
|
if ( len === 0 ) {
|
|
|
|
window.clearInterval( intervalId );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
addPoint: addPoint,
|
|
|
|
removePoint: removePoint
|
|
|
|
};
|
|
|
|
} )();
|
|
|
|
|
|
|
|
|
2014-04-03 19:50:25 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2014-04-15 05:17:18 +04:00
|
|
|
// Pointer event model and feature detection
|
2014-04-03 19:50:25 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-12-30 23:57:17 +03:00
|
|
|
$.MouseTracker.captureElement = document;
|
|
|
|
|
2013-10-23 23:58:36 +04:00
|
|
|
/**
|
2014-03-10 22:49:51 +04:00
|
|
|
* Detect available mouse wheel event name.
|
2013-10-23 23:58:36 +04:00
|
|
|
*/
|
2020-06-26 02:01:14 +03:00
|
|
|
$.MouseTracker.wheelEventName = ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version > 8 ) ||
|
2013-10-24 00:55:52 +04:00
|
|
|
( 'onwheel' in document.createElement( 'div' ) ) ? 'wheel' : // Modern browsers support 'wheel'
|
|
|
|
document.onmousewheel !== undefined ? 'mousewheel' : // Webkit and IE support at least 'mousewheel'
|
|
|
|
'DOMMouseScroll'; // Assume old Firefox
|
2013-10-23 23:58:36 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
/**
|
2014-03-30 04:02:24 +04:00
|
|
|
* Detect browser pointer device event model(s) and build appropriate list of events to subscribe to.
|
2014-03-10 22:49:51 +04:00
|
|
|
*/
|
2015-01-17 03:26:30 +03:00
|
|
|
$.MouseTracker.subscribeEvents = [ "click", "dblclick", "keydown", "keyup", "keypress", "focus", "blur", $.MouseTracker.wheelEventName ];
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-06-26 02:01:14 +03:00
|
|
|
if( $.MouseTracker.wheelEventName === "DOMMouseScroll" ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
// Older Firefox
|
|
|
|
$.MouseTracker.subscribeEvents.push( "MozMousePixelScroll" );
|
|
|
|
}
|
|
|
|
|
2020-07-25 06:05:39 +03:00
|
|
|
if ( window.PointerEvent ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
// IE11 and other W3C Pointer Event implementations (see http://www.w3.org/TR/pointerevents)
|
2015-01-13 03:08:26 +03:00
|
|
|
$.MouseTracker.havePointerEvents = true;
|
2020-07-25 06:05:39 +03:00
|
|
|
$.MouseTracker.subscribeEvents.push( "pointerenter", "pointerleave", "pointerover", "pointerout", "pointerdown", "pointerup", "pointermove", "pointercancel" );
|
2014-03-10 22:49:51 +04:00
|
|
|
$.MouseTracker.unprefixedPointerEvents = true;
|
2020-07-26 04:30:06 +03:00
|
|
|
$.MouseTracker.havePointerOverOut = true;
|
|
|
|
// Pointer events capture support
|
|
|
|
$.MouseTracker.havePointerCapture = (function () {
|
|
|
|
var divElement = document.createElement( 'div' );
|
|
|
|
return $.isFunction( divElement.setPointerCapture ) && $.isFunction( divElement.releasePointerCapture );
|
|
|
|
}());
|
2020-07-31 07:08:02 +03:00
|
|
|
if ( $.MouseTracker.havePointerCapture ) {
|
|
|
|
$.MouseTracker.subscribeEvents.push( "gotpointercapture", "lostpointercapture" );
|
|
|
|
}
|
2015-01-20 21:26:14 +03:00
|
|
|
} else if ( window.MSPointerEvent && window.navigator.msPointerEnabled ) {
|
2020-07-26 04:30:06 +03:00
|
|
|
// IE10 (MSPointerEnter/MSPointerLeave simulated with MSPointerOver/MSPointerOut)
|
2015-01-13 03:08:26 +03:00
|
|
|
$.MouseTracker.havePointerEvents = true;
|
2020-07-26 04:30:06 +03:00
|
|
|
$.MouseTracker.subscribeEvents.push( "MSPointerOver", "MSPointerOut", "MSPointerDown", "MSPointerUp", "MSPointerMove", "MSPointerCancel" );
|
2014-03-10 22:49:51 +04:00
|
|
|
$.MouseTracker.unprefixedPointerEvents = false;
|
2020-07-26 04:30:06 +03:00
|
|
|
$.MouseTracker.havePointerOverOut = true;
|
|
|
|
// Prefixed pointer events capture support
|
|
|
|
$.MouseTracker.havePointerCapture = (function () {
|
|
|
|
var divElement = document.createElement( 'div' );
|
|
|
|
return $.isFunction( divElement.msSetPointerCapture ) && $.isFunction( divElement.msReleasePointerCapture );
|
|
|
|
}());
|
2020-07-31 07:08:02 +03:00
|
|
|
if ( $.MouseTracker.havePointerCapture ) {
|
|
|
|
$.MouseTracker.subscribeEvents.push( "MSGotPointerCapture", "MSLostPointerCapture" );
|
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
$.MouseTracker.subscribeEvents.push( "MSGestureStart", "MSGestureChange" );
|
2014-04-15 05:17:18 +04:00
|
|
|
} else {
|
2014-04-02 05:27:54 +04:00
|
|
|
// Legacy W3C mouse events
|
2015-01-13 03:08:26 +03:00
|
|
|
$.MouseTracker.havePointerEvents = false;
|
2020-07-31 07:08:02 +03:00
|
|
|
$.MouseTracker.unprefixedPointerEvents = true;
|
2020-07-25 06:05:39 +03:00
|
|
|
$.MouseTracker.subscribeEvents.push( "mouseenter", "mouseleave" );
|
|
|
|
if ( $.Browser.vendor !== $.BROWSERS.IE || $.Browser.version > 8 ) {
|
2015-01-11 01:49:02 +03:00
|
|
|
$.MouseTracker.subscribeEvents.push( "mouseover", "mouseout" );
|
2020-07-26 04:30:06 +03:00
|
|
|
$.MouseTracker.havePointerOverOut = true;
|
2020-07-25 06:05:39 +03:00
|
|
|
} else {
|
2020-07-26 04:30:06 +03:00
|
|
|
$.MouseTracker.havePointerOverOut = false;
|
2015-01-11 01:49:02 +03:00
|
|
|
}
|
|
|
|
$.MouseTracker.subscribeEvents.push( "mousedown", "mouseup", "mousemove" );
|
2020-07-26 04:30:06 +03:00
|
|
|
$.MouseTracker.mousePointerId = "legacy-mouse";
|
2020-07-31 07:08:02 +03:00
|
|
|
// Legacy mouse events capture support (IE/Firefox only?)
|
2020-07-26 04:30:06 +03:00
|
|
|
$.MouseTracker.havePointerCapture = (function () {
|
|
|
|
var divElement = document.createElement( 'div' );
|
|
|
|
return $.isFunction( divElement.setCapture ) && $.isFunction( divElement.releaseCapture );
|
|
|
|
}());
|
2020-07-31 07:08:02 +03:00
|
|
|
if ( $.MouseTracker.havePointerCapture ) {
|
|
|
|
$.MouseTracker.subscribeEvents.push( "losecapture" );
|
|
|
|
}
|
2020-07-26 04:30:06 +03:00
|
|
|
// Legacy touch events
|
2014-03-10 22:49:51 +04:00
|
|
|
if ( 'ontouchstart' in window ) {
|
2015-01-15 23:15:22 +03:00
|
|
|
// iOS, Android, and other W3c Touch Event implementations
|
|
|
|
// (see http://www.w3.org/TR/touch-events/)
|
|
|
|
// (see https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html)
|
|
|
|
// (see https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html)
|
2014-03-30 04:02:24 +04:00
|
|
|
$.MouseTracker.subscribeEvents.push( "touchstart", "touchend", "touchmove", "touchcancel" );
|
2014-03-21 22:45:20 +04:00
|
|
|
}
|
|
|
|
if ( 'ongesturestart' in window ) {
|
2015-01-15 23:15:22 +03:00
|
|
|
// iOS (see https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html)
|
2014-03-21 22:45:20 +04:00
|
|
|
// Subscribe to these to prevent default gesture handling
|
|
|
|
$.MouseTracker.subscribeEvents.push( "gesturestart", "gesturechange" );
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
|
|
|
}
|
2015-06-08 17:38:16 +03:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2014-04-03 19:50:25 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Classes and typedefs
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
/**
|
|
|
|
* Used for the processing/disposition of DOM events (propagation, default handling, capture, etc.)
|
|
|
|
*
|
|
|
|
* @typedef {Object} EventProcessInfo
|
|
|
|
* @memberof OpenSeadragon.MouseTracker
|
2020-08-14 03:21:32 +03:00
|
|
|
* @since v2.5.0
|
2020-08-13 07:22:48 +03:00
|
|
|
*
|
|
|
|
* @property {OpenSeadragon.MouseTracker} eventSource
|
|
|
|
* A reference to the tracker instance.
|
|
|
|
* @property {Object} originalEvent
|
|
|
|
* The original DOM event object.
|
|
|
|
* @property {Number} eventPhase
|
|
|
|
* 0 == NONE, 1 == CAPTURING_PHASE, 2 == AT_TARGET, 3 == BUBBLING_PHASE.
|
|
|
|
* @property {String} eventType
|
|
|
|
* "gotpointercapture", "lostpointercapture", "pointerenter", "pointerleave", "pointerover", "pointerout", "pointerdown", "pointerup", "pointermove", "pointercancel", "wheel".
|
|
|
|
* @property {String} pointerType
|
|
|
|
* "mouse", "touch", "pen", etc.
|
|
|
|
* @property {Boolean} isEmulated
|
|
|
|
* True if this is an emulated event. If true, originalEvent is the event that caused
|
|
|
|
* the emulated event or null if no DOM event applies. Emulated events
|
|
|
|
* can occur on eventType "pointerenter", "pointerleave", "pointerover", "pointerout".
|
|
|
|
* @property {Boolean} isStopable
|
|
|
|
* True if propagation of the event (e.g. bubbling) can be stopped with stopPropagation/stopImmediatePropagation.
|
|
|
|
* @property {Boolean} isCancelable
|
|
|
|
* True if the event's default handling by the browser can be prevented with preventDefault.
|
|
|
|
* @property {Boolean} defaultPrevented
|
|
|
|
* True if the event's default handling has already been prevented by a descendent element.
|
|
|
|
* @property {Boolean} preventDefault
|
|
|
|
* Set to true to prevent the event's default handling by the browser.
|
|
|
|
* @property {Boolean} preventGesture
|
|
|
|
* Set to true to prevent this MouseTracker from generating a gesture from the event.
|
|
|
|
* Valid on eventType "pointerdown".
|
|
|
|
* @property {Boolean} stopPropagation
|
|
|
|
* Set to true prevent the event from propagating to ancestor/descendent elements on capture/bubble phase.
|
|
|
|
* @property {Boolean} shouldCapture
|
|
|
|
* (Internal Use) Set to true if the pointer should be captured (events (re)targeted to tracker element).
|
|
|
|
* @property {Boolean} shouldReleaseCapture
|
|
|
|
* (Internal Use) Set to true if the captured pointer should be released.
|
|
|
|
* @property {Object} userData
|
|
|
|
* Arbitrary user-defined object.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-03-30 04:02:24 +04:00
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* Represents a point of contact on the screen made by a mouse cursor, pen, touch, or other pointer device.
|
2014-03-30 04:02:24 +04:00
|
|
|
*
|
|
|
|
* @typedef {Object} GesturePoint
|
|
|
|
* @memberof OpenSeadragon.MouseTracker
|
|
|
|
*
|
|
|
|
* @property {Number} id
|
|
|
|
* Identifier unique from all other active GesturePoints for a given pointer device.
|
|
|
|
* @property {String} type
|
2014-04-15 05:17:18 +04:00
|
|
|
* The pointer device type: "mouse", "touch", "pen", etc.
|
|
|
|
* @property {Boolean} captured
|
|
|
|
* True if events for the gesture point are captured to the tracked element.
|
2014-04-01 20:32:04 +04:00
|
|
|
* @property {Boolean} isPrimary
|
|
|
|
* True if the gesture point is a master pointer amongst the set of active pointers for each pointer type. True for mouse and primary (first) touch/pen pointers.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @property {Boolean} insideElementPressed
|
2014-04-01 20:32:04 +04:00
|
|
|
* True if button pressed or contact point initiated inside the screen area of the tracked element.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @property {Boolean} insideElement
|
2014-04-01 20:32:04 +04:00
|
|
|
* True if pointer or contact point is currently inside the bounds of the tracked element.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @property {Number} speed
|
2014-04-01 20:32:04 +04:00
|
|
|
* Current computed speed, in pixels per second.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @property {Number} direction
|
2014-04-01 20:32:04 +04:00
|
|
|
* Current computed direction, expressed as an angle counterclockwise relative to the positive X axis (-pi to pi, in radians). Only valid if speed > 0.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @property {OpenSeadragon.Point} contactPos
|
|
|
|
* The initial pointer contact position, relative to the page including any scrolling. Only valid if the pointer has contact (pressed, touch contact, pen contact).
|
|
|
|
* @property {Number} contactTime
|
|
|
|
* The initial pointer contact time, in milliseconds. Only valid if the pointer has contact (pressed, touch contact, pen contact).
|
2014-03-30 04:02:24 +04:00
|
|
|
* @property {OpenSeadragon.Point} lastPos
|
|
|
|
* The last pointer position, relative to the page including any scrolling.
|
|
|
|
* @property {Number} lastTime
|
|
|
|
* The last pointer contact time, in milliseconds.
|
|
|
|
* @property {OpenSeadragon.Point} currentPos
|
|
|
|
* The current pointer position, relative to the page including any scrolling.
|
|
|
|
* @property {Number} currentTime
|
|
|
|
* The current pointer contact time, in milliseconds.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
/**
|
2014-03-30 04:02:24 +04:00
|
|
|
* @class GesturePointList
|
2014-04-15 05:17:18 +04:00
|
|
|
* @classdesc Provides an abstraction for a set of active {@link OpenSeadragon.MouseTracker.GesturePoint|GesturePoint} objects for a given pointer device type.
|
2015-06-08 17:38:16 +03:00
|
|
|
* Active pointers are any pointer being tracked for this element which are in the hit-test area
|
2014-04-15 05:17:18 +04:00
|
|
|
* of the element (for hover-capable devices) and/or have contact or a button press initiated in the element.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @memberof OpenSeadragon.MouseTracker
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {String} type - The pointer device type: "mouse", "touch", "pen", etc.
|
2014-03-30 04:02:24 +04:00
|
|
|
*/
|
2014-04-15 05:17:18 +04:00
|
|
|
$.MouseTracker.GesturePointList = function ( type ) {
|
2014-03-30 04:02:24 +04:00
|
|
|
this._gPoints = [];
|
2014-04-15 05:17:18 +04:00
|
|
|
/**
|
|
|
|
* The pointer device type: "mouse", "touch", "pen", etc.
|
|
|
|
* @member {String} type
|
|
|
|
* @memberof OpenSeadragon.MouseTracker.GesturePointList#
|
|
|
|
*/
|
|
|
|
this.type = type;
|
|
|
|
/**
|
|
|
|
* Current buttons pressed for the device.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
|
|
|
* @member {Number} buttons
|
|
|
|
* @memberof OpenSeadragon.MouseTracker.GesturePointList#
|
|
|
|
*/
|
|
|
|
this.buttons = 0;
|
|
|
|
/**
|
|
|
|
* Current number of contact points (touch points, mouse down, etc.) for the device.
|
|
|
|
* @member {Number} contacts
|
|
|
|
* @memberof OpenSeadragon.MouseTracker.GesturePointList#
|
|
|
|
*/
|
|
|
|
this.contacts = 0;
|
2014-04-22 20:23:56 +04:00
|
|
|
/**
|
|
|
|
* Current number of clicks for the device. Used for multiple click gesture tracking.
|
|
|
|
* @member {Number} clicks
|
|
|
|
* @memberof OpenSeadragon.MouseTracker.GesturePointList#
|
|
|
|
*/
|
|
|
|
this.clicks = 0;
|
2015-01-01 01:30:10 +03:00
|
|
|
/**
|
|
|
|
* Current number of captured pointers for the device.
|
|
|
|
* @member {Number} captureCount
|
|
|
|
* @memberof OpenSeadragon.MouseTracker.GesturePointList#
|
|
|
|
*/
|
|
|
|
this.captureCount = 0;
|
2014-03-30 04:02:24 +04:00
|
|
|
};
|
2016-01-25 00:09:18 +03:00
|
|
|
|
|
|
|
/** @lends OpenSeadragon.MouseTracker.GesturePointList.prototype */
|
|
|
|
$.MouseTracker.GesturePointList.prototype = {
|
2014-03-30 04:02:24 +04:00
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @returns {Number} Number of gesture points in the list.
|
|
|
|
*/
|
|
|
|
getLength: function () {
|
|
|
|
return this._gPoints.length;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @returns {Array.<OpenSeadragon.MouseTracker.GesturePoint>} The list of gesture points in the list as an array (read-only).
|
|
|
|
*/
|
|
|
|
asArray: function () {
|
|
|
|
return this._gPoints;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gesturePoint - A gesture point to add to the list.
|
|
|
|
* @returns {Number} Number of gesture points in the list.
|
|
|
|
*/
|
|
|
|
add: function ( gp ) {
|
|
|
|
return this._gPoints.push( gp );
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @param {Number} id - The id of the gesture point to remove from the list.
|
|
|
|
* @returns {Number} Number of gesture points in the list.
|
|
|
|
*/
|
|
|
|
removeById: function ( id ) {
|
|
|
|
var i,
|
|
|
|
len = this._gPoints.length;
|
|
|
|
for ( i = 0; i < len; i++ ) {
|
|
|
|
if ( this._gPoints[ i ].id === id ) {
|
|
|
|
this._gPoints.splice( i, 1 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this._gPoints.length;
|
|
|
|
},
|
2014-04-01 20:32:04 +04:00
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @param {Number} index - The index of the gesture point to retrieve from the list.
|
|
|
|
* @returns {OpenSeadragon.MouseTracker.GesturePoint|null} The gesture point at the given index, or null if not found.
|
|
|
|
*/
|
|
|
|
getByIndex: function ( index ) {
|
|
|
|
if ( index < this._gPoints.length) {
|
|
|
|
return this._gPoints[ index ];
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
2014-03-30 04:02:24 +04:00
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @param {Number} id - The id of the gesture point to retrieve from the list.
|
|
|
|
* @returns {OpenSeadragon.MouseTracker.GesturePoint|null} The gesture point with the given id, or null if not found.
|
|
|
|
*/
|
|
|
|
getById: function ( id ) {
|
|
|
|
var i,
|
|
|
|
len = this._gPoints.length;
|
|
|
|
for ( i = 0; i < len; i++ ) {
|
|
|
|
if ( this._gPoints[ i ].id === id ) {
|
|
|
|
return this._gPoints[ i ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2014-04-01 20:32:04 +04:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @returns {OpenSeadragon.MouseTracker.GesturePoint|null} The primary gesture point in the list, or null if not found.
|
|
|
|
*/
|
|
|
|
getPrimary: function ( id ) {
|
|
|
|
var i,
|
|
|
|
len = this._gPoints.length;
|
|
|
|
for ( i = 0; i < len; i++ ) {
|
|
|
|
if ( this._gPoints[ i ].isPrimary ) {
|
|
|
|
return this._gPoints[ i ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2017-07-08 01:50:03 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2020-08-14 02:43:49 +03:00
|
|
|
* Increment this pointer list's contact count.
|
2017-07-08 01:50:03 +03:00
|
|
|
* It will evaluate whether this pointer type is allowed to have multiple contacts.
|
2017-07-19 02:22:26 +03:00
|
|
|
* @function
|
2017-07-08 01:50:03 +03:00
|
|
|
*/
|
|
|
|
addContact: function() {
|
|
|
|
++this.contacts;
|
|
|
|
|
|
|
|
if (this.contacts > 1 && (this.type === "mouse" || this.type === "pen")) {
|
2020-08-13 07:22:48 +03:00
|
|
|
$.console.warn('GesturePointList.addContact() Implausible contacts value');
|
2017-07-08 01:50:03 +03:00
|
|
|
this.contacts = 1;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2020-08-14 02:43:49 +03:00
|
|
|
* Decrement this pointer list's contact count.
|
2017-07-08 01:50:03 +03:00
|
|
|
* It will make sure the count does not go below 0.
|
2017-07-19 02:22:26 +03:00
|
|
|
* @function
|
2017-07-08 01:50:03 +03:00
|
|
|
*/
|
|
|
|
removeContact: function() {
|
|
|
|
--this.contacts;
|
|
|
|
|
|
|
|
if (this.contacts < 0) {
|
2020-08-13 07:22:48 +03:00
|
|
|
$.console.warn('GesturePointList.removeContact() Implausible contacts value');
|
2017-07-08 01:50:03 +03:00
|
|
|
this.contacts = 0;
|
|
|
|
}
|
2014-03-30 04:02:24 +04:00
|
|
|
}
|
|
|
|
};
|
2015-06-08 17:38:16 +03:00
|
|
|
|
2014-03-30 04:02:24 +04:00
|
|
|
|
2014-04-03 19:50:25 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Utility functions
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-12-30 23:57:17 +03:00
|
|
|
/**
|
|
|
|
* Removes all tracked pointers.
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function clearTrackedPointers( tracker ) {
|
|
|
|
var delegate = THIS[ tracker.hash ],
|
2020-08-14 02:43:49 +03:00
|
|
|
i, j,
|
|
|
|
pointsList,
|
|
|
|
gPoints,
|
|
|
|
gPointsToRemove,
|
2014-12-30 23:57:17 +03:00
|
|
|
pointerListCount = delegate.activePointersLists.length;
|
|
|
|
|
2015-01-01 01:30:10 +03:00
|
|
|
for ( i = 0; i < pointerListCount; i++ ) {
|
2020-08-14 02:43:49 +03:00
|
|
|
pointsList = delegate.activePointersLists[ i ];
|
|
|
|
|
|
|
|
if ( pointsList.getLength() > 0 ) {
|
|
|
|
// Make an array containing references to the gPoints in the pointer list
|
|
|
|
// (because calls to stopTrackingPointer() are going to modify the pointer list)
|
|
|
|
gPointsToRemove = [];
|
|
|
|
gPoints = pointsList.asArray();
|
|
|
|
for ( j = 0; j < gPoints.length; j++ ) {
|
|
|
|
gPointsToRemove.push( gPoints[ j ] );
|
|
|
|
}
|
2014-12-30 23:57:17 +03:00
|
|
|
|
2020-08-14 02:43:49 +03:00
|
|
|
// Release and remove all gPoints from the pointer list
|
|
|
|
for ( j = 0; j < gPointsToRemove.length; j++ ) {
|
|
|
|
stopTrackingPointer( tracker, pointsList, gPointsToRemove[ j ] );
|
|
|
|
}
|
2015-01-01 01:30:10 +03:00
|
|
|
}
|
2014-12-30 23:57:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for ( i = 0; i < pointerListCount; i++ ) {
|
|
|
|
delegate.activePointersLists.pop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2014-04-03 19:50:25 +04:00
|
|
|
* Starts tracking pointer events on the tracked element.
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2012-02-03 04:12:45 +04:00
|
|
|
function startTracking( tracker ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
var delegate = THIS[ tracker.hash ],
|
2013-06-19 21:33:25 +04:00
|
|
|
event,
|
2012-02-03 04:12:45 +04:00
|
|
|
i;
|
|
|
|
|
|
|
|
if ( !delegate.tracking ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
for ( i = 0; i < $.MouseTracker.subscribeEvents.length; i++ ) {
|
|
|
|
event = $.MouseTracker.subscribeEvents[ i ];
|
2013-06-19 21:33:25 +04:00
|
|
|
$.addEvent(
|
|
|
|
tracker.element,
|
|
|
|
event,
|
2013-09-20 20:58:18 +04:00
|
|
|
delegate[ event ],
|
2012-02-03 04:12:45 +04:00
|
|
|
false
|
|
|
|
);
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
2015-06-08 17:38:16 +03:00
|
|
|
|
2014-12-30 23:57:17 +03:00
|
|
|
clearTrackedPointers( tracker );
|
2014-09-13 03:01:19 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
delegate.tracking = true;
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2014-04-03 19:50:25 +04:00
|
|
|
* Stops tracking pointer events on the tracked element.
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2012-02-03 04:12:45 +04:00
|
|
|
function stopTracking( tracker ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
var delegate = THIS[ tracker.hash ],
|
2013-06-19 21:33:25 +04:00
|
|
|
event,
|
2012-02-03 04:12:45 +04:00
|
|
|
i;
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
if ( delegate.tracking ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
for ( i = 0; i < $.MouseTracker.subscribeEvents.length; i++ ) {
|
|
|
|
event = $.MouseTracker.subscribeEvents[ i ];
|
2013-06-19 21:33:25 +04:00
|
|
|
$.removeEvent(
|
|
|
|
tracker.element,
|
|
|
|
event,
|
2013-09-20 20:58:18 +04:00
|
|
|
delegate[ event ],
|
2012-02-03 04:12:45 +04:00
|
|
|
false
|
|
|
|
);
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
|
|
|
|
2014-12-30 23:57:17 +03:00
|
|
|
clearTrackedPointers( tracker );
|
2014-09-13 03:01:19 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
delegate.tracking = false;
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2015-01-01 01:30:10 +03:00
|
|
|
function getCaptureEventParams( tracker, pointerType ) {
|
2014-08-06 00:56:18 +04:00
|
|
|
var delegate = THIS[ tracker.hash ];
|
|
|
|
|
2015-01-13 03:08:26 +03:00
|
|
|
if ( pointerType === 'pointerevent' ) {
|
|
|
|
return {
|
|
|
|
upName: $.MouseTracker.unprefixedPointerEvents ? 'pointerup' : 'MSPointerUp',
|
|
|
|
upHandler: delegate.pointerupcaptured,
|
|
|
|
moveName: $.MouseTracker.unprefixedPointerEvents ? 'pointermove' : 'MSPointerMove',
|
|
|
|
moveHandler: delegate.pointermovecaptured
|
|
|
|
};
|
|
|
|
} else if ( pointerType === 'mouse' ) {
|
2015-01-01 01:30:10 +03:00
|
|
|
return {
|
|
|
|
upName: 'mouseup',
|
|
|
|
upHandler: delegate.mouseupcaptured,
|
|
|
|
moveName: 'mousemove',
|
|
|
|
moveHandler: delegate.mousemovecaptured
|
|
|
|
};
|
|
|
|
} else if ( pointerType === 'touch' ) {
|
|
|
|
return {
|
|
|
|
upName: 'touchend',
|
|
|
|
upHandler: delegate.touchendcaptured,
|
|
|
|
moveName: 'touchmove',
|
|
|
|
moveHandler: delegate.touchmovecaptured
|
|
|
|
};
|
|
|
|
} else {
|
2015-01-13 03:08:26 +03:00
|
|
|
throw new Error( "MouseTracker.getCaptureEventParams: Unknown pointer type." );
|
2015-01-01 01:30:10 +03:00
|
|
|
}
|
|
|
|
}
|
2014-08-06 00:56:18 +04:00
|
|
|
|
2015-01-01 01:30:10 +03:00
|
|
|
/**
|
|
|
|
* Begin capturing pointer events to the tracked element.
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2020-07-31 07:08:02 +03:00
|
|
|
function capturePointer( tracker, gPoint ) {
|
|
|
|
var eventParams;
|
2015-01-01 01:30:10 +03:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
if ( $.MouseTracker.havePointerCapture ) {
|
|
|
|
if ( $.MouseTracker.havePointerEvents ) {
|
2020-08-25 18:51:00 +03:00
|
|
|
// Can throw InvalidPointerId
|
2020-08-25 19:11:00 +03:00
|
|
|
// (should never happen so we'll log a warning)
|
2020-08-25 18:51:00 +03:00
|
|
|
try {
|
|
|
|
if ( $.MouseTracker.unprefixedPointerEvents ) {
|
|
|
|
tracker.element.setPointerCapture( gPoint.id );
|
|
|
|
//$.console.log('element.setPointerCapture() called');
|
|
|
|
} else {
|
|
|
|
tracker.element.msSetPointerCapture( gPoint.id );
|
|
|
|
//$.console.log('element.msSetPointerCapture() called');
|
|
|
|
}
|
|
|
|
} catch ( e ) {
|
|
|
|
$.console.warn('setPointerCapture() called on invalid pointer ID');
|
2015-12-07 19:39:08 +03:00
|
|
|
}
|
2020-07-31 07:08:02 +03:00
|
|
|
} else {
|
|
|
|
tracker.element.setCapture( true );
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('element.setCapture() called');
|
2020-07-31 07:08:02 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Emulate mouse capture by hanging listeners on the document object.
|
|
|
|
// (Note we listen on the capture phase so the captured handlers will get called first)
|
|
|
|
// eslint-disable-next-line no-use-before-define
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('Emulated mouse capture set');
|
2020-07-31 07:08:02 +03:00
|
|
|
eventParams = getCaptureEventParams( tracker, $.MouseTracker.havePointerEvents ? 'pointerevent' : gPoint.type );
|
2020-08-14 02:43:49 +03:00
|
|
|
// https://github.com/openseadragon/openseadragon/pull/790
|
2020-07-31 07:08:02 +03:00
|
|
|
if (isInIframe && canAccessEvents(window.top)) {
|
2015-01-11 01:49:02 +03:00
|
|
|
$.addEvent(
|
2020-07-31 07:08:02 +03:00
|
|
|
window.top,
|
2015-01-11 01:49:02 +03:00
|
|
|
eventParams.upName,
|
|
|
|
eventParams.upHandler,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
2020-07-31 07:08:02 +03:00
|
|
|
$.addEvent(
|
|
|
|
$.MouseTracker.captureElement,
|
|
|
|
eventParams.upName,
|
|
|
|
eventParams.upHandler,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$.addEvent(
|
|
|
|
$.MouseTracker.captureElement,
|
|
|
|
eventParams.moveName,
|
|
|
|
eventParams.moveHandler,
|
|
|
|
true
|
|
|
|
);
|
2014-08-06 00:56:18 +04:00
|
|
|
}
|
2020-07-31 07:08:02 +03:00
|
|
|
|
|
|
|
updatePointerCaptured( tracker, gPoint, true );
|
2014-08-06 00:56:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2014-08-06 21:49:42 +04:00
|
|
|
* Stop capturing pointer events to the tracked element.
|
2014-08-06 00:56:18 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2020-07-31 07:08:02 +03:00
|
|
|
function releasePointer( tracker, gPoint ) {
|
|
|
|
var eventParams;
|
2020-08-25 19:11:00 +03:00
|
|
|
var pointsList;
|
|
|
|
var cachedGPoint;
|
2014-08-06 00:56:18 +04:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
if ( $.MouseTracker.havePointerCapture ) {
|
|
|
|
if ( $.MouseTracker.havePointerEvents ) {
|
2020-08-25 19:11:00 +03:00
|
|
|
pointsList = tracker.getActivePointersListByType( gPoint.type );
|
|
|
|
cachedGPoint = pointsList.getById( gPoint.id );
|
|
|
|
if ( !cachedGPoint || !cachedGPoint.captured ) {
|
|
|
|
return;
|
|
|
|
}
|
2020-08-25 18:51:00 +03:00
|
|
|
// Can throw InvalidPointerId
|
2020-08-25 19:11:00 +03:00
|
|
|
// (should never happen so we'll log a warning)
|
2020-08-25 18:51:00 +03:00
|
|
|
try {
|
|
|
|
if ( $.MouseTracker.unprefixedPointerEvents ) {
|
|
|
|
tracker.element.releasePointerCapture( gPoint.id );
|
|
|
|
//$.console.log('element.releasePointerCapture() called');
|
|
|
|
} else {
|
|
|
|
tracker.element.msReleasePointerCapture( gPoint.id );
|
|
|
|
//$.console.log('element.msReleasePointerCapture() called');
|
|
|
|
}
|
|
|
|
} catch ( e ) {
|
2020-08-25 19:11:00 +03:00
|
|
|
$.console.warn('releasePointerCapture() called on invalid pointer ID');
|
2015-12-07 19:39:08 +03:00
|
|
|
}
|
2020-07-31 07:08:02 +03:00
|
|
|
} else {
|
|
|
|
tracker.element.releaseCapture();
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('element.releaseCapture() called');
|
2020-07-31 07:08:02 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Emulate mouse capture by hanging listeners on the document object.
|
|
|
|
// (Note we listen on the capture phase so the captured handlers will get called first)
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('Emulated mouse capture release');
|
2020-07-31 07:08:02 +03:00
|
|
|
eventParams = getCaptureEventParams( tracker, $.MouseTracker.havePointerEvents ? 'pointerevent' : gPoint.type );
|
2020-08-14 02:43:49 +03:00
|
|
|
// https://github.com/openseadragon/openseadragon/pull/790
|
2020-07-31 07:08:02 +03:00
|
|
|
if (isInIframe && canAccessEvents(window.top)) {
|
2015-01-11 01:49:02 +03:00
|
|
|
$.removeEvent(
|
2020-07-31 07:08:02 +03:00
|
|
|
window.top,
|
2015-01-11 01:49:02 +03:00
|
|
|
eventParams.upName,
|
|
|
|
eventParams.upHandler,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
2020-07-31 07:08:02 +03:00
|
|
|
$.removeEvent(
|
|
|
|
$.MouseTracker.captureElement,
|
|
|
|
eventParams.moveName,
|
|
|
|
eventParams.moveHandler,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$.removeEvent(
|
|
|
|
$.MouseTracker.captureElement,
|
|
|
|
eventParams.upName,
|
|
|
|
eventParams.upHandler,
|
|
|
|
true
|
|
|
|
);
|
2012-02-03 04:12:45 +04:00
|
|
|
}
|
2020-07-31 07:08:02 +03:00
|
|
|
|
|
|
|
updatePointerCaptured( tracker, gPoint, false );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-10 07:16:09 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
/**
|
2014-04-03 19:50:25 +04:00
|
|
|
* Gets a W3C Pointer Events model compatible pointer type string from a DOM pointer event.
|
2014-04-15 05:17:18 +04:00
|
|
|
* IE10 used a long integer value, but the W3C specification (and IE11+) use a string "mouse", "touch", "pen", etc.
|
2014-03-10 22:49:51 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function getPointerType( event ) {
|
2020-07-31 07:08:02 +03:00
|
|
|
// Note: IE pointer events bug - sends invalid pointerType on lostpointercapture events
|
|
|
|
// and possibly other events. We rely on sane, valid property values in DOM events, so for
|
|
|
|
// IE, when the pointerType is missing, we'll default to 'mouse'...should be right most of the time
|
2014-03-10 22:49:51 +04:00
|
|
|
var pointerTypeStr;
|
|
|
|
if ( $.MouseTracker.unprefixedPointerEvents ) {
|
2020-07-31 07:08:02 +03:00
|
|
|
pointerTypeStr = event.pointerType || (( $.Browser.vendor === $.BROWSERS.IE ) ? 'mouse' : '');
|
2014-04-15 05:17:18 +04:00
|
|
|
} else {
|
2014-03-10 22:49:51 +04:00
|
|
|
// IE10
|
|
|
|
// MSPOINTER_TYPE_TOUCH: 0x00000002
|
|
|
|
// MSPOINTER_TYPE_PEN: 0x00000003
|
|
|
|
// MSPOINTER_TYPE_MOUSE: 0x00000004
|
|
|
|
switch( event.pointerType )
|
|
|
|
{
|
|
|
|
case 0x00000002:
|
|
|
|
pointerTypeStr = 'touch';
|
|
|
|
break;
|
|
|
|
case 0x00000003:
|
|
|
|
pointerTypeStr = 'pen';
|
|
|
|
break;
|
|
|
|
case 0x00000004:
|
|
|
|
pointerTypeStr = 'mouse';
|
|
|
|
break;
|
|
|
|
default:
|
2020-07-31 07:08:02 +03:00
|
|
|
pointerTypeStr = 'mouse';
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
2012-02-03 04:12:45 +04:00
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
return pointerTypeStr;
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-10 07:16:09 +04:00
|
|
|
|
2012-03-16 19:36:28 +04:00
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2014-03-10 22:49:51 +04:00
|
|
|
function getMouseAbsolute( event ) {
|
|
|
|
return $.getMousePosition( event );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-03-16 19:36:28 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function getMouseRelative( event, element ) {
|
2014-03-31 23:54:37 +04:00
|
|
|
return getPointRelativeToAbsolute( getMouseAbsolute( event ), element );
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
2012-03-16 19:36:28 +04:00
|
|
|
|
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2014-03-31 23:54:37 +04:00
|
|
|
function getPointRelativeToAbsolute( point, element ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
var offset = $.getElementOffset( element );
|
|
|
|
return point.minus( offset );
|
|
|
|
}
|
|
|
|
|
2014-03-15 01:15:09 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function getCenterPoint( point1, point2 ) {
|
|
|
|
return new $.Point( ( point1.x + point2.x ) / 2, ( point1.y + point2.y ) / 2 );
|
|
|
|
}
|
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2014-04-03 19:50:25 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2014-04-15 05:17:18 +04:00
|
|
|
// Device-specific DOM event handlers
|
2014-04-03 19:50:25 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onClick( tracker, event ) {
|
|
|
|
if ( tracker.clickHandler ) {
|
|
|
|
$.cancelEvent( event );
|
2012-03-16 19:36:28 +04:00
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-03-16 19:36:28 +04:00
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2014-04-22 20:23:56 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onDblClick( tracker, event ) {
|
|
|
|
if ( tracker.dblClickHandler ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-17 03:26:30 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onKeyDown( tracker, event ) {
|
|
|
|
//$.console.log( "keydown %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
|
|
|
|
var propagate;
|
|
|
|
if ( tracker.keyDownHandler ) {
|
|
|
|
event = $.getEvent( event );
|
|
|
|
propagate = tracker.keyDownHandler(
|
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
|
|
|
ctrl: event.ctrlKey,
|
|
|
|
shift: event.shiftKey,
|
|
|
|
alt: event.altKey,
|
|
|
|
meta: event.metaKey,
|
|
|
|
originalEvent: event,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if ( !propagate ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onKeyUp( tracker, event ) {
|
|
|
|
//$.console.log( "keyup %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
|
|
|
|
var propagate;
|
|
|
|
if ( tracker.keyUpHandler ) {
|
|
|
|
event = $.getEvent( event );
|
|
|
|
propagate = tracker.keyUpHandler(
|
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
|
|
|
ctrl: event.ctrlKey,
|
|
|
|
shift: event.shiftKey,
|
|
|
|
alt: event.altKey,
|
|
|
|
meta: event.metaKey,
|
|
|
|
originalEvent: event,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if ( !propagate ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-16 19:36:28 +04:00
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
function onKeyPress( tracker, event ) {
|
2015-01-17 03:26:30 +03:00
|
|
|
//$.console.log( "keypress %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
|
2012-03-20 23:30:29 +04:00
|
|
|
var propagate;
|
2012-03-16 19:36:28 +04:00
|
|
|
if ( tracker.keyHandler ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
event = $.getEvent( event );
|
2013-06-19 21:33:25 +04:00
|
|
|
propagate = tracker.keyHandler(
|
2013-09-06 04:20:17 +04:00
|
|
|
{
|
2013-11-05 00:41:45 +04:00
|
|
|
eventSource: tracker,
|
|
|
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
2015-01-17 03:26:30 +03:00
|
|
|
ctrl: event.ctrlKey,
|
2013-11-05 00:41:45 +04:00
|
|
|
shift: event.shiftKey,
|
2015-01-17 03:26:30 +03:00
|
|
|
alt: event.altKey,
|
|
|
|
meta: event.metaKey,
|
2013-11-05 00:41:45 +04:00
|
|
|
originalEvent: event,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
2013-09-06 04:20:17 +04:00
|
|
|
}
|
2012-04-11 01:02:24 +04:00
|
|
|
);
|
2013-09-06 04:20:17 +04:00
|
|
|
if ( !propagate ) {
|
2012-04-11 01:02:24 +04:00
|
|
|
$.cancelEvent( event );
|
2012-03-16 19:36:28 +04:00
|
|
|
}
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-03-16 19:36:28 +04:00
|
|
|
|
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2014-03-10 22:49:51 +04:00
|
|
|
function onFocus( tracker, event ) {
|
|
|
|
//console.log( "focus %s", event );
|
|
|
|
var propagate;
|
|
|
|
if ( tracker.focusHandler ) {
|
|
|
|
event = $.getEvent( event );
|
|
|
|
propagate = tracker.focusHandler(
|
2013-09-06 04:20:17 +04:00
|
|
|
{
|
2013-11-05 00:41:45 +04:00
|
|
|
eventSource: tracker,
|
|
|
|
originalEvent: event,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
2013-09-06 04:20:17 +04:00
|
|
|
}
|
2012-04-11 01:02:24 +04:00
|
|
|
);
|
2013-09-06 04:20:17 +04:00
|
|
|
if ( propagate === false ) {
|
2012-04-11 01:02:24 +04:00
|
|
|
$.cancelEvent( event );
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
2012-02-03 04:12:45 +04:00
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-10 07:16:09 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2014-03-10 22:49:51 +04:00
|
|
|
function onBlur( tracker, event ) {
|
|
|
|
//console.log( "blur %s", event );
|
|
|
|
var propagate;
|
|
|
|
if ( tracker.blurHandler ) {
|
|
|
|
event = $.getEvent( event );
|
|
|
|
propagate = tracker.blurHandler(
|
2013-09-06 04:20:17 +04:00
|
|
|
{
|
2013-11-05 00:41:45 +04:00
|
|
|
eventSource: tracker,
|
|
|
|
originalEvent: event,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
2013-09-06 04:20:17 +04:00
|
|
|
}
|
2012-04-11 01:02:24 +04:00
|
|
|
);
|
2013-09-06 04:20:17 +04:00
|
|
|
if ( propagate === false ) {
|
2012-04-11 01:02:24 +04:00
|
|
|
$.cancelEvent( event );
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
2012-02-03 04:12:45 +04:00
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-10 07:16:09 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2014-03-10 22:49:51 +04:00
|
|
|
* Handler for 'wheel' events
|
|
|
|
*
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2014-03-10 22:49:51 +04:00
|
|
|
function onWheel( tracker, event ) {
|
|
|
|
handleWheelEvent( tracker, event, event );
|
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2013-09-06 04:20:17 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
/**
|
|
|
|
* Handler for 'mousewheel', 'DOMMouseScroll', and 'MozMousePixelScroll' events
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onMouseWheel( tracker, event ) {
|
|
|
|
event = $.getEvent( event );
|
2013-09-12 21:05:50 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
// Simulate a 'wheel' event
|
|
|
|
var simulatedEvent = {
|
|
|
|
target: event.target || event.srcElement,
|
|
|
|
type: "wheel",
|
|
|
|
shiftKey: event.shiftKey || false,
|
|
|
|
clientX: event.clientX,
|
|
|
|
clientY: event.clientY,
|
|
|
|
pageX: event.pageX ? event.pageX : event.clientX,
|
|
|
|
pageY: event.pageY ? event.pageY : event.clientY,
|
2020-06-26 02:01:14 +03:00
|
|
|
deltaMode: event.type === "MozMousePixelScroll" ? 0 : 1, // 0=pixel, 1=line, 2=page
|
2014-03-10 22:49:51 +04:00
|
|
|
deltaX: 0,
|
|
|
|
deltaZ: 0
|
|
|
|
};
|
2013-02-13 07:40:08 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
// Calculate deltaY
|
2020-06-26 02:01:14 +03:00
|
|
|
if ( $.MouseTracker.wheelEventName === "mousewheel" ) {
|
2017-01-08 17:52:57 +03:00
|
|
|
simulatedEvent.deltaY = -event.wheelDelta / $.DEFAULT_SETTINGS.pixelsPerWheelLine;
|
2014-03-10 22:49:51 +04:00
|
|
|
} else {
|
|
|
|
simulatedEvent.deltaY = event.detail;
|
2012-02-03 04:12:45 +04:00
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
handleWheelEvent( tracker, simulatedEvent, event );
|
|
|
|
}
|
2012-02-03 04:12:45 +04:00
|
|
|
|
2012-02-02 01:56:04 +04:00
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
/**
|
2015-06-08 17:38:16 +03:00
|
|
|
* Handles 'wheel' events.
|
2014-04-15 05:17:18 +04:00
|
|
|
* The event may be simulated by the legacy mouse wheel event handler (onMouseWheel()).
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function handleWheelEvent( tracker, event, originalEvent ) {
|
|
|
|
var nDelta = 0,
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo;
|
2014-04-15 05:17:18 +04:00
|
|
|
|
|
|
|
// The nDelta variable is gated to provide smooth z-index scrolling
|
|
|
|
// since the mouse wheel allows for substantial deltas meant for rapid
|
|
|
|
// y-index scrolling.
|
|
|
|
// event.deltaMode: 0=pixel, 1=line, 2=page
|
|
|
|
// TODO: Deltas in pixel mode should be accumulated then a scroll value computed after $.DEFAULT_SETTINGS.pixelsPerWheelLine threshold reached
|
|
|
|
nDelta = event.deltaY < 0 ? 1 : -1;
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'wheel',
|
|
|
|
pointerType: 'mouse',
|
|
|
|
isEmulated: event !== originalEvent
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
if ( tracker.scrollHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
|
|
|
eventInfo.preventDefault = true;
|
|
|
|
|
|
|
|
tracker.scrollHandler(
|
2014-04-15 05:17:18 +04:00
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: 'mouse',
|
|
|
|
position: getMouseRelative( event, tracker.element ),
|
|
|
|
scroll: nDelta,
|
|
|
|
shift: event.shiftKey,
|
|
|
|
isTouchEvent: false,
|
|
|
|
originalEvent: originalEvent,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( originalEvent );
|
|
|
|
}
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( originalEvent );
|
|
|
|
}
|
|
|
|
}
|
2014-04-15 05:17:18 +04:00
|
|
|
|
|
|
|
|
2014-04-16 00:04:08 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function isParentChild( parent, child )
|
|
|
|
{
|
|
|
|
if ( parent === child ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
while ( child && child !== parent ) {
|
|
|
|
child = child.parentNode;
|
|
|
|
}
|
|
|
|
return child === parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
/**
|
2020-08-13 07:22:48 +03:00
|
|
|
* TODO Never actually seen this event fired, and documentation is tough to find
|
2020-07-31 07:08:02 +03:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onLoseCapture( tracker, event ) {
|
2020-08-21 02:56:57 +03:00
|
|
|
//$.console.log('losecapture ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
2020-07-31 07:08:02 +03:00
|
|
|
event = $.getEvent( event );
|
|
|
|
|
|
|
|
var gPoint = {
|
|
|
|
id: $.MouseTracker.mousePointerId,
|
|
|
|
type: 'mouse'
|
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'lostpointercapture',
|
|
|
|
pointerType: 'mouse',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
updatePointerCaptured( tracker, gPoint, false );
|
2020-08-13 07:22:48 +03:00
|
|
|
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2020-07-31 07:08:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-16 00:04:08 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2015-01-11 01:49:02 +03:00
|
|
|
function onMouseEnter( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('mouseenter ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
|
2015-01-11 01:49:02 +03:00
|
|
|
event = $.getEvent( event );
|
|
|
|
|
2020-07-25 06:05:39 +03:00
|
|
|
var gPoint = {
|
|
|
|
id: $.MouseTracker.mousePointerId,
|
|
|
|
type: 'mouse',
|
|
|
|
isPrimary: true,
|
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
|
|
|
};
|
2014-04-16 00:04:08 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// pointerenter doesn't bubble and is not cancelable, but we call
|
|
|
|
// preProcessEvent() so it's dispatched to preProcessEventHandler
|
|
|
|
// if necessary
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerenter',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerEnter( tracker, eventInfo, gPoint );
|
2014-04-16 00:04:08 +04:00
|
|
|
|
2020-07-26 04:30:06 +03:00
|
|
|
// Simulate mouseover on IE < 9
|
|
|
|
if ( !$.MouseTracker.havePointerOverOut ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
handleMouseOver( tracker, event, true );
|
2020-07-26 04:30:06 +03:00
|
|
|
}
|
2015-01-11 01:49:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2020-07-25 06:05:39 +03:00
|
|
|
function onMouseLeave( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('mouseleave ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
|
2020-07-25 06:05:39 +03:00
|
|
|
event = $.getEvent( event );
|
|
|
|
|
2015-01-11 01:49:02 +03:00
|
|
|
var gPoint = {
|
2014-04-16 00:04:08 +04:00
|
|
|
id: $.MouseTracker.mousePointerId,
|
|
|
|
type: 'mouse',
|
|
|
|
isPrimary: true,
|
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// pointerleave doesn't bubble and is not cancelable, but we call
|
|
|
|
// preProcessEvent() so it's dispatched to preProcessEventHandler
|
|
|
|
// if necessary
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerleave',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2020-07-26 04:30:06 +03:00
|
|
|
// Simulate mouseoout on IE < 9
|
|
|
|
if ( !$.MouseTracker.havePointerOverOut ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
handleMouseOut( tracker, event, true );
|
2020-07-26 04:30:06 +03:00
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
|
|
|
|
updatePointerLeave( tracker, eventInfo, gPoint );
|
2014-04-16 00:04:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-07-25 06:05:39 +03:00
|
|
|
* IE9+ only
|
2015-01-11 01:49:02 +03:00
|
|
|
*
|
2014-04-16 00:04:08 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2020-07-25 06:05:39 +03:00
|
|
|
function onMouseOver( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('mouseover ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
|
|
|
|
handleMouseOver( tracker, event, false );
|
2015-01-11 01:49:02 +03:00
|
|
|
}
|
|
|
|
|
2014-04-16 00:04:08 +04:00
|
|
|
|
2015-01-11 01:49:02 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function handleMouseOver( tracker, event, isEmulated ) {
|
2020-07-25 06:05:39 +03:00
|
|
|
var gPoint = {
|
|
|
|
id: $.MouseTracker.mousePointerId,
|
|
|
|
type: 'mouse',
|
|
|
|
isPrimary: true,
|
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
|
|
|
};
|
2014-04-16 00:04:08 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerover',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: isEmulated
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerOver( tracker, eventInfo, gPoint );
|
|
|
|
|
|
|
|
if ( !isEmulated ) {
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
|
|
|
}
|
2020-07-25 06:05:39 +03:00
|
|
|
}
|
2014-04-16 00:04:08 +04:00
|
|
|
|
2020-07-25 06:05:39 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IE9+ only
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onMouseOut( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('mouseout ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
|
|
|
|
handleMouseOut( tracker, event, false );
|
2015-01-11 01:49:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function handleMouseOut( tracker, event, isEmulated ) {
|
2015-01-11 01:49:02 +03:00
|
|
|
var gPoint = {
|
2014-04-16 00:04:08 +04:00
|
|
|
id: $.MouseTracker.mousePointerId,
|
|
|
|
type: 'mouse',
|
|
|
|
isPrimary: true,
|
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerout',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: isEmulated
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerOut( tracker, eventInfo, gPoint );
|
|
|
|
|
|
|
|
if ( !isEmulated ) {
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
|
|
|
}
|
2014-04-16 00:04:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-11 01:49:02 +03:00
|
|
|
/**
|
|
|
|
* Returns a W3C DOM level 3 standard button value given an event.button property:
|
|
|
|
* -1 == none, 0 == primary/left, 1 == middle, 2 == secondary/right, 3 == X1/back, 4 == X2/forward, 5 == eraser (pen)
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function getStandardizedButton( button ) {
|
|
|
|
if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 9 ) {
|
|
|
|
// On IE 8, 0 == none, 1 == left, 2 == right, 3 == left and right, 4 == middle, 5 == left and middle, 6 == right and middle, 7 == all three
|
|
|
|
// TODO: Support chorded (multiple) button presses on IE 8?
|
|
|
|
if ( button === 1 ) {
|
|
|
|
return 0;
|
|
|
|
} else if ( button === 2 ) {
|
|
|
|
return 2;
|
|
|
|
} else if ( button === 4 ) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-10 07:16:09 +04:00
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2014-03-10 22:49:51 +04:00
|
|
|
function onMouseDown( tracker, event ) {
|
2014-03-31 23:54:37 +04:00
|
|
|
var gPoint;
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2014-03-30 04:02:24 +04:00
|
|
|
event = $.getEvent( event );
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
//$.console.log('onMouseDown ' + (tracker.userData ? tracker.userData.toString() : ''));
|
|
|
|
|
2014-03-21 22:45:20 +04:00
|
|
|
gPoint = {
|
2014-03-10 22:49:51 +04:00
|
|
|
id: $.MouseTracker.mousePointerId,
|
|
|
|
type: 'mouse',
|
2014-04-01 20:32:04 +04:00
|
|
|
isPrimary: true,
|
2014-03-31 23:54:37 +04:00
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
2014-03-10 22:49:51 +04:00
|
|
|
};
|
2013-09-06 04:20:17 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerdown',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
2012-02-10 07:16:09 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updatePointerDown( tracker, eventInfo, gPoint, getStandardizedButton( event.button ) );
|
|
|
|
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.shouldCapture ) {
|
|
|
|
//$.stopEvent( event );
|
|
|
|
//$.console.log('mousedown calling capturePointer() ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
capturePointer( tracker, gPoint );
|
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onMouseUp( tracker, event ) {
|
2014-04-15 05:17:18 +04:00
|
|
|
handleMouseUp( tracker, event );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-02-10 07:16:09 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* This handler is attached to the window object (on the capture phase) to emulate mouse capture.
|
|
|
|
* onMouseUp is still attached to the tracked element, so stop propagation to avoid processing twice.
|
|
|
|
*
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2014-04-02 05:27:54 +04:00
|
|
|
function onMouseUpCaptured( tracker, event ) {
|
|
|
|
handleMouseUp( tracker, event );
|
2014-04-15 05:17:18 +04:00
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function handleMouseUp( tracker, event ) {
|
|
|
|
var gPoint;
|
|
|
|
|
|
|
|
event = $.getEvent( event );
|
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
//$.console.log('onMouseUp ' + (tracker.userData ? tracker.userData.toString() : ''));
|
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
gPoint = {
|
|
|
|
id: $.MouseTracker.mousePointerId,
|
|
|
|
type: 'mouse',
|
|
|
|
isPrimary: true,
|
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerup',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerUp( tracker, eventInfo, gPoint, getStandardizedButton( event.button ) );
|
|
|
|
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( eventInfo.shouldReleaseCapture ) {
|
|
|
|
//$.stopEvent( event );
|
|
|
|
releasePointer( tracker, gPoint );
|
|
|
|
}
|
2014-04-02 05:27:54 +04:00
|
|
|
}
|
2012-02-03 04:12:45 +04:00
|
|
|
|
2015-01-11 01:49:02 +03:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2013-09-06 04:20:17 +04:00
|
|
|
function onMouseMove( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
handleMouseMove( tracker, event );
|
2014-03-31 23:54:37 +04:00
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2015-06-08 17:38:16 +03:00
|
|
|
|
2013-10-23 00:54:04 +04:00
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* This handler is attached to the window object (on the capture phase) to emulate mouse capture.
|
|
|
|
* onMouseMove is still attached to the tracked element, so stop propagation to avoid processing twice.
|
|
|
|
*
|
2013-10-23 00:54:04 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2014-03-10 22:49:51 +04:00
|
|
|
function onMouseMoveCaptured( tracker, event ) {
|
|
|
|
handleMouseMove( tracker, event );
|
2014-04-15 05:17:18 +04:00
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function handleMouseMove( tracker, event ) {
|
|
|
|
var gPoint;
|
|
|
|
|
|
|
|
event = $.getEvent( event );
|
|
|
|
|
|
|
|
gPoint = {
|
|
|
|
id: $.MouseTracker.mousePointerId,
|
|
|
|
type: 'mouse',
|
|
|
|
isPrimary: true,
|
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointermove',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerMove( tracker, eventInfo, gPoint );
|
|
|
|
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2013-09-06 04:20:17 +04:00
|
|
|
}
|
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
//TODO Revisit this if there's still an issue. The PointerEvent model should have no problems
|
|
|
|
// like the issue this code attempts to fix.
|
|
|
|
// /**
|
|
|
|
// * @private
|
|
|
|
// * @inner
|
|
|
|
// */
|
|
|
|
// function abortContacts( tracker, event, pointsList ) {
|
|
|
|
// var i,
|
|
|
|
// gPointCount = pointsList.getLength(),
|
|
|
|
// abortGPoints = [];
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
// // Check contact count for hoverable pointer types before aborting
|
|
|
|
// if (pointsList.type === 'touch' || pointsList.contacts > 0) {
|
|
|
|
// for ( i = 0; i < gPointCount; i++ ) {
|
|
|
|
// abortGPoints.push( pointsList.getByIndex( i ) );
|
|
|
|
// }
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
// if ( abortGPoints.length > 0 ) {
|
|
|
|
// // simulate touchend/mouseup
|
2020-08-13 07:22:48 +03:00
|
|
|
// updatePointerUp( tracker, eventInfo, , 0 ); // 0 means primary button press/release or touch contact
|
2020-07-31 07:08:02 +03:00
|
|
|
// // release pointer capture
|
|
|
|
// pointsList.captureCount = 1;
|
|
|
|
// //releasePointer( tracker, pointsList.type );
|
|
|
|
// // simulate touchleave/mouseout
|
2020-08-13 07:22:48 +03:00
|
|
|
// updatePointerLeave( tracker, eventInfo, );
|
2020-07-31 07:08:02 +03:00
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2014-03-21 22:45:20 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onTouchStart( tracker, event ) {
|
2014-04-15 05:17:18 +04:00
|
|
|
var time,
|
2014-03-21 22:45:20 +04:00
|
|
|
i,
|
|
|
|
touchCount = event.changedTouches.length,
|
2020-08-13 07:22:48 +03:00
|
|
|
gPoint,
|
2015-01-15 23:15:22 +03:00
|
|
|
pointsList = tracker.getActivePointersListByType( 'touch' );
|
2014-03-21 22:45:20 +04:00
|
|
|
|
|
|
|
time = $.now();
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('touchstart ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2020-07-31 07:08:02 +03:00
|
|
|
|
|
|
|
//TODO Revisit this if there's still an issue. The PointerEvent model should have no problems
|
|
|
|
// like the issue this code attempts to fix.
|
|
|
|
// if ( pointsList.getLength() > event.touches.length - touchCount ) {
|
|
|
|
// $.console.warn('Tracked touch contact count doesn\'t match event.touches.length. Removing all tracked touch pointers.');
|
|
|
|
// abortContacts( tracker, event, pointsList );
|
|
|
|
// }
|
2015-01-15 23:15:22 +03:00
|
|
|
if ( pointsList.getLength() > event.touches.length - touchCount ) {
|
2020-07-31 07:08:02 +03:00
|
|
|
$.console.warn('Tracked touch contact count doesn\'t match event.touches.length');
|
2015-01-15 23:15:22 +03:00
|
|
|
}
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerdown',
|
|
|
|
pointerType: 'touch',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
for ( i = 0; i < touchCount; i++ ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
gPoint = {
|
2014-03-10 22:49:51 +04:00
|
|
|
id: event.changedTouches[ i ].identifier,
|
|
|
|
type: 'touch',
|
2020-08-21 02:56:57 +03:00
|
|
|
// Simulate isPrimary
|
|
|
|
isPrimary: pointsList.getLength() === 0,
|
2014-03-31 23:54:37 +04:00
|
|
|
currentPos: getMouseAbsolute( event.changedTouches[ i ] ),
|
2014-03-10 22:49:51 +04:00
|
|
|
currentTime: time
|
2020-08-13 07:22:48 +03:00
|
|
|
};
|
2013-10-23 23:58:36 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// simulate touchenter on our tracked element
|
|
|
|
updatePointerEnter( tracker, eventInfo, gPoint );
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updatePointerCaptured( tracker, gPoint, true );
|
2020-07-31 07:08:02 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updatePointerDown( tracker, eventInfo, gPoint, 0 );
|
2014-03-21 22:45:20 +04:00
|
|
|
}
|
2014-04-15 05:17:18 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onTouchEnd( tracker, event ) {
|
2014-04-15 05:17:18 +04:00
|
|
|
var time,
|
2014-03-10 22:49:51 +04:00
|
|
|
i,
|
|
|
|
touchCount = event.changedTouches.length,
|
2020-08-13 07:22:48 +03:00
|
|
|
gPoint;
|
2014-03-10 22:49:51 +04:00
|
|
|
|
|
|
|
time = $.now();
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('touchend ' + (tracker.userData ? tracker.userData.toString() : ''));
|
|
|
|
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerup',
|
|
|
|
pointerType: 'touch',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
2020-07-31 07:08:02 +03:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
for ( i = 0; i < touchCount; i++ ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
gPoint = {
|
2014-03-10 22:49:51 +04:00
|
|
|
id: event.changedTouches[ i ].identifier,
|
|
|
|
type: 'touch',
|
2014-03-31 23:54:37 +04:00
|
|
|
currentPos: getMouseAbsolute( event.changedTouches[ i ] ),
|
2014-03-10 22:49:51 +04:00
|
|
|
currentTime: time
|
2020-08-13 07:22:48 +03:00
|
|
|
};
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updatePointerUp( tracker, eventInfo, gPoint, 0 );
|
2020-07-31 07:08:02 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updatePointerCaptured( tracker, gPoint, false );
|
|
|
|
|
|
|
|
// simulate touchleave on our tracked element
|
|
|
|
updatePointerLeave( tracker, eventInfo, gPoint );
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onTouchMove( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
var time,
|
|
|
|
i,
|
|
|
|
touchCount = event.changedTouches.length,
|
|
|
|
gPoint;
|
2015-01-01 01:30:10 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
time = $.now();
|
2015-01-01 01:30:10 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointermove',
|
|
|
|
pointerType: 'touch',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
2014-03-10 22:49:51 +04:00
|
|
|
|
|
|
|
for ( i = 0; i < touchCount; i++ ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
gPoint = {
|
2014-03-10 22:49:51 +04:00
|
|
|
id: event.changedTouches[ i ].identifier,
|
|
|
|
type: 'touch',
|
2014-03-31 23:54:37 +04:00
|
|
|
currentPos: getMouseAbsolute( event.changedTouches[ i ] ),
|
2020-08-13 07:22:48 +03:00
|
|
|
currentTime: time
|
|
|
|
};
|
2013-10-23 23:58:36 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updatePointerMove( tracker, eventInfo, gPoint );
|
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2013-10-23 23:58:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-21 22:45:20 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onTouchCancel( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
var touchCount = event.changedTouches.length,
|
|
|
|
i,
|
|
|
|
gPoint;
|
|
|
|
|
|
|
|
//$.console.log('touchcancel ' + (tracker.userData ? tracker.userData.toString() : ''));
|
|
|
|
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointercancel',
|
|
|
|
pointerType: 'touch',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
for ( i = 0; i < touchCount; i++ ) {
|
|
|
|
gPoint = {
|
|
|
|
id: event.changedTouches[ i ].identifier,
|
|
|
|
type: 'touch'
|
|
|
|
};
|
2020-07-31 07:08:02 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
//TODO need to only do this if our element is target?
|
|
|
|
updatePointerCancel( tracker, eventInfo, gPoint );
|
|
|
|
}
|
2017-01-08 17:52:57 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2014-03-21 22:45:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-14 21:42:22 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onGestureStart( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( !$.eventIsCanceled( event ) ) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2014-03-14 21:42:22 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onGestureChange( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( !$.eventIsCanceled( event ) ) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2014-03-14 21:42:22 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onGotPointerCapture( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('gotpointercapture ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'gotpointercapture',
|
|
|
|
pointerType: getPointerType( event ),
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
2020-07-31 07:08:02 +03:00
|
|
|
|
|
|
|
if ( event.target === tracker.element ) {
|
|
|
|
//$.console.log('gotpointercapture ' + (tracker.userData ? tracker.userData.toString() : ''));
|
|
|
|
updatePointerCaptured( tracker, {
|
|
|
|
id: event.pointerId,
|
|
|
|
type: getPointerType( event )
|
|
|
|
}, true );
|
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2020-07-31 07:08:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onLostPointerCapture( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
//$.console.log('lostpointercapture ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'lostpointercapture',
|
|
|
|
pointerType: getPointerType( event ),
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
2020-07-31 07:08:02 +03:00
|
|
|
|
|
|
|
if ( event.target === tracker.element ) {
|
|
|
|
//$.console.log('lostpointercapture ' + (tracker.userData ? tracker.userData.toString() : ''));
|
|
|
|
updatePointerCaptured( tracker, {
|
|
|
|
id: event.pointerId,
|
|
|
|
type: getPointerType( event )
|
|
|
|
}, false );
|
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2020-07-31 07:08:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-05 08:41:07 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2020-07-25 06:05:39 +03:00
|
|
|
function onPointerEnter( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
handlePointerEnter( tracker, event, false );
|
2020-07-26 04:30:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function handlePointerEnter( tracker, event, isEmulated ) {
|
2014-08-05 08:41:07 +04:00
|
|
|
var gPoint;
|
|
|
|
|
2020-07-26 04:30:06 +03:00
|
|
|
//$.console.log('pointerenter ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2014-08-05 08:41:07 +04:00
|
|
|
|
|
|
|
gPoint = {
|
|
|
|
id: event.pointerId,
|
|
|
|
type: getPointerType( event ),
|
|
|
|
isPrimary: event.isPrimary,
|
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// pointerenter doesn't bubble and is not cancelable, but we call
|
|
|
|
// preProcessEvent() so it's dispatched to preProcessEventHandler
|
|
|
|
// if necessary
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerenter',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: isEmulated
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerEnter( tracker, eventInfo, gPoint );
|
2020-07-26 04:30:06 +03:00
|
|
|
}
|
2020-07-25 06:05:39 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerLeave( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
handlePointerLeave( tracker, event, false );
|
2020-07-26 04:30:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function handlePointerLeave( tracker, event, isEmulated ) {
|
2020-07-25 06:05:39 +03:00
|
|
|
var gPoint;
|
|
|
|
|
2020-07-26 04:30:06 +03:00
|
|
|
//$.console.log('pointerleave ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2020-07-25 06:05:39 +03:00
|
|
|
|
|
|
|
gPoint = {
|
|
|
|
id: event.pointerId,
|
|
|
|
type: getPointerType( event ),
|
|
|
|
isPrimary: event.isPrimary,
|
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// pointerleave doesn't bubble and is not cancelable, but we call
|
|
|
|
// preProcessEvent() so it's dispatched to preProcessEventHandler
|
|
|
|
// if necessary
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerleave',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: isEmulated
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerLeave( tracker, eventInfo, gPoint );
|
2020-07-25 06:05:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerOver( tracker, event ) {
|
2020-07-26 04:30:06 +03:00
|
|
|
//$.console.log('pointerover ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var gPoint = {
|
2020-07-25 06:05:39 +03:00
|
|
|
id: event.pointerId,
|
|
|
|
type: getPointerType( event ),
|
|
|
|
isPrimary: event.isPrimary,
|
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerover',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
// If on IE 10, simulate MSPointerEnter
|
|
|
|
if ( !$.MouseTracker.unprefixedPointerEvents &&
|
|
|
|
event.currentTarget !== event.relatedTarget &&
|
|
|
|
!isParentChild( event.currentTarget, event.relatedTarget ) ) {
|
|
|
|
handlePointerEnter( tracker, event, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
updatePointerOver( tracker, eventInfo, gPoint );
|
|
|
|
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2014-08-05 08:41:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerOut( tracker, event ) {
|
2020-07-26 04:30:06 +03:00
|
|
|
//$.console.log('pointerout ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var gPoint = {
|
2014-08-05 08:41:07 +04:00
|
|
|
id: event.pointerId,
|
|
|
|
type: getPointerType( event ),
|
|
|
|
isPrimary: event.isPrimary,
|
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerout',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerOut( tracker, eventInfo, gPoint );
|
|
|
|
|
|
|
|
// If on IE 10, simulate MSPointerLeave
|
|
|
|
if ( !$.MouseTracker.unprefixedPointerEvents &&
|
|
|
|
event.currentTarget !== event.relatedTarget &&
|
|
|
|
!isParentChild( event.currentTarget, event.relatedTarget ) ) {
|
|
|
|
handlePointerLeave( tracker, event, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2014-08-05 08:41:07 +04:00
|
|
|
}
|
|
|
|
|
2015-01-14 19:44:14 +03:00
|
|
|
|
2014-03-21 22:45:20 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerDown( tracker, event ) {
|
2014-03-31 23:54:37 +04:00
|
|
|
var gPoint;
|
2020-07-31 07:08:02 +03:00
|
|
|
|
|
|
|
//$.console.log('onPointerDown ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2020-08-13 07:22:48 +03:00
|
|
|
// $.console.log('onPointerDown ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + event.target.tagName);
|
|
|
|
|
|
|
|
// Most browsers implicitly capture touch pointer events
|
|
|
|
// Note no IE versions have element.hasPointerCapture() so no implicit
|
|
|
|
// pointer capture possible
|
|
|
|
var implicitlyCaptured = (tracker.element.hasPointerCapture &&
|
|
|
|
$.Browser.vendor !== $.BROWSERS.IE &&
|
|
|
|
$.MouseTracker.unprefixedPointerEvents) ?
|
2020-07-31 07:08:02 +03:00
|
|
|
tracker.element.hasPointerCapture(event.pointerId) : false;
|
2020-08-13 07:22:48 +03:00
|
|
|
// if (implicitlyCaptured) {
|
|
|
|
// $.console.log('pointerdown implicitlyCaptured ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
// } else {
|
|
|
|
// $.console.log('pointerdown not implicitlyCaptured ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
// }
|
2014-03-21 22:45:20 +04:00
|
|
|
|
|
|
|
gPoint = {
|
|
|
|
id: event.pointerId,
|
|
|
|
type: getPointerType( event ),
|
2014-04-01 20:32:04 +04:00
|
|
|
isPrimary: event.isPrimary,
|
2014-03-31 23:54:37 +04:00
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
2014-03-21 22:45:20 +04:00
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerdown',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
2020-07-31 07:08:02 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updatePointerDown( tracker, eventInfo, gPoint, event.button );
|
2020-07-31 07:08:02 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.shouldCapture && !implicitlyCaptured ) {
|
|
|
|
//$.console.log('pointerdown calling capturePointer() ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
capturePointer( tracker, gPoint );
|
|
|
|
} else if ( !eventInfo.shouldCapture && implicitlyCaptured ) {
|
|
|
|
//$.console.log('pointerdown calling releasePointer() ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
releasePointer( tracker, gPoint ); //TODO should we do this? Investigate when implementing bubble handling
|
|
|
|
}
|
2014-03-21 22:45:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerUp( tracker, event ) {
|
2014-08-05 08:41:07 +04:00
|
|
|
handlePointerUp( tracker, event );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This handler is attached to the window object (on the capture phase) to emulate mouse capture.
|
|
|
|
* onPointerUp is still attached to the tracked element, so stop propagation to avoid processing twice.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerUpCaptured( tracker, event ) {
|
2014-08-06 00:56:18 +04:00
|
|
|
var pointsList = tracker.getActivePointersListByType( getPointerType( event ) );
|
|
|
|
if ( pointsList.getById( event.pointerId ) ) {
|
|
|
|
handlePointerUp( tracker, event );
|
|
|
|
}
|
2014-08-05 08:41:07 +04:00
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function handlePointerUp( tracker, event ) {
|
2014-03-31 23:54:37 +04:00
|
|
|
var gPoint;
|
2014-03-21 22:45:20 +04:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
//$.console.log('onPointerUp ' + (tracker.userData ? tracker.userData.toString() : ''));
|
|
|
|
|
2014-03-21 22:45:20 +04:00
|
|
|
gPoint = {
|
|
|
|
id: event.pointerId,
|
|
|
|
type: getPointerType( event ),
|
2014-04-01 20:32:04 +04:00
|
|
|
isPrimary: event.isPrimary,
|
2014-03-31 23:54:37 +04:00
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
2014-03-21 22:45:20 +04:00
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointerup',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerUp( tracker, eventInfo, gPoint, event.button );
|
|
|
|
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Per spec, pointerup events are supposed to release capture. Not all browser
|
|
|
|
// versions have adhered to the spec, and there's no harm in releasing
|
|
|
|
// explicitly
|
|
|
|
if ( eventInfo.shouldReleaseCapture && event.target === tracker.element ) {
|
|
|
|
//$.stopEvent( event );
|
|
|
|
releasePointer( tracker, gPoint );
|
|
|
|
}
|
2014-03-21 22:45:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerMove( tracker, event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
handlePointerMove( tracker, event );
|
2014-08-05 08:41:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This handler is attached to the window object (on the capture phase) to emulate mouse capture.
|
|
|
|
* onPointerMove is still attached to the tracked element, so stop propagation to avoid processing twice.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerMoveCaptured( tracker, event ) {
|
2014-08-06 00:56:18 +04:00
|
|
|
var pointsList = tracker.getActivePointersListByType( getPointerType( event ) );
|
|
|
|
if ( pointsList.getById( event.pointerId ) ) {
|
|
|
|
handlePointerMove( tracker, event );
|
|
|
|
}
|
2014-08-05 08:41:07 +04:00
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function handlePointerMove( tracker, event ) {
|
2014-03-21 22:45:20 +04:00
|
|
|
// Pointer changed coordinates, button state, pressure, tilt, or contact geometry (e.g. width and height)
|
2014-03-31 23:54:37 +04:00
|
|
|
var gPoint;
|
2014-03-21 22:45:20 +04:00
|
|
|
|
|
|
|
gPoint = {
|
|
|
|
id: event.pointerId,
|
|
|
|
type: getPointerType( event ),
|
2014-04-01 20:32:04 +04:00
|
|
|
isPrimary: event.isPrimary,
|
2014-03-31 23:54:37 +04:00
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
2014-03-21 22:45:20 +04:00
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointermove',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerMove( tracker, eventInfo, gPoint );
|
|
|
|
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2014-03-21 22:45:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerCancel( tracker, event ) {
|
2020-08-21 02:56:57 +03:00
|
|
|
//$.console.log('pointercancel ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2014-03-21 22:45:20 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var gPoint = {
|
2014-03-21 22:45:20 +04:00
|
|
|
id: event.pointerId,
|
2014-06-14 13:15:40 +04:00
|
|
|
type: getPointerType( event )
|
2014-03-21 22:45:20 +04:00
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'pointercancel',
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
//TODO need to only do this if our element is target?
|
|
|
|
updatePointerCancel( tracker, eventInfo, gPoint );
|
|
|
|
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2014-03-21 22:45:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-03 19:50:25 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2014-04-15 05:17:18 +04:00
|
|
|
// Device-agnostic DOM event handlers
|
2014-04-03 19:50:25 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-10-23 23:58:36 +04:00
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* @function
|
2013-10-23 23:58:36 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePointList} pointsList
|
|
|
|
* The GesturePointList to track the pointer in.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gPoint
|
|
|
|
* Gesture point to track.
|
|
|
|
* @returns {Number} Number of gesture points in pointsList.
|
2013-10-23 23:58:36 +04:00
|
|
|
*/
|
2014-04-15 05:17:18 +04:00
|
|
|
function startTrackingPointer( pointsList, gPoint ) {
|
|
|
|
gPoint.speed = 0;
|
|
|
|
gPoint.direction = 0;
|
|
|
|
gPoint.contactPos = gPoint.currentPos;
|
|
|
|
gPoint.contactTime = gPoint.currentTime;
|
|
|
|
gPoint.lastPos = gPoint.currentPos;
|
|
|
|
gPoint.lastTime = gPoint.currentTime;
|
|
|
|
|
|
|
|
return pointsList.add( gPoint );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-02-03 04:12:45 +04:00
|
|
|
|
2012-02-10 07:16:09 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* @function
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
2020-08-14 02:43:49 +03:00
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePointList} pointsList
|
|
|
|
* The GesturePointList to stop tracking the pointer on.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gPoint
|
|
|
|
* Gesture point to stop tracking.
|
|
|
|
* @returns {Number} Number of gesture points in pointsList.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2020-08-14 02:43:49 +03:00
|
|
|
function stopTrackingPointer( tracker, pointsList, gPoint ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
var listLength;
|
2014-04-15 05:17:18 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
var trackedGPoint = pointsList.getById( gPoint.id );
|
2014-04-15 05:17:18 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( trackedGPoint ) {
|
|
|
|
if ( trackedGPoint.captured ) {
|
2020-08-14 02:43:49 +03:00
|
|
|
releasePointer( tracker, trackedGPoint );
|
2020-08-13 07:22:48 +03:00
|
|
|
pointsList.removeContact();
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
|
|
|
|
listLength = pointsList.removeById( gPoint.id );
|
2014-04-15 05:17:18 +04:00
|
|
|
} else {
|
|
|
|
listLength = pointsList.getLength();
|
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
return listLength;
|
|
|
|
}
|
2013-09-06 04:20:17 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* @function
|
2014-03-10 22:49:51 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function getEventProcessDefaults( tracker, eventInfo ) {
|
|
|
|
switch ( eventInfo.eventType ) {
|
|
|
|
case 'pointermove':
|
|
|
|
eventInfo.isStopable = true;
|
|
|
|
eventInfo.isCancelable = true;
|
|
|
|
eventInfo.preventDefault = false;
|
|
|
|
eventInfo.preventGesture = !tracker.hasGestureHandlers;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'pointerover':
|
|
|
|
case 'pointerout':
|
|
|
|
eventInfo.isStopable = true;
|
|
|
|
eventInfo.isCancelable = true;
|
|
|
|
eventInfo.preventDefault = false;
|
|
|
|
eventInfo.preventGesture = false;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'pointerdown':
|
|
|
|
eventInfo.isStopable = true;
|
|
|
|
eventInfo.isCancelable = true;
|
|
|
|
eventInfo.preventDefault = false;//tracker.hasGestureHandlers;
|
|
|
|
eventInfo.preventGesture = !tracker.hasGestureHandlers;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'pointerup':
|
|
|
|
eventInfo.isStopable = true;
|
|
|
|
eventInfo.isCancelable = true;
|
|
|
|
eventInfo.preventDefault = false;
|
|
|
|
eventInfo.preventGesture = !tracker.hasGestureHandlers;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'wheel':
|
|
|
|
eventInfo.isStopable = true;
|
|
|
|
eventInfo.isCancelable = true;
|
|
|
|
eventInfo.preventDefault = false;//tracker.hasScrollHandler;
|
|
|
|
eventInfo.preventGesture = !tracker.hasScrollHandler;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'gotpointercapture':
|
|
|
|
case 'lostpointercapture':
|
|
|
|
case 'pointercancel':
|
|
|
|
eventInfo.isStopable = true;
|
|
|
|
eventInfo.isCancelable = false;
|
|
|
|
eventInfo.preventDefault = false;
|
|
|
|
eventInfo.preventGesture = false;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'pointerenter':
|
|
|
|
case 'pointerleave':
|
|
|
|
default:
|
|
|
|
eventInfo.isStopable = false;
|
|
|
|
eventInfo.isCancelable = false;
|
|
|
|
eventInfo.preventDefault = false;
|
|
|
|
eventInfo.preventGesture = false;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-02-03 04:12:45 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
/**
|
|
|
|
* Sets up for and calls preProcessEventHandler. Call with the following parameters -
|
|
|
|
* this function will fill in the rest of the preProcessEventHandler event object
|
|
|
|
* properties
|
|
|
|
*
|
|
|
|
* @function
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.EventProcessInfo} eventInfo
|
|
|
|
* @param {Object} eventInfo.originalEvent
|
|
|
|
* @param {String} eventInfo.eventType
|
|
|
|
* @param {String} eventInfo.pointerType
|
|
|
|
* @param {Boolean} eventInfo.isEmulated
|
|
|
|
*/
|
|
|
|
function preProcessEvent( tracker, eventInfo ) {
|
|
|
|
eventInfo.eventSource = tracker;
|
|
|
|
eventInfo.eventPhase = eventInfo.originalEvent ?
|
|
|
|
((typeof eventInfo.originalEvent.eventPhase !== 'undefined') ?
|
|
|
|
eventInfo.originalEvent.eventPhase : 0) : 0;
|
|
|
|
eventInfo.defaultPrevented = $.eventIsCanceled( eventInfo.originalEvent );
|
|
|
|
eventInfo.shouldCapture = false;
|
|
|
|
eventInfo.shouldReleaseCapture = false;
|
|
|
|
eventInfo.userData = tracker.userData;
|
|
|
|
|
|
|
|
getEventProcessDefaults( tracker, eventInfo );
|
|
|
|
|
|
|
|
if ( tracker.preProcessEventHandler ) {
|
|
|
|
tracker.preProcessEventHandler( eventInfo );
|
|
|
|
}
|
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
/**
|
|
|
|
* Sets or resets the captured property on the tracked pointer matching the passed gPoint's id/type
|
|
|
|
*
|
|
|
|
* @function
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
|
|
|
* @param {Object} gPoint
|
|
|
|
* An object with id and type properties describing the pointer to update.
|
|
|
|
* @param {Boolean} isCaptured
|
|
|
|
* Value to set the captured property to.
|
|
|
|
*/
|
|
|
|
function updatePointerCaptured( tracker, gPoint, isCaptured ) {
|
|
|
|
var pointsList = tracker.getActivePointersListByType( gPoint.type );
|
|
|
|
var updateGPoint = pointsList.getById( gPoint.id );
|
|
|
|
|
|
|
|
if ( updateGPoint ) {
|
|
|
|
if ( isCaptured && !updateGPoint.captured ) {
|
|
|
|
updateGPoint.captured = true;
|
|
|
|
pointsList.captureCount++;
|
|
|
|
} else if ( !isCaptured && updateGPoint.captured ) {
|
|
|
|
updateGPoint.captured = false;
|
|
|
|
pointsList.captureCount--;
|
|
|
|
if ( pointsList.captureCount < 0 ) {
|
|
|
|
pointsList.captureCount = 0;
|
|
|
|
$.console.warn('updatePointerCaptured() - pointsList.captureCount went negative');
|
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
} else {
|
|
|
|
$.console.warn('updatePointerCaptured() called on untracked pointer');
|
2012-02-02 01:56:04 +04:00
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-10 07:16:09 +04:00
|
|
|
|
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* @function
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
2020-08-13 07:22:48 +03:00
|
|
|
* @param {OpenSeadragon.MouseTracker.EventProcessInfo} eventInfo
|
|
|
|
* Processing info for originating DOM event.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gPoint
|
|
|
|
* Gesture point associated with the event.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function updatePointerEnter( tracker, eventInfo, gPoint ) {
|
|
|
|
var pointsList = tracker.getActivePointersListByType( gPoint.type ),
|
|
|
|
updateGPoint;
|
2012-02-10 07:16:09 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updateGPoint = pointsList.getById( gPoint.id );
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( updateGPoint ) {
|
|
|
|
// Already tracking the pointer...update it
|
|
|
|
updateGPoint.insideElement = true;
|
|
|
|
updateGPoint.lastPos = updateGPoint.currentPos;
|
|
|
|
updateGPoint.lastTime = updateGPoint.currentTime;
|
|
|
|
updateGPoint.currentPos = gPoint.currentPos;
|
|
|
|
updateGPoint.currentTime = gPoint.currentTime;
|
|
|
|
|
|
|
|
gPoint = updateGPoint;
|
|
|
|
} else {
|
|
|
|
// Initialize for tracking and add to the tracking list
|
|
|
|
gPoint.captured = false; // Handled by updatePointerCaptured()
|
|
|
|
gPoint.insideElementPressed = false;
|
|
|
|
gPoint.insideElement = true;
|
|
|
|
startTrackingPointer( pointsList, gPoint );
|
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// Enter (doesn't bubble and not cancelable)
|
|
|
|
if ( tracker.enterHandler ) {
|
|
|
|
tracker.enterHandler(
|
|
|
|
{
|
2020-07-25 06:05:39 +03:00
|
|
|
eventSource: tracker,
|
2020-08-13 07:22:48 +03:00
|
|
|
pointerType: gPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( gPoint.currentPos, tracker.element ),
|
2020-07-25 06:05:39 +03:00
|
|
|
buttons: pointsList.buttons,
|
|
|
|
pointers: tracker.getActivePointerCount(),
|
2020-08-13 07:22:48 +03:00
|
|
|
insideElementPressed: gPoint.insideElementPressed,
|
2020-07-25 06:05:39 +03:00
|
|
|
buttonDownAny: pointsList.buttons !== 0,
|
2020-08-13 07:22:48 +03:00
|
|
|
isTouchEvent: gPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
2020-07-25 06:05:39 +03:00
|
|
|
userData: tracker.userData
|
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
);
|
2020-07-25 06:05:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
2020-08-13 07:22:48 +03:00
|
|
|
* @param {OpenSeadragon.MouseTracker.EventProcessInfo} eventInfo
|
|
|
|
* Processing info for originating DOM event.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gPoint
|
|
|
|
* Gesture point associated with the event.
|
2020-07-25 06:05:39 +03:00
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function updatePointerLeave( tracker, eventInfo, gPoint ) {
|
|
|
|
var pointsList = tracker.getActivePointersListByType(gPoint.type),
|
2020-07-25 06:05:39 +03:00
|
|
|
updateGPoint,
|
2020-08-13 07:22:48 +03:00
|
|
|
dispatchEventObj;
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updateGPoint = pointsList.getById( gPoint.id );
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( updateGPoint ) {
|
|
|
|
// Already tracking the pointer. If captured then update it, else stop tracking it
|
|
|
|
if ( updateGPoint.captured ) {
|
|
|
|
updateGPoint.insideElement = false;
|
|
|
|
updateGPoint.lastPos = updateGPoint.currentPos;
|
|
|
|
updateGPoint.lastTime = updateGPoint.currentTime;
|
|
|
|
updateGPoint.currentPos = gPoint.currentPos;
|
|
|
|
updateGPoint.currentTime = gPoint.currentTime;
|
|
|
|
} else {
|
2020-08-14 02:43:49 +03:00
|
|
|
stopTrackingPointer( tracker, pointsList, updateGPoint );
|
2020-08-13 07:22:48 +03:00
|
|
|
}
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
gPoint = updateGPoint;
|
|
|
|
} else {
|
|
|
|
gPoint.captured = false; // Handled by updatePointerCaptured()
|
|
|
|
gPoint.insideElementPressed = false;
|
|
|
|
}
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// Leave (doesn't bubble and not cancelable)
|
|
|
|
// Note: exitHandler is deprecated, replaced by leaveHandler
|
|
|
|
if ( tracker.leaveHandler || tracker.exitHandler ) {
|
|
|
|
dispatchEventObj = {
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
// GitHub PR: https://github.com/openseadragon/openseadragon/pull/1754 (gPoint.currentPos && )
|
|
|
|
position: gPoint.currentPos && getPointRelativeToAbsolute( gPoint.currentPos, tracker.element ),
|
|
|
|
buttons: pointsList.buttons,
|
|
|
|
pointers: tracker.getActivePointerCount(),
|
|
|
|
insideElementPressed: gPoint.insideElementPressed,
|
|
|
|
buttonDownAny: pointsList.buttons !== 0,
|
|
|
|
isTouchEvent: gPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
|
|
|
userData: tracker.userData
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( tracker.leaveHandler ) {
|
|
|
|
tracker.leaveHandler( dispatchEventObj );
|
|
|
|
}
|
|
|
|
// Deprecated
|
|
|
|
if ( tracker.exitHandler ) {
|
|
|
|
tracker.exitHandler( dispatchEventObj );
|
2020-07-25 06:05:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
|
2020-07-25 06:05:39 +03:00
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
2020-08-13 07:22:48 +03:00
|
|
|
* @param {OpenSeadragon.MouseTracker.EventProcessInfo} eventInfo
|
|
|
|
* Processing info for originating DOM event.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gPoint
|
|
|
|
* Gesture point associated with the event.
|
2020-07-25 06:05:39 +03:00
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function updatePointerOver( tracker, eventInfo, gPoint ) {
|
2020-07-25 06:05:39 +03:00
|
|
|
var pointsList,
|
2020-08-13 07:22:48 +03:00
|
|
|
updateGPoint;
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
pointsList = tracker.getActivePointersListByType( gPoint.type );
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updateGPoint = pointsList.getById( gPoint.id );
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( updateGPoint ) {
|
|
|
|
gPoint = updateGPoint;
|
|
|
|
} else {
|
|
|
|
gPoint.captured = false;
|
|
|
|
gPoint.insideElementPressed = false;
|
|
|
|
//gPoint.insideElement = true; // Tracked by updatePointerEnter
|
|
|
|
}
|
2014-04-15 05:17:18 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( tracker.overHandler ) {
|
|
|
|
// Over
|
|
|
|
tracker.overHandler(
|
|
|
|
{
|
2020-07-25 06:05:39 +03:00
|
|
|
eventSource: tracker,
|
2020-08-13 07:22:48 +03:00
|
|
|
pointerType: gPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( gPoint.currentPos, tracker.element ),
|
2020-07-25 06:05:39 +03:00
|
|
|
buttons: pointsList.buttons,
|
|
|
|
pointers: tracker.getActivePointerCount(),
|
2020-08-13 07:22:48 +03:00
|
|
|
insideElementPressed: gPoint.insideElementPressed,
|
2020-07-25 06:05:39 +03:00
|
|
|
buttonDownAny: pointsList.buttons !== 0,
|
2020-08-13 07:22:48 +03:00
|
|
|
isTouchEvent: gPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
2020-07-25 06:05:39 +03:00
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.EventProcessInfo} eventInfo
|
|
|
|
* Processing info for originating DOM event.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gPoint
|
|
|
|
* Gesture point associated with the event.
|
|
|
|
*/
|
|
|
|
function updatePointerOut( tracker, eventInfo, gPoint ) {
|
|
|
|
var pointsList,
|
|
|
|
updateGPoint;
|
|
|
|
|
|
|
|
pointsList = tracker.getActivePointersListByType(gPoint.type);
|
|
|
|
|
|
|
|
updateGPoint = pointsList.getById( gPoint.id );
|
|
|
|
|
|
|
|
if ( updateGPoint ) {
|
|
|
|
gPoint = updateGPoint;
|
|
|
|
} else {
|
|
|
|
gPoint.captured = false;
|
|
|
|
gPoint.insideElementPressed = false;
|
|
|
|
//gPoint.insideElement = true; // Tracked by updatePointerEnter
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( tracker.outHandler ) {
|
|
|
|
// Out
|
|
|
|
tracker.outHandler( {
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: gPoint.type,
|
|
|
|
position: gPoint.currentPos && getPointRelativeToAbsolute( gPoint.currentPos, tracker.element ),
|
|
|
|
buttons: pointsList.buttons,
|
|
|
|
pointers: tracker.getActivePointerCount(),
|
|
|
|
insideElementPressed: gPoint.insideElementPressed,
|
|
|
|
buttonDownAny: pointsList.buttons !== 0,
|
|
|
|
isTouchEvent: gPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
} );
|
2012-02-10 07:16:09 +04:00
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-02-10 07:16:09 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* @function
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
2020-08-13 07:22:48 +03:00
|
|
|
* @param {OpenSeadragon.MouseTracker.EventProcessInfo} eventInfo
|
|
|
|
* Processing info for originating DOM event.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gPoint
|
|
|
|
* Gesture point associated with the event.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {Number} buttonChanged
|
2015-01-11 01:49:02 +03:00
|
|
|
* The button involved in the event: -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
2015-06-08 17:38:16 +03:00
|
|
|
* Note on chorded button presses (a button pressed when another button is already pressed): In the W3C Pointer Events model,
|
2014-04-15 05:17:18 +04:00
|
|
|
* only one pointerdown/pointerup event combo is fired. Chorded button state changes instead fire pointermove events.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function updatePointerDown( tracker, eventInfo, gPoint, buttonChanged ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
var delegate = THIS[ tracker.hash ],
|
2020-08-13 07:22:48 +03:00
|
|
|
pointsList = tracker.getActivePointersListByType( gPoint.type ),
|
2014-04-15 05:17:18 +04:00
|
|
|
updateGPoint;
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( typeof eventInfo.originalEvent.buttons !== 'undefined' ) {
|
|
|
|
pointsList.buttons = eventInfo.originalEvent.buttons;
|
2014-04-15 05:17:18 +04:00
|
|
|
} else {
|
2015-01-11 01:49:02 +03:00
|
|
|
if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 9 ) {
|
|
|
|
if ( buttonChanged === 0 ) {
|
|
|
|
// Primary
|
|
|
|
pointsList.buttons += 1;
|
|
|
|
} else if ( buttonChanged === 1 ) {
|
|
|
|
// Aux
|
|
|
|
pointsList.buttons += 4;
|
|
|
|
} else if ( buttonChanged === 2 ) {
|
|
|
|
// Secondary
|
|
|
|
pointsList.buttons += 2;
|
|
|
|
} else if ( buttonChanged === 3 ) {
|
|
|
|
// X1 (Back)
|
|
|
|
pointsList.buttons += 8;
|
|
|
|
} else if ( buttonChanged === 4 ) {
|
|
|
|
// X2 (Forward)
|
|
|
|
pointsList.buttons += 16;
|
|
|
|
} else if ( buttonChanged === 5 ) {
|
|
|
|
// Pen Eraser
|
|
|
|
pointsList.buttons += 32;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ( buttonChanged === 0 ) {
|
|
|
|
// Primary
|
|
|
|
pointsList.buttons |= 1;
|
|
|
|
} else if ( buttonChanged === 1 ) {
|
|
|
|
// Aux
|
|
|
|
pointsList.buttons |= 4;
|
|
|
|
} else if ( buttonChanged === 2 ) {
|
|
|
|
// Secondary
|
|
|
|
pointsList.buttons |= 2;
|
|
|
|
} else if ( buttonChanged === 3 ) {
|
|
|
|
// X1 (Back)
|
|
|
|
pointsList.buttons |= 8;
|
|
|
|
} else if ( buttonChanged === 4 ) {
|
|
|
|
// X2 (Forward)
|
|
|
|
pointsList.buttons |= 16;
|
|
|
|
} else if ( buttonChanged === 5 ) {
|
|
|
|
// Pen Eraser
|
|
|
|
pointsList.buttons |= 32;
|
|
|
|
}
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
|
|
|
}
|
2014-03-30 04:02:24 +04:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
//TODO Revisit this if there's still an issue. The PointerEvent model should have no problems
|
|
|
|
// like the issue this code attempts to fix.
|
|
|
|
// // Some pointers may steal control from another pointer without firing the appropriate release events
|
|
|
|
// // e.g. Touching a screen while click-dragging with certain mice.
|
2020-08-13 07:22:48 +03:00
|
|
|
// var otherPointsLists = tracker.getActivePointersListsExceptType(gPoint.type);
|
2020-07-31 07:08:02 +03:00
|
|
|
// for (i = 0; i < otherPointsLists.length; i++) {
|
|
|
|
// //If another pointer has contact, simulate the release
|
|
|
|
// abortContacts(tracker, event, otherPointsLists[i]); // No-op if no active pointer
|
|
|
|
// }
|
2017-07-08 01:50:03 +03:00
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
// Only capture and track primary button, pen, and touch contacts
|
2015-01-11 01:49:02 +03:00
|
|
|
if ( buttonChanged !== 0 ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.shouldCapture = false;
|
|
|
|
eventInfo.shouldReleaseCapture = false;
|
|
|
|
|
2015-01-11 01:49:02 +03:00
|
|
|
// Aux Press
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( tracker.nonPrimaryPressHandler &&
|
|
|
|
!eventInfo.preventGesture &&
|
|
|
|
!eventInfo.defaultPrevented ) {
|
|
|
|
eventInfo.preventDefault = true;
|
|
|
|
|
|
|
|
tracker.nonPrimaryPressHandler(
|
2015-01-11 01:49:02 +03:00
|
|
|
{
|
|
|
|
eventSource: tracker,
|
2020-08-13 07:22:48 +03:00
|
|
|
pointerType: gPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( gPoint.currentPos, tracker.element ),
|
2015-01-11 01:49:02 +03:00
|
|
|
button: buttonChanged,
|
|
|
|
buttons: pointsList.buttons,
|
2020-08-13 07:22:48 +03:00
|
|
|
isTouchEvent: gPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
2015-01-11 01:49:02 +03:00
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
return;
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
2014-03-30 04:02:24 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updateGPoint = pointsList.getById( gPoint.id );
|
2014-04-15 05:17:18 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( updateGPoint ) {
|
|
|
|
// Already tracking the pointer...update it
|
|
|
|
//updateGPoint.captured = true; // Handled by updatePointerCaptured()
|
|
|
|
updateGPoint.insideElementPressed = true;
|
|
|
|
updateGPoint.insideElement = true;
|
|
|
|
updateGPoint.contactPos = gPoint.currentPos;
|
|
|
|
updateGPoint.contactTime = gPoint.currentTime;
|
|
|
|
updateGPoint.lastPos = updateGPoint.currentPos;
|
|
|
|
updateGPoint.lastTime = updateGPoint.currentTime;
|
|
|
|
updateGPoint.currentPos = gPoint.currentPos;
|
|
|
|
updateGPoint.currentTime = gPoint.currentTime;
|
|
|
|
|
|
|
|
gPoint = updateGPoint;
|
|
|
|
} else {
|
|
|
|
// Initialize for tracking and add to the tracking list (no pointerover or pointermove event occurred before this)
|
|
|
|
gPoint.captured = false; // Handled by updatePointerCaptured()
|
|
|
|
gPoint.insideElementPressed = true;
|
|
|
|
gPoint.insideElement = true;
|
|
|
|
startTrackingPointer( pointsList, gPoint );
|
|
|
|
}
|
2014-04-15 05:17:18 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
|
|
|
eventInfo.shouldCapture = true;
|
|
|
|
eventInfo.shouldReleaseCapture = false;
|
|
|
|
eventInfo.preventDefault = true;
|
2012-02-03 04:12:45 +04:00
|
|
|
|
2017-07-08 01:50:03 +03:00
|
|
|
pointsList.addContact();
|
2014-08-06 00:56:18 +04:00
|
|
|
//$.console.log('contacts++ ', pointsList.contacts);
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
if ( tracker.dragHandler || tracker.dragEndHandler || tracker.pinchHandler ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
$.MouseTracker.gesturePointVelocityTracker.addPoint( tracker, gPoint );
|
2014-03-31 23:54:37 +04:00
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
if ( pointsList.contacts === 1 ) {
|
|
|
|
// Press
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( tracker.pressHandler && !eventInfo.preventGesture ) {
|
|
|
|
tracker.pressHandler(
|
2014-03-10 22:49:51 +04:00
|
|
|
{
|
|
|
|
eventSource: tracker,
|
2020-08-13 07:22:48 +03:00
|
|
|
pointerType: gPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( gPoint.contactPos, tracker.element ),
|
2014-04-15 05:17:18 +04:00
|
|
|
buttons: pointsList.buttons,
|
2020-08-13 07:22:48 +03:00
|
|
|
isTouchEvent: gPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
2014-03-10 22:49:51 +04:00
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2014-04-15 05:17:18 +04:00
|
|
|
} else if ( pointsList.contacts === 2 ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( tracker.pinchHandler && gPoint.type === 'touch' ) {
|
2014-04-15 05:17:18 +04:00
|
|
|
// Initialize for pinch
|
|
|
|
delegate.pinchGPoints = pointsList.asArray();
|
|
|
|
delegate.lastPinchDist = delegate.currentPinchDist = delegate.pinchGPoints[ 0 ].currentPos.distanceTo( delegate.pinchGPoints[ 1 ].currentPos );
|
|
|
|
delegate.lastPinchCenter = delegate.currentPinchCenter = getCenterPoint( delegate.pinchGPoints[ 0 ].currentPos, delegate.pinchGPoints[ 1 ].currentPos );
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
} else {
|
|
|
|
eventInfo.shouldCapture = false;
|
|
|
|
eventInfo.shouldReleaseCapture = false;
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2012-02-01 06:01:37 +04:00
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* @function
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
2020-08-13 07:22:48 +03:00
|
|
|
* @param {OpenSeadragon.MouseTracker.EventProcessInfo} eventInfo
|
|
|
|
* Processing info for originating DOM event.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gPoint
|
2014-04-15 05:17:18 +04:00
|
|
|
* Gesture points associated with the event.
|
|
|
|
* @param {Number} buttonChanged
|
2015-01-11 01:49:02 +03:00
|
|
|
* The button involved in the event: -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
2015-06-08 17:38:16 +03:00
|
|
|
* Note on chorded button presses (a button pressed when another button is already pressed): In the W3C Pointer Events model,
|
2014-04-15 05:17:18 +04:00
|
|
|
* only one pointerdown/pointerup event combo is fired. Chorded button state changes instead fire pointermove events.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function updatePointerUp( tracker, eventInfo, gPoint, buttonChanged ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
var delegate = THIS[ tracker.hash ],
|
2020-08-13 07:22:48 +03:00
|
|
|
pointsList = tracker.getActivePointersListByType( gPoint.type ),
|
2014-03-10 22:49:51 +04:00
|
|
|
releasePoint,
|
2014-03-30 04:02:24 +04:00
|
|
|
releaseTime,
|
|
|
|
updateGPoint,
|
2014-04-22 20:23:56 +04:00
|
|
|
wasCaptured = false,
|
|
|
|
quick;
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( typeof eventInfo.originalEvent.buttons !== 'undefined' ) {
|
|
|
|
pointsList.buttons = eventInfo.originalEvent.buttons;
|
2014-04-15 05:17:18 +04:00
|
|
|
} else {
|
2015-01-11 01:49:02 +03:00
|
|
|
if ( $.Browser.vendor === $.BROWSERS.IE && $.Browser.version < 9 ) {
|
|
|
|
if ( buttonChanged === 0 ) {
|
|
|
|
// Primary
|
|
|
|
pointsList.buttons -= 1;
|
|
|
|
} else if ( buttonChanged === 1 ) {
|
|
|
|
// Aux
|
|
|
|
pointsList.buttons -= 4;
|
|
|
|
} else if ( buttonChanged === 2 ) {
|
|
|
|
// Secondary
|
|
|
|
pointsList.buttons -= 2;
|
|
|
|
} else if ( buttonChanged === 3 ) {
|
|
|
|
// X1 (Back)
|
|
|
|
pointsList.buttons -= 8;
|
|
|
|
} else if ( buttonChanged === 4 ) {
|
|
|
|
// X2 (Forward)
|
|
|
|
pointsList.buttons -= 16;
|
|
|
|
} else if ( buttonChanged === 5 ) {
|
|
|
|
// Pen Eraser
|
|
|
|
pointsList.buttons -= 32;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ( buttonChanged === 0 ) {
|
|
|
|
// Primary
|
|
|
|
pointsList.buttons ^= ~1;
|
|
|
|
} else if ( buttonChanged === 1 ) {
|
|
|
|
// Aux
|
|
|
|
pointsList.buttons ^= ~4;
|
|
|
|
} else if ( buttonChanged === 2 ) {
|
|
|
|
// Secondary
|
|
|
|
pointsList.buttons ^= ~2;
|
|
|
|
} else if ( buttonChanged === 3 ) {
|
|
|
|
// X1 (Back)
|
|
|
|
pointsList.buttons ^= ~8;
|
|
|
|
} else if ( buttonChanged === 4 ) {
|
|
|
|
// X2 (Forward)
|
|
|
|
pointsList.buttons ^= ~16;
|
|
|
|
} else if ( buttonChanged === 5 ) {
|
|
|
|
// Pen Eraser
|
|
|
|
pointsList.buttons ^= ~32;
|
|
|
|
}
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.shouldCapture = false;
|
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
// Only capture and track primary button, pen, and touch contacts
|
2015-01-11 01:49:02 +03:00
|
|
|
if ( buttonChanged !== 0 ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.shouldReleaseCapture = false;
|
|
|
|
|
2015-01-11 01:49:02 +03:00
|
|
|
// Aux Release
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( tracker.nonPrimaryReleaseHandler &&
|
|
|
|
!eventInfo.preventGesture &&
|
|
|
|
!eventInfo.defaultPrevented ) {
|
|
|
|
eventInfo.preventDefault = true;
|
|
|
|
|
|
|
|
tracker.nonPrimaryReleaseHandler(
|
2015-01-11 01:49:02 +03:00
|
|
|
{
|
|
|
|
eventSource: tracker,
|
2020-08-13 07:22:48 +03:00
|
|
|
pointerType: gPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute(gPoint.currentPos, tracker.element),
|
2015-01-11 01:49:02 +03:00
|
|
|
button: buttonChanged,
|
|
|
|
buttons: pointsList.buttons,
|
2020-08-13 07:22:48 +03:00
|
|
|
isTouchEvent: gPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
2015-01-11 01:49:02 +03:00
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
//TODO Revisit this if there's still an issue. The PointerEvent model should have no problems
|
|
|
|
// like the issue this code attempts to fix.
|
|
|
|
// // A primary mouse button may have been released while the non-primary button was down
|
|
|
|
// var otherPointsList = tracker.getActivePointersListByType("mouse");
|
|
|
|
// // Stop tracking the mouse; see https://github.com/openseadragon/openseadragon/pull/1223
|
|
|
|
// abortContacts(tracker, event, otherPointsList); // No-op if no active pointer
|
2017-07-08 01:50:03 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
return;
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
//TODO Revisit this if there's still an issue. The PointerEvent model should have no problems
|
|
|
|
// like the issue this code attempts to fix.
|
2020-08-13 07:22:48 +03:00
|
|
|
// GitHub PR: https://github.com/openseadragon/openseadragon/pull/1754
|
2020-07-31 07:08:02 +03:00
|
|
|
// // OS-specific gestures (e.g. swipe up with four fingers in iPadOS 13)
|
2020-08-13 07:22:48 +03:00
|
|
|
// if (typeof gPoint.currentPos === "undefined") {
|
|
|
|
// $.console.log('typeof gPoint.currentPos === "undefined" ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2020-07-31 07:08:02 +03:00
|
|
|
// abortContacts(tracker, event, pointsList);
|
2019-12-10 10:29:20 +03:00
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
// return false;
|
|
|
|
// }
|
2019-12-10 10:29:20 +03:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updateGPoint = pointsList.getById( gPoint.id );
|
2014-03-30 04:02:24 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( updateGPoint ) {
|
|
|
|
// Update the pointer, stop tracking it if not still in this element
|
|
|
|
if ( updateGPoint.captured ) {
|
|
|
|
//updateGPoint.captured = false; // Handled by updatePointerCaptured()
|
|
|
|
wasCaptured = true;
|
|
|
|
}
|
|
|
|
updateGPoint.lastPos = updateGPoint.currentPos;
|
|
|
|
updateGPoint.lastTime = updateGPoint.currentTime;
|
|
|
|
updateGPoint.currentPos = gPoint.currentPos;
|
|
|
|
updateGPoint.currentTime = gPoint.currentTime;
|
|
|
|
if ( !updateGPoint.insideElement ) {
|
2020-08-14 02:43:49 +03:00
|
|
|
stopTrackingPointer( tracker, pointsList, updateGPoint );
|
2020-08-13 07:22:48 +03:00
|
|
|
}
|
2014-03-30 04:02:24 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
releasePoint = updateGPoint.currentPos;
|
|
|
|
releaseTime = updateGPoint.currentTime;
|
|
|
|
} else {
|
|
|
|
// should never get here...we'll start to track pointer anyway
|
|
|
|
$.console.warn('updatePointerUp(): pointerup on untracked gPoint');
|
|
|
|
gPoint.captured = false; // Handled by updatePointerCaptured()
|
|
|
|
gPoint.insideElementPressed = false;
|
|
|
|
gPoint.insideElement = true;
|
|
|
|
startTrackingPointer( pointsList, gPoint );
|
|
|
|
|
|
|
|
updateGPoint = gPoint;
|
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
|
|
|
if ( wasCaptured ) {
|
|
|
|
// Pointer was activated in our element but could have been removed in any element since events are captured to our element
|
2014-03-30 04:02:24 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.shouldReleaseCapture = true;
|
|
|
|
eventInfo.preventDefault = true;
|
2014-03-30 04:02:24 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
pointsList.removeContact();
|
|
|
|
//$.console.log('contacts-- ', pointsList.contacts);
|
2014-03-30 04:02:24 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( tracker.dragHandler || tracker.dragEndHandler || tracker.pinchHandler ) {
|
|
|
|
$.MouseTracker.gesturePointVelocityTracker.removePoint( tracker, updateGPoint );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pointsList.contacts === 0 ) {
|
|
|
|
|
|
|
|
// Release (pressed in our element)
|
|
|
|
if ( tracker.releaseHandler ) {
|
|
|
|
tracker.releaseHandler(
|
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: updateGPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( releasePoint, tracker.element ),
|
|
|
|
buttons: pointsList.buttons,
|
|
|
|
insideElementPressed: updateGPoint.insideElementPressed,
|
|
|
|
insideElementReleased: updateGPoint.insideElement,
|
|
|
|
isTouchEvent: updateGPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
2014-03-30 04:02:24 +04:00
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
);
|
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// Drag End
|
|
|
|
if ( tracker.dragEndHandler ) {
|
|
|
|
tracker.dragEndHandler(
|
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: updateGPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( updateGPoint.currentPos, tracker.element ),
|
|
|
|
speed: updateGPoint.speed,
|
|
|
|
direction: updateGPoint.direction,
|
|
|
|
shift: eventInfo.originalEvent.shiftKey,
|
|
|
|
isTouchEvent: updateGPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Click / Double-Click
|
|
|
|
if ( ( tracker.clickHandler || tracker.dblClickHandler ) && updateGPoint.insideElement ) {
|
|
|
|
quick = releaseTime - updateGPoint.contactTime <= tracker.clickTimeThreshold &&
|
|
|
|
updateGPoint.contactPos.distanceTo( releasePoint ) <= tracker.clickDistThreshold;
|
|
|
|
|
|
|
|
// Click
|
|
|
|
if ( tracker.clickHandler ) {
|
|
|
|
tracker.clickHandler(
|
2014-03-30 04:02:24 +04:00
|
|
|
{
|
|
|
|
eventSource: tracker,
|
2014-04-15 05:17:18 +04:00
|
|
|
pointerType: updateGPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( updateGPoint.currentPos, tracker.element ),
|
2020-08-13 07:22:48 +03:00
|
|
|
quick: quick,
|
|
|
|
shift: eventInfo.originalEvent.shiftKey,
|
2014-04-15 05:17:18 +04:00
|
|
|
isTouchEvent: updateGPoint.type === 'touch',
|
2020-08-13 07:22:48 +03:00
|
|
|
originalEvent: eventInfo.originalEvent,
|
2014-03-30 04:02:24 +04:00
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// Double-Click
|
|
|
|
if ( tracker.dblClickHandler && quick ) {
|
|
|
|
pointsList.clicks++;
|
|
|
|
if ( pointsList.clicks === 1 ) {
|
|
|
|
delegate.lastClickPos = releasePoint;
|
|
|
|
/*jshint loopfunc:true*/
|
|
|
|
delegate.dblClickTimeOut = setTimeout( function() {
|
2014-04-22 20:23:56 +04:00
|
|
|
pointsList.clicks = 0;
|
2020-08-13 07:22:48 +03:00
|
|
|
}, tracker.dblClickTimeThreshold );
|
|
|
|
/*jshint loopfunc:false*/
|
|
|
|
} else if ( pointsList.clicks === 2 ) {
|
|
|
|
clearTimeout( delegate.dblClickTimeOut );
|
|
|
|
pointsList.clicks = 0;
|
|
|
|
if ( delegate.lastClickPos.distanceTo( releasePoint ) <= tracker.dblClickDistThreshold ) {
|
|
|
|
tracker.dblClickHandler(
|
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: updateGPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( updateGPoint.currentPos, tracker.element ),
|
|
|
|
shift: eventInfo.originalEvent.shiftKey,
|
|
|
|
isTouchEvent: updateGPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
2014-04-22 20:23:56 +04:00
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
);
|
2014-03-30 04:02:24 +04:00
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
delegate.lastClickPos = null;
|
2014-03-30 04:02:24 +04:00
|
|
|
}
|
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
} else if ( pointsList.contacts === 2 ) {
|
|
|
|
if ( tracker.pinchHandler && updateGPoint.type === 'touch' ) {
|
|
|
|
// Reset for pinch
|
|
|
|
delegate.pinchGPoints = pointsList.asArray();
|
|
|
|
delegate.lastPinchDist = delegate.currentPinchDist = delegate.pinchGPoints[ 0 ].currentPos.distanceTo( delegate.pinchGPoints[ 1 ].currentPos );
|
|
|
|
delegate.lastPinchCenter = delegate.currentPinchCenter = getCenterPoint( delegate.pinchGPoints[ 0 ].currentPos, delegate.pinchGPoints[ 1 ].currentPos );
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
} else {
|
|
|
|
// Pointer was activated in another element but removed in our element
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.shouldReleaseCapture = false;
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// Release (pressed in another element)
|
|
|
|
if ( tracker.releaseHandler ) {
|
|
|
|
tracker.releaseHandler(
|
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: updateGPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( releasePoint, tracker.element ),
|
|
|
|
buttons: pointsList.buttons,
|
|
|
|
insideElementPressed: updateGPoint.insideElementPressed,
|
|
|
|
insideElementReleased: updateGPoint.insideElement,
|
|
|
|
isTouchEvent: updateGPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
eventInfo.preventDefault = true;
|
2020-07-31 07:08:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-01 06:01:37 +04:00
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* Call when pointer(s) change coordinates, button state, pressure, tilt, or contact geometry (e.g. width and height)
|
|
|
|
*
|
|
|
|
* @function
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
2020-08-13 07:22:48 +03:00
|
|
|
* @param {OpenSeadragon.MouseTracker.EventProcessInfo} eventInfo
|
|
|
|
* Processing info for originating DOM event.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gPoint
|
2014-04-15 05:17:18 +04:00
|
|
|
* Gesture points associated with the event.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function updatePointerMove( tracker, eventInfo, gPoint ) {
|
2014-04-15 05:17:18 +04:00
|
|
|
var delegate = THIS[ tracker.hash ],
|
2020-08-13 07:22:48 +03:00
|
|
|
pointsList = tracker.getActivePointersListByType( gPoint.type ),
|
2014-04-15 05:17:18 +04:00
|
|
|
updateGPoint,
|
|
|
|
gPointArray,
|
2020-08-13 07:22:48 +03:00
|
|
|
delta;
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( typeof eventInfo.originalEvent.buttons !== 'undefined' ) {
|
|
|
|
pointsList.buttons = eventInfo.originalEvent.buttons;
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
updateGPoint = pointsList.getById( gPoint.id );
|
2014-04-15 05:17:18 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( updateGPoint ) {
|
|
|
|
// Already tracking the pointer...update it
|
|
|
|
updateGPoint.lastPos = updateGPoint.currentPos;
|
|
|
|
updateGPoint.lastTime = updateGPoint.currentTime;
|
|
|
|
updateGPoint.currentPos = gPoint.currentPos;
|
|
|
|
updateGPoint.currentTime = gPoint.currentTime;
|
|
|
|
} else {
|
|
|
|
// Initialize for tracking and add to the tracking list (no pointerover or pointerdown event occurred before this)
|
|
|
|
gPoint.captured = false; // Handled by updatePointerCaptured()
|
|
|
|
gPoint.insideElementPressed = false;
|
|
|
|
gPoint.insideElement = true;
|
|
|
|
startTrackingPointer( pointsList, gPoint );
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.shouldCapture = false;
|
|
|
|
eventInfo.shouldReleaseCapture = false;
|
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
// Stop (mouse only)
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( tracker.stopHandler && gPoint.type === 'mouse' ) {
|
2014-04-15 05:17:18 +04:00
|
|
|
clearTimeout( tracker.stopTimeOut );
|
|
|
|
tracker.stopTimeOut = setTimeout( function() {
|
2020-08-13 07:22:48 +03:00
|
|
|
handlePointerStop( tracker, eventInfo.originalEvent, gPoint.type );
|
2014-04-15 05:17:18 +04:00
|
|
|
}, tracker.stopDelay );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pointsList.contacts === 0 ) {
|
|
|
|
// Move (no contacts: hovering mouse or other hover-capable device)
|
|
|
|
if ( tracker.moveHandler ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
tracker.moveHandler(
|
2014-04-15 05:17:18 +04:00
|
|
|
{
|
|
|
|
eventSource: tracker,
|
2020-08-13 07:22:48 +03:00
|
|
|
pointerType: gPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( gPoint.currentPos, tracker.element ),
|
2014-04-15 05:17:18 +04:00
|
|
|
buttons: pointsList.buttons,
|
2020-08-13 07:22:48 +03:00
|
|
|
isTouchEvent: gPoint.type === 'touch',
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
2014-04-15 05:17:18 +04:00
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else if ( pointsList.contacts === 1 ) {
|
|
|
|
// Move (1 contact)
|
|
|
|
if ( tracker.moveHandler ) {
|
|
|
|
updateGPoint = pointsList.asArray()[ 0 ];
|
2020-08-13 07:22:48 +03:00
|
|
|
tracker.moveHandler(
|
2014-04-15 05:17:18 +04:00
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: updateGPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( updateGPoint.currentPos, tracker.element ),
|
|
|
|
buttons: pointsList.buttons,
|
|
|
|
isTouchEvent: updateGPoint.type === 'touch',
|
2020-08-13 07:22:48 +03:00
|
|
|
originalEvent: eventInfo.originalEvent,
|
2014-04-15 05:17:18 +04:00
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Drag
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( tracker.dragHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
2014-04-15 05:17:18 +04:00
|
|
|
updateGPoint = pointsList.asArray()[ 0 ];
|
|
|
|
delta = updateGPoint.currentPos.minus( updateGPoint.lastPos );
|
2020-08-13 07:22:48 +03:00
|
|
|
tracker.dragHandler(
|
2014-04-15 05:17:18 +04:00
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: updateGPoint.type,
|
|
|
|
position: getPointRelativeToAbsolute( updateGPoint.currentPos, tracker.element ),
|
|
|
|
buttons: pointsList.buttons,
|
|
|
|
delta: delta,
|
|
|
|
speed: updateGPoint.speed,
|
|
|
|
direction: updateGPoint.direction,
|
2020-08-13 07:22:48 +03:00
|
|
|
shift: eventInfo.originalEvent.shiftKey,
|
2014-04-15 05:17:18 +04:00
|
|
|
isTouchEvent: updateGPoint.type === 'touch',
|
2020-08-13 07:22:48 +03:00
|
|
|
originalEvent: eventInfo.originalEvent,
|
2014-04-15 05:17:18 +04:00
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.preventDefault = true;
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
|
|
|
} else if ( pointsList.contacts === 2 ) {
|
|
|
|
// Move (2 contacts, use center)
|
|
|
|
if ( tracker.moveHandler ) {
|
|
|
|
gPointArray = pointsList.asArray();
|
2020-08-13 07:22:48 +03:00
|
|
|
tracker.moveHandler(
|
2014-04-15 05:17:18 +04:00
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: gPointArray[ 0 ].type,
|
|
|
|
position: getPointRelativeToAbsolute( getCenterPoint( gPointArray[ 0 ].currentPos, gPointArray[ 1 ].currentPos ), tracker.element ),
|
|
|
|
buttons: pointsList.buttons,
|
|
|
|
isTouchEvent: gPointArray[ 0 ].type === 'touch',
|
2020-08-13 07:22:48 +03:00
|
|
|
originalEvent: eventInfo.originalEvent,
|
2014-04-15 05:17:18 +04:00
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pinch
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( tracker.pinchHandler && gPoint.type === 'touch' &&
|
|
|
|
!eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
2014-04-15 05:17:18 +04:00
|
|
|
delta = delegate.pinchGPoints[ 0 ].currentPos.distanceTo( delegate.pinchGPoints[ 1 ].currentPos );
|
2020-06-26 02:01:14 +03:00
|
|
|
if ( delta !== delegate.currentPinchDist ) {
|
2014-04-15 05:17:18 +04:00
|
|
|
delegate.lastPinchDist = delegate.currentPinchDist;
|
|
|
|
delegate.currentPinchDist = delta;
|
|
|
|
delegate.lastPinchCenter = delegate.currentPinchCenter;
|
|
|
|
delegate.currentPinchCenter = getCenterPoint( delegate.pinchGPoints[ 0 ].currentPos, delegate.pinchGPoints[ 1 ].currentPos );
|
2020-08-13 07:22:48 +03:00
|
|
|
tracker.pinchHandler(
|
2014-04-15 05:17:18 +04:00
|
|
|
{
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: 'touch',
|
|
|
|
gesturePoints: delegate.pinchGPoints,
|
|
|
|
lastCenter: getPointRelativeToAbsolute( delegate.lastPinchCenter, tracker.element ),
|
|
|
|
center: getPointRelativeToAbsolute( delegate.currentPinchCenter, tracker.element ),
|
|
|
|
lastDistance: delegate.lastPinchDist,
|
|
|
|
distance: delegate.currentPinchDist,
|
2020-08-13 07:22:48 +03:00
|
|
|
shift: eventInfo.originalEvent.shiftKey,
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
2014-04-15 05:17:18 +04:00
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.preventDefault = true;
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-03 19:50:25 +04:00
|
|
|
|
2014-03-10 22:49:51 +04:00
|
|
|
|
2012-02-01 06:01:37 +04:00
|
|
|
/**
|
2014-04-15 05:17:18 +04:00
|
|
|
* @function
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {OpenSeadragon.MouseTracker} tracker
|
|
|
|
* A reference to the MouseTracker instance.
|
2020-08-13 07:22:48 +03:00
|
|
|
* @param {OpenSeadragon.MouseTracker.EventProcessInfo} eventInfo
|
|
|
|
* Processing info for originating DOM event.
|
|
|
|
* @param {OpenSeadragon.MouseTracker.GesturePoint} gPoint
|
2014-04-15 05:17:18 +04:00
|
|
|
* Gesture points associated with the event.
|
2013-09-06 21:43:39 +04:00
|
|
|
*/
|
2020-08-13 07:22:48 +03:00
|
|
|
function updatePointerCancel( tracker, eventInfo, gPoint ) {
|
|
|
|
var pointsList = tracker.getActivePointersListByType( gPoint.type ),
|
|
|
|
updateGPoint;
|
|
|
|
|
|
|
|
updateGPoint = pointsList.getById( gPoint.id );
|
|
|
|
|
|
|
|
if ( updateGPoint ) {
|
2020-08-14 02:43:49 +03:00
|
|
|
stopTrackingPointer( tracker, pointsList, updateGPoint );
|
2020-08-13 07:22:48 +03:00
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-14 05:04:38 +04:00
|
|
|
|
2014-04-15 05:17:18 +04:00
|
|
|
|
2012-02-01 06:01:37 +04:00
|
|
|
/**
|
2013-09-06 21:43:39 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
2014-04-15 05:17:18 +04:00
|
|
|
function handlePointerStop( tracker, originalMoveEvent, pointerType ) {
|
|
|
|
if ( tracker.stopHandler ) {
|
|
|
|
tracker.stopHandler( {
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: pointerType,
|
|
|
|
position: getMouseRelative( originalMoveEvent, tracker.element ),
|
|
|
|
buttons: tracker.getActivePointersListByType( pointerType ).buttons,
|
|
|
|
isTouchEvent: pointerType === 'touch',
|
|
|
|
originalEvent: originalMoveEvent,
|
|
|
|
preventDefaultAction: false,
|
|
|
|
userData: tracker.userData
|
|
|
|
} );
|
2011-12-14 05:04:38 +04:00
|
|
|
}
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
2017-01-08 17:52:57 +03:00
|
|
|
|
|
|
|
}(OpenSeadragon));
|