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
|
2022-06-09 01:02:29 +03:00
|
|
|
* Copyright (C) 2010-2022 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.
|
2020-08-25 21:46:35 +03:00
|
|
|
* @param {OpenSeadragon.EventHandler} [options.contextMenuHandler=null]
|
|
|
|
* An optional handler for contextmenu.
|
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
|
2022-02-18 07:19:24 +03:00
|
|
|
* to be treated as a double-click gesture.
|
2022-02-12 21:04:40 +03:00
|
|
|
* @member {Number} dblClickDistThreshold
|
2014-04-22 20:23:56 +04:00
|
|
|
* @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;
|
2020-08-25 21:46:35 +03:00
|
|
|
this.contextMenuHandler = options.contextMenuHandler || 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 ); },
|
2020-08-25 21:46:35 +03:00
|
|
|
contextmenu: function ( event ) { onContextMenu( _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 ); },
|
2021-03-05 02:48:13 +03:00
|
|
|
|
|
|
|
mouseenter: function ( event ) { onPointerEnter( _this, event ); },
|
|
|
|
mouseleave: function ( event ) { onPointerLeave( _this, event ); },
|
|
|
|
mouseover: function ( event ) { onPointerOver( _this, event ); },
|
|
|
|
mouseout: function ( event ) { onPointerOut( _this, event ); },
|
|
|
|
mousedown: function ( event ) { onPointerDown( _this, event ); },
|
|
|
|
mouseup: function ( event ) { onPointerUp( _this, event ); },
|
|
|
|
mousemove: function ( event ) { onPointerMove( _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
|
|
|
|
|
2020-07-31 07:08:02 +03:00
|
|
|
gotpointercapture: function ( event ) { onGotPointerCapture( _this, event ); },
|
|
|
|
lostpointercapture: 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 ); },
|
|
|
|
pointerout: function ( event ) { onPointerOut( _this, event ); },
|
2014-03-10 22:49:51 +04:00
|
|
|
pointerdown: function ( event ) { onPointerDown( _this, event ); },
|
|
|
|
pointerup: function ( event ) { onPointerUp( _this, event ); },
|
|
|
|
pointermove: function ( event ) { onPointerMove( _this, event ); },
|
|
|
|
pointercancel: 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,
|
2021-11-19 00:45:50 +03:00
|
|
|
currentPinchCenter: null,
|
|
|
|
|
|
|
|
// Tracking for drag
|
|
|
|
sentDragEvent: false
|
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;
|
|
|
|
|
2021-05-03 21:38:20 +03:00
|
|
|
if ( $.MouseTracker.havePointerEvents ) {
|
|
|
|
$.setElementPointerEvents( this.element, 'auto' );
|
|
|
|
}
|
|
|
|
|
2021-02-10 19:32:00 +03:00
|
|
|
if (this.exitHandler) {
|
|
|
|
$.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead.");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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 () { },
|
|
|
|
|
2020-08-25 21:46:35 +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 {OpenSeadragon.Point} event.position
|
|
|
|
* The position of the event relative to the tracked element.
|
|
|
|
* @param {Object} event.originalEvent
|
|
|
|
* The original event object.
|
2021-03-11 00:45:15 +03:00
|
|
|
* @param {Boolean} event.preventDefault
|
|
|
|
* Set to true to prevent the default user-agent's handling of the contextmenu event.
|
2020-08-25 21:46:35 +03:00
|
|
|
* @param {Object} event.userData
|
|
|
|
* Arbitrary user-defined object.
|
|
|
|
*/
|
|
|
|
contextMenuHandler: 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-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 {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 {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-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 {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-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 {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-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.
|
2021-03-17 05:35:22 +03:00
|
|
|
* @param {Boolean} event.preventDefault
|
|
|
|
* Set to true to prevent the default user-agent's handling of the wheel event.
|
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.
|
2021-09-22 21:37:55 +03:00
|
|
|
* @param {Element} event.originalTarget
|
|
|
|
* The DOM element clicked on.
|
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 {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-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 {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 {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.
|
|
|
|
* @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.
|
2021-03-17 05:35:22 +03:00
|
|
|
* @param {Boolean} event.preventDefault
|
|
|
|
* Set to true to prevent the default user-agent's handling of the keydown event.
|
2015-01-17 03:26:30 +03:00
|
|
|
* @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.
|
2021-03-17 05:35:22 +03:00
|
|
|
* @param {Boolean} event.preventDefault
|
|
|
|
* Set to true to prevent the default user-agent's handling of the keyup event.
|
2015-01-17 03:26:30 +03:00
|
|
|
* @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.
|
2021-03-17 05:35:22 +03:00
|
|
|
* @param {Boolean} event.preventDefault
|
|
|
|
* Set to true to prevent the default user-agent's handling of the keypress event.
|
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-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-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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2020-08-25 21:46:35 +03:00
|
|
|
$.MouseTracker.subscribeEvents = [ "click", "dblclick", "keydown", "keyup", "keypress", "focus", "blur", "contextmenu", $.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" );
|
2020-07-26 04:30:06 +03:00
|
|
|
// 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" );
|
|
|
|
}
|
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;
|
2021-03-05 02:48:13 +03:00
|
|
|
$.MouseTracker.subscribeEvents.push( "mouseenter", "mouseleave", "mouseover", "mouseout", "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
|
2021-03-11 01:53:33 +03:00
|
|
|
* "keydown", "keyup", "keypress", "focus", "blur", "contextmenu", "gotpointercapture", "lostpointercapture", "pointerenter", "pointerleave", "pointerover", "pointerout", "pointerdown", "pointerup", "pointermove", "pointercancel", "wheel", "click", "dblclick".
|
2020-08-13 07:22:48 +03:00
|
|
|
* @property {String} pointerType
|
|
|
|
* "mouse", "touch", "pen", etc.
|
|
|
|
* @property {Boolean} isEmulated
|
2021-03-06 05:06:26 +03:00
|
|
|
* True if this is an emulated event. If true, originalEvent is either the event that caused
|
|
|
|
* the emulated event, a synthetic event object created with values from the actual DOM event,
|
|
|
|
* or null if no DOM event applies. Emulated events can occur on eventType "wheel" on legacy mouse-scroll
|
|
|
|
* event emitting user agents.
|
2021-09-22 21:41:17 +03:00
|
|
|
* @property {Boolean} isStoppable
|
2020-08-13 07:22:48 +03:00
|
|
|
* 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() {
|
2022-03-14 16:26:11 +03:00
|
|
|
--this.contacts;
|
|
|
|
|
|
|
|
if (this.contacts < 0) {
|
|
|
|
this.contacts = 0;
|
2017-07-08 01:50:03 +03:00
|
|
|
}
|
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();
|
|
|
|
}
|
2021-11-19 00:45:50 +03:00
|
|
|
|
|
|
|
delegate.sentDragEvent = false;
|
2014-12-30 23:57:17 +03:00
|
|
|
}
|
|
|
|
|
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 ],
|
2021-09-25 02:20:04 +03:00
|
|
|
event === $.MouseTracker.wheelEventName ? { passive: false, capture: false } : false
|
2012-02-03 04:12:45 +04:00
|
|
|
);
|
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 {
|
2021-03-05 02:48:13 +03:00
|
|
|
upName: 'pointerup',
|
2015-01-13 03:08:26 +03:00
|
|
|
upHandler: delegate.pointerupcaptured,
|
2021-03-05 02:48:13 +03:00
|
|
|
moveName: 'pointermove',
|
2015-01-13 03:08:26 +03:00
|
|
|
moveHandler: delegate.pointermovecaptured
|
|
|
|
};
|
|
|
|
} else if ( pointerType === 'mouse' ) {
|
2015-01-01 01:30:10 +03:00
|
|
|
return {
|
2021-03-05 02:48:13 +03:00
|
|
|
upName: 'pointerup',
|
|
|
|
upHandler: delegate.pointerupcaptured,
|
|
|
|
moveName: 'pointermove',
|
|
|
|
moveHandler: delegate.pointermovecaptured
|
2015-01-01 01:30:10 +03:00
|
|
|
};
|
|
|
|
} 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 ) {
|
2021-05-03 21:38:20 +03:00
|
|
|
// Can throw NotFoundError (InvalidPointerId Firefox < 82)
|
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 {
|
2021-03-05 02:48:13 +03:00
|
|
|
tracker.element.setPointerCapture( gPoint.id );
|
|
|
|
//$.console.log('element.setPointerCapture() called');
|
2020-08-25 18:51:00 +03:00
|
|
|
} catch ( e ) {
|
|
|
|
$.console.warn('setPointerCapture() called on invalid pointer ID');
|
2021-05-03 21:38:20 +03:00
|
|
|
return;
|
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;
|
|
|
|
}
|
2021-05-03 21:38:20 +03:00
|
|
|
// Can throw NotFoundError (InvalidPointerId Firefox < 82)
|
2020-08-25 21:46:35 +03:00
|
|
|
// (should never happen, but it does on Firefox 79 touch so we won't log a warning)
|
2020-08-25 18:51:00 +03:00
|
|
|
try {
|
2021-03-05 02:48:13 +03:00
|
|
|
tracker.element.releasePointerCapture( gPoint.id );
|
|
|
|
//$.console.log('element.releasePointerCapture() called');
|
2020-08-25 18:51:00 +03:00
|
|
|
} catch ( e ) {
|
2020-08-25 21:46:35 +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
|
|
|
|
2021-03-05 02:48:13 +03:00
|
|
|
/**
|
2021-03-06 05:39:31 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function getPointerId( event ) {
|
|
|
|
return ( $.MouseTracker.havePointerEvents ) ? event.pointerId : $.MouseTracker.mousePointerId;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
|
2021-03-06 05:39:31 +03:00
|
|
|
*
|
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2014-03-10 22:49:51 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function getPointerType( event ) {
|
2021-03-05 02:48:13 +03:00
|
|
|
if ( $.MouseTracker.havePointerEvents ) {
|
|
|
|
// 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
|
|
|
|
return event.pointerType || (( $.Browser.vendor === $.BROWSERS.IE ) ? 'mouse' : '');
|
2014-04-15 05:17:18 +04:00
|
|
|
} else {
|
2021-03-05 02:48:13 +03:00
|
|
|
return 'mouse';
|
2012-02-03 04:12:45 +04:00
|
|
|
}
|
2021-03-05 02:48:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-06 05:39:31 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function getIsPrimary( event ) {
|
|
|
|
return ( $.MouseTracker.havePointerEvents ) ? event.isPrimary : true;
|
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 ) {
|
2021-05-03 21:38:20 +03:00
|
|
|
//$.console.log('click ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2021-03-02 21:29:44 +03:00
|
|
|
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'click',
|
|
|
|
pointerType: 'mouse',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
2014-03-10 22:49:51 +04:00
|
|
|
$.cancelEvent( event );
|
2012-03-16 19:36:28 +04:00
|
|
|
}
|
2021-03-02 21:29:44 +03:00
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
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 ) {
|
2021-05-03 21:38:20 +03:00
|
|
|
//$.console.log('dblclick ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2021-03-02 21:29:44 +03:00
|
|
|
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'dblclick',
|
|
|
|
pointerType: 'mouse',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
2014-04-22 20:23:56 +04:00
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
2021-03-02 21:29:44 +03:00
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2014-04-22 20:23:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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 );
|
2021-03-17 05:35:22 +03:00
|
|
|
var eventArgs = null;
|
|
|
|
|
2021-03-11 01:53:33 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'keydown',
|
|
|
|
pointerType: '',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
if ( tracker.keyDownHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
2021-03-17 05:35:22 +03:00
|
|
|
eventArgs = {
|
|
|
|
eventSource: tracker,
|
|
|
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
|
|
|
ctrl: event.ctrlKey,
|
|
|
|
shift: event.shiftKey,
|
|
|
|
alt: event.altKey,
|
|
|
|
meta: event.metaKey,
|
|
|
|
originalEvent: event,
|
|
|
|
preventDefault: eventInfo.preventDefault || eventInfo.defaultPrevented,
|
|
|
|
userData: tracker.userData
|
|
|
|
};
|
|
|
|
|
|
|
|
tracker.keyDownHandler( eventArgs );
|
2021-03-11 01:53:33 +03:00
|
|
|
}
|
|
|
|
|
2021-03-17 05:35:22 +03:00
|
|
|
if ( ( eventArgs && eventArgs.preventDefault ) || ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) ) {
|
|
|
|
$.cancelEvent( event );
|
2021-03-11 01:53:33 +03:00
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
2015-01-17 03:26:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onKeyUp( tracker, event ) {
|
|
|
|
//$.console.log( "keyup %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
|
2021-03-11 01:53:33 +03:00
|
|
|
|
2021-03-17 05:35:22 +03:00
|
|
|
var eventArgs = null;
|
|
|
|
|
2021-03-11 01:53:33 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'keyup',
|
|
|
|
pointerType: '',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
if ( tracker.keyUpHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
2021-03-17 05:35:22 +03:00
|
|
|
eventArgs = {
|
|
|
|
eventSource: tracker,
|
|
|
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
|
|
|
ctrl: event.ctrlKey,
|
|
|
|
shift: event.shiftKey,
|
|
|
|
alt: event.altKey,
|
|
|
|
meta: event.metaKey,
|
|
|
|
originalEvent: event,
|
|
|
|
preventDefault: eventInfo.preventDefault || eventInfo.defaultPrevented,
|
|
|
|
userData: tracker.userData
|
|
|
|
};
|
|
|
|
|
|
|
|
tracker.keyUpHandler( eventArgs );
|
2021-03-11 01:53:33 +03:00
|
|
|
}
|
|
|
|
|
2021-03-17 05:35:22 +03:00
|
|
|
if ( ( eventArgs && eventArgs.preventDefault ) || ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) ) {
|
2021-03-11 01:53:33 +03:00
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
2015-01-17 03:26:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 );
|
2021-03-11 01:53:33 +03:00
|
|
|
|
2021-03-17 05:35:22 +03:00
|
|
|
var eventArgs = null;
|
|
|
|
|
2021-03-11 01:53:33 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'keypress',
|
|
|
|
pointerType: '',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
if ( tracker.keyHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
2021-03-17 05:35:22 +03:00
|
|
|
eventArgs = {
|
|
|
|
eventSource: tracker,
|
|
|
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
|
|
|
ctrl: event.ctrlKey,
|
|
|
|
shift: event.shiftKey,
|
|
|
|
alt: event.altKey,
|
|
|
|
meta: event.metaKey,
|
|
|
|
originalEvent: event,
|
|
|
|
preventDefault: eventInfo.preventDefault || eventInfo.defaultPrevented,
|
|
|
|
userData: tracker.userData
|
|
|
|
};
|
|
|
|
|
|
|
|
tracker.keyHandler( eventArgs );
|
2021-03-11 01:53:33 +03:00
|
|
|
}
|
|
|
|
|
2021-03-17 05:35:22 +03:00
|
|
|
if ( ( eventArgs && eventArgs.preventDefault ) || ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) ) {
|
2021-03-11 01:53:33 +03:00
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( 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 ) {
|
2021-05-03 21:38:20 +03:00
|
|
|
//$.console.log('focus ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2021-03-11 01:53:33 +03:00
|
|
|
|
|
|
|
// focus doesn't bubble and is not cancelable, but we call
|
|
|
|
// preProcessEvent() so it's dispatched to preProcessEventHandler
|
|
|
|
// if necessary
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'focus',
|
|
|
|
pointerType: '',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
if ( tracker.focusHandler && !eventInfo.preventGesture ) {
|
|
|
|
tracker.focusHandler(
|
2013-09-06 04:20:17 +04:00
|
|
|
{
|
2013-11-05 00:41:45 +04:00
|
|
|
eventSource: tracker,
|
|
|
|
originalEvent: event,
|
|
|
|
userData: tracker.userData
|
2013-09-06 04:20:17 +04:00
|
|
|
}
|
2012-04-11 01:02:24 +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 ) {
|
2021-05-03 21:38:20 +03:00
|
|
|
//$.console.log('blur ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2021-03-11 01:53:33 +03:00
|
|
|
|
|
|
|
// blur doesn't bubble and is not cancelable, but we call
|
|
|
|
// preProcessEvent() so it's dispatched to preProcessEventHandler
|
|
|
|
// if necessary
|
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'blur',
|
|
|
|
pointerType: '',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
if ( tracker.blurHandler && !eventInfo.preventGesture ) {
|
|
|
|
tracker.blurHandler(
|
2013-09-06 04:20:17 +04:00
|
|
|
{
|
2013-11-05 00:41:45 +04:00
|
|
|
eventSource: tracker,
|
|
|
|
originalEvent: event,
|
|
|
|
userData: tracker.userData
|
2013-09-06 04:20:17 +04:00
|
|
|
}
|
2012-04-11 01:02:24 +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
|
|
|
|
2020-08-25 21:46:35 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onContextMenu( tracker, event ) {
|
|
|
|
//$.console.log('contextmenu ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
|
|
|
|
2021-03-11 00:45:15 +03:00
|
|
|
var eventArgs = null;
|
|
|
|
|
2020-08-25 21:46:35 +03:00
|
|
|
var eventInfo = {
|
|
|
|
originalEvent: event,
|
|
|
|
eventType: 'contextmenu',
|
|
|
|
pointerType: 'mouse',
|
|
|
|
isEmulated: false
|
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
// ContextMenu
|
2021-03-02 21:29:44 +03:00
|
|
|
if ( tracker.contextMenuHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
2021-03-11 00:45:15 +03:00
|
|
|
eventArgs = {
|
|
|
|
eventSource: tracker,
|
|
|
|
position: getPointRelativeToAbsolute( getMouseAbsolute( event ), tracker.element ),
|
|
|
|
originalEvent: eventInfo.originalEvent,
|
|
|
|
preventDefault: eventInfo.preventDefault || eventInfo.defaultPrevented,
|
|
|
|
userData: tracker.userData
|
|
|
|
};
|
|
|
|
|
|
|
|
tracker.contextMenuHandler( eventArgs );
|
2020-08-25 21:46:35 +03:00
|
|
|
}
|
|
|
|
|
2021-03-11 00:45:15 +03:00
|
|
|
if ( ( eventArgs && eventArgs.preventDefault ) || ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) ) {
|
2020-08-25 21:46:35 +03:00
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 ) {
|
|
|
|
// 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
|
|
|
|
2021-03-17 05:35:22 +03:00
|
|
|
var eventArgs = null;
|
|
|
|
|
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 ) {
|
2021-03-17 05:35:22 +03:00
|
|
|
eventArgs = {
|
|
|
|
eventSource: tracker,
|
|
|
|
pointerType: 'mouse',
|
|
|
|
position: getMouseRelative( event, tracker.element ),
|
|
|
|
scroll: nDelta,
|
|
|
|
shift: event.shiftKey,
|
|
|
|
isTouchEvent: false,
|
|
|
|
originalEvent: originalEvent,
|
|
|
|
preventDefault: eventInfo.preventDefault || eventInfo.defaultPrevented,
|
|
|
|
userData: tracker.userData
|
|
|
|
};
|
2020-08-13 07:22:48 +03:00
|
|
|
|
2021-03-17 05:35:22 +03:00
|
|
|
|
|
|
|
tracker.scrollHandler( eventArgs );
|
2014-04-15 05:17:18 +04:00
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( originalEvent );
|
|
|
|
}
|
2021-03-17 05:35:22 +03:00
|
|
|
if ( ( eventArgs && eventArgs.preventDefault ) || ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) ) {
|
|
|
|
$.cancelEvent( originalEvent );
|
2020-08-13 07:22:48 +03:00
|
|
|
}
|
|
|
|
}
|
2014-04-15 05:17:18 +04:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2021-05-03 21:38:20 +03:00
|
|
|
if ( event.target === tracker.element ) {
|
|
|
|
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-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();
|
|
|
|
|
2021-05-03 23:43:47 +03:00
|
|
|
//$.console.log('touchstart ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
2020-07-31 07:08:02 +03:00
|
|
|
|
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
|
|
|
updatePointerDown( tracker, eventInfo, gPoint, 0 );
|
2021-05-03 21:38:20 +03:00
|
|
|
|
|
|
|
updatePointerCaptured( tracker, gPoint, true );
|
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();
|
|
|
|
|
2021-05-03 23:43:47 +03:00
|
|
|
//$.console.log('touchend ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
2020-08-13 07:22:48 +03:00
|
|
|
|
|
|
|
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 ) {
|
2021-05-03 23:43:47 +03:00
|
|
|
//$.console.log('gotpointercapture ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
2020-08-13 07:22:48 +03:00
|
|
|
|
|
|
|
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 ) {
|
2021-05-03 23:43:47 +03:00
|
|
|
//$.console.log('lostpointercapture ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
2020-08-13 07:22:48 +03:00
|
|
|
|
|
|
|
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
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +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-07-26 04:30:06 +03:00
|
|
|
//$.console.log('pointerenter ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2014-08-05 08:41:07 +04:00
|
|
|
|
2021-03-08 01:24:32 +03:00
|
|
|
var gPoint = {
|
2021-03-05 02:48:13 +03:00
|
|
|
id: getPointerId( event ),
|
2014-08-05 08:41:07 +04:00
|
|
|
type: getPointerType( event ),
|
2021-03-05 02:48:13 +03:00
|
|
|
isPrimary: getIsPrimary( event ),
|
2014-08-05 08:41:07 +04:00
|
|
|
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,
|
2021-03-05 02:48:13 +03:00
|
|
|
isEmulated: false
|
2020-08-13 07:22:48 +03:00
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerEnter( tracker, eventInfo, gPoint );
|
2020-07-26 04:30:06 +03:00
|
|
|
}
|
2020-07-25 06:05:39 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
*
|
2020-07-25 06:05:39 +03:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerLeave( tracker, event ) {
|
2020-07-26 04:30:06 +03:00
|
|
|
//$.console.log('pointerleave ' + (tracker.userData ? tracker.userData.toString() : ''));
|
2020-07-25 06:05:39 +03:00
|
|
|
|
2021-03-08 01:24:32 +03:00
|
|
|
var gPoint = {
|
2021-03-05 02:48:13 +03:00
|
|
|
id: getPointerId( event ),
|
2020-07-25 06:05:39 +03:00
|
|
|
type: getPointerType( event ),
|
2021-03-05 02:48:13 +03:00
|
|
|
isPrimary: getIsPrimary( event ),
|
2020-07-25 06:05:39 +03:00
|
|
|
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,
|
2021-03-05 02:48:13 +03:00
|
|
|
isEmulated: false
|
2020-08-13 07:22:48 +03:00
|
|
|
};
|
|
|
|
preProcessEvent( tracker, eventInfo );
|
|
|
|
|
|
|
|
updatePointerLeave( tracker, eventInfo, gPoint );
|
2020-07-25 06:05:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
*
|
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 = {
|
2021-03-05 02:48:13 +03:00
|
|
|
id: getPointerId( event ),
|
2020-07-25 06:05:39 +03:00
|
|
|
type: getPointerType( event ),
|
2021-03-05 02:48:13 +03:00
|
|
|
isPrimary: getIsPrimary( event ),
|
2020-07-25 06:05:39 +03:00
|
|
|
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 );
|
|
|
|
|
|
|
|
updatePointerOver( tracker, eventInfo, gPoint );
|
|
|
|
|
|
|
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
|
|
|
$.cancelEvent( event );
|
|
|
|
}
|
|
|
|
if ( eventInfo.stopPropagation ) {
|
|
|
|
$.stopEvent( event );
|
|
|
|
}
|
2014-08-05 08:41:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
*
|
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 = {
|
2021-03-05 02:48:13 +03:00
|
|
|
id: getPointerId( event ),
|
2014-08-05 08:41:07 +04:00
|
|
|
type: getPointerType( event ),
|
2021-03-05 02:48:13 +03:00
|
|
|
isPrimary: getIsPrimary( event ),
|
2014-08-05 08:41:07 +04:00
|
|
|
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 ( 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
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
*
|
2014-03-21 22:45:20 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function onPointerDown( tracker, event ) {
|
2021-03-08 01:24:32 +03:00
|
|
|
var gPoint = {
|
2021-03-05 02:48:13 +03:00
|
|
|
id: getPointerId( event ),
|
2014-03-21 22:45:20 +04:00
|
|
|
type: getPointerType( event ),
|
2021-03-05 02:48:13 +03:00
|
|
|
isPrimary: getIsPrimary( event ),
|
2014-03-31 23:54:37 +04:00
|
|
|
currentPos: getMouseAbsolute( event ),
|
|
|
|
currentTime: $.now()
|
2014-03-21 22:45:20 +04:00
|
|
|
};
|
|
|
|
|
2021-05-03 21:38:20 +03:00
|
|
|
// Most browsers implicitly capture touch pointer events
|
|
|
|
// Note no IE versions have element.hasPointerCapture() so no implicit
|
|
|
|
// pointer capture possible
|
|
|
|
// var implicitlyCaptured = ($.MouseTracker.havePointerEvents &&
|
|
|
|
// event.target.hasPointerCapture &&
|
|
|
|
// $.Browser.vendor !== $.BROWSERS.IE) ?
|
|
|
|
// event.target.hasPointerCapture(event.pointerId) : false;
|
|
|
|
var implicitlyCaptured = $.MouseTracker.havePointerEvents &&
|
|
|
|
gPoint.type === 'touch' &&
|
|
|
|
$.Browser.vendor !== $.BROWSERS.IE;
|
|
|
|
|
2021-05-03 23:43:47 +03:00
|
|
|
//$.console.log('pointerdown ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
2021-05-03 21:38:20 +03: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 );
|
|
|
|
}
|
2021-05-03 21:38:20 +03:00
|
|
|
if ( eventInfo.shouldCapture ) {
|
|
|
|
if ( implicitlyCaptured ) {
|
|
|
|
updatePointerCaptured( tracker, gPoint, true );
|
|
|
|
} else {
|
|
|
|
capturePointer( tracker, gPoint );
|
|
|
|
}
|
2021-05-03 23:43:47 +03:00
|
|
|
}
|
2014-03-21 22:45:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
*
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
*
|
2014-08-05 08:41:07 +04:00
|
|
|
* 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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
*
|
2014-08-05 08:41:07 +04:00
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
*/
|
|
|
|
function handlePointerUp( tracker, event ) {
|
2014-03-31 23:54:37 +04:00
|
|
|
var gPoint;
|
2014-03-21 22:45:20 +04:00
|
|
|
|
2021-05-03 23:43:47 +03:00
|
|
|
//$.console.log('pointerup ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
2020-07-31 07:08:02 +03:00
|
|
|
|
2014-03-21 22:45:20 +04:00
|
|
|
gPoint = {
|
2021-03-05 02:48:13 +03:00
|
|
|
id: getPointerId( event ),
|
2014-03-21 22:45:20 +04:00
|
|
|
type: getPointerType( event ),
|
2021-03-05 02:48:13 +03:00
|
|
|
isPrimary: getIsPrimary( event ),
|
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
|
2021-05-03 21:38:20 +03:00
|
|
|
if ( eventInfo.shouldReleaseCapture ) {
|
|
|
|
if ( event.target === tracker.element ) {
|
|
|
|
releasePointer( tracker, gPoint );
|
|
|
|
} else {
|
|
|
|
updatePointerCaptured( tracker, gPoint, false );
|
|
|
|
}
|
2020-08-13 07:22:48 +03:00
|
|
|
}
|
2014-03-21 22:45:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
*
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
*
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-06 05:50:40 +03:00
|
|
|
* Note: Called for both pointer events and legacy mouse events
|
|
|
|
* ($.MouseTracker.havePointerEvents determines which)
|
2021-03-05 02:48:13 +03:00
|
|
|
*
|
2014-08-05 08:41:07 +04:00
|
|
|
* @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)
|
|
|
|
|
2021-03-08 01:24:32 +03:00
|
|
|
var gPoint = {
|
2021-03-05 02:48:13 +03:00
|
|
|
id: getPointerId( event ),
|
2014-03-21 22:45:20 +04:00
|
|
|
type: getPointerType( event ),
|
2021-03-05 02:48:13 +03:00
|
|
|
isPrimary: getIsPrimary( event ),
|
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 ) {
|
2021-05-03 23:43:47 +03:00
|
|
|
//$.console.log('pointercancel ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
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 ) {
|
2021-05-03 21:38:20 +03:00
|
|
|
//$.console.log('startTrackingPointer *** ' + pointsList.type + ' ' + gPoint.id.toString());
|
2014-04-15 05:17:18 +04:00
|
|
|
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 ) {
|
2021-05-03 21:38:20 +03:00
|
|
|
//$.console.log('stopTrackingPointer *** ' + pointsList.type + ' ' + gPoint.id.toString());
|
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 ) {
|
2021-05-03 23:43:47 +03:00
|
|
|
$.console.warn('stopTrackingPointer() called on captured pointer');
|
2020-08-14 02:43:49 +03:00
|
|
|
releasePointer( tracker, trackedGPoint );
|
2021-05-03 23:43:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// If child element relinquishes capture to a parent we may get here
|
|
|
|
// from a pointerleave event while a pointerup event will never be received.
|
|
|
|
// In that case, we'll clean up the contact count
|
2022-02-22 16:24:10 +03:00
|
|
|
pointsList.removeContact();
|
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':
|
2021-09-22 21:41:17 +03:00
|
|
|
eventInfo.isStoppable = true;
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.isCancelable = true;
|
|
|
|
eventInfo.preventDefault = false;
|
|
|
|
eventInfo.preventGesture = !tracker.hasGestureHandlers;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'pointerover':
|
|
|
|
case 'pointerout':
|
2021-03-11 03:10:28 +03:00
|
|
|
case 'contextmenu':
|
2021-03-17 05:35:22 +03:00
|
|
|
case 'keydown':
|
|
|
|
case 'keyup':
|
|
|
|
case 'keypress':
|
2021-09-22 21:41:17 +03:00
|
|
|
eventInfo.isStoppable = true;
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.isCancelable = true;
|
2021-03-17 05:35:22 +03:00
|
|
|
eventInfo.preventDefault = false; // onContextMenu(), onKeyDown(), onKeyUp(), onKeyPress() may set true
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.preventGesture = false;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'pointerdown':
|
2021-09-22 21:41:17 +03:00
|
|
|
eventInfo.isStoppable = true;
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.isCancelable = true;
|
2021-03-11 00:45:15 +03:00
|
|
|
eventInfo.preventDefault = false; // updatePointerDown() may set true (tracker.hasGestureHandlers)
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.preventGesture = !tracker.hasGestureHandlers;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'pointerup':
|
2021-09-22 21:41:17 +03:00
|
|
|
eventInfo.isStoppable = true;
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.isCancelable = true;
|
|
|
|
eventInfo.preventDefault = false;
|
|
|
|
eventInfo.preventGesture = !tracker.hasGestureHandlers;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'wheel':
|
2021-09-22 21:41:17 +03:00
|
|
|
eventInfo.isStoppable = true;
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.isCancelable = true;
|
2021-03-17 05:35:22 +03:00
|
|
|
eventInfo.preventDefault = false; // handleWheelEvent() may set true
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.preventGesture = !tracker.hasScrollHandler;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'gotpointercapture':
|
|
|
|
case 'lostpointercapture':
|
|
|
|
case 'pointercancel':
|
2021-09-22 21:41:17 +03:00
|
|
|
eventInfo.isStoppable = true;
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.isCancelable = false;
|
|
|
|
eventInfo.preventDefault = false;
|
|
|
|
eventInfo.preventGesture = false;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
2021-03-02 21:29:44 +03:00
|
|
|
case 'click':
|
2021-09-22 21:41:17 +03:00
|
|
|
eventInfo.isStoppable = true;
|
2021-03-02 21:29:44 +03:00
|
|
|
eventInfo.isCancelable = true;
|
|
|
|
eventInfo.preventDefault = !!tracker.clickHandler;
|
|
|
|
eventInfo.preventGesture = false;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
|
|
|
case 'dblclick':
|
2021-09-22 21:41:17 +03:00
|
|
|
eventInfo.isStoppable = true;
|
2021-03-02 21:29:44 +03:00
|
|
|
eventInfo.isCancelable = true;
|
|
|
|
eventInfo.preventDefault = !!tracker.dblClickHandler;
|
|
|
|
eventInfo.preventGesture = false;
|
|
|
|
eventInfo.stopPropagation = false;
|
|
|
|
break;
|
2021-03-11 01:53:33 +03:00
|
|
|
case 'focus':
|
|
|
|
case 'blur':
|
2020-08-13 07:22:48 +03:00
|
|
|
case 'pointerenter':
|
|
|
|
case 'pointerleave':
|
|
|
|
default:
|
2021-09-22 21:41:17 +03:00
|
|
|
eventInfo.isStoppable = false;
|
2020-08-13 07:22:48 +03:00
|
|
|
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)
|
2021-02-10 19:32:00 +03:00
|
|
|
// Note: exitHandler is deprecated (v2.5.0), replaced by leaveHandler
|
2020-08-13 07:22:48 +03:00
|
|
|
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
|
|
|
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,
|
|
|
|
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 {
|
2021-03-05 02:48:13 +03:00
|
|
|
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
|
|
|
|
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
|
|
|
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;
|
2021-09-20 21:41:23 +03:00
|
|
|
updateGPoint.originalTarget = eventInfo.originalEvent.target;
|
2020-08-13 07:22:48 +03:00
|
|
|
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 {
|
2021-05-05 02:55:37 +03:00
|
|
|
// Initialize for tracking and add to the tracking list (no pointerenter event occurred before this)
|
2022-03-23 12:22:13 +03:00
|
|
|
// NOTE: pointerdown event on untracked pointer
|
2020-08-13 07:22:48 +03:00
|
|
|
gPoint.captured = false; // Handled by updatePointerCaptured()
|
|
|
|
gPoint.insideElementPressed = true;
|
|
|
|
gPoint.insideElement = true;
|
2021-09-20 21:41:23 +03:00
|
|
|
gPoint.originalTarget = eventInfo.originalEvent.target;
|
2020-08-13 07:22:48 +03:00
|
|
|
startTrackingPointer( pointsList, gPoint );
|
|
|
|
}
|
2014-04-15 05:17:18 +04:00
|
|
|
|
2021-05-03 21:38:20 +03:00
|
|
|
pointsList.addContact();
|
|
|
|
//$.console.log('contacts++ ', pointsList.contacts);
|
|
|
|
|
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
|
|
|
|
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
|
|
|
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 {
|
2021-03-05 02:48:13 +03:00
|
|
|
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
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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-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 ) {
|
2021-05-05 02:55:37 +03:00
|
|
|
pointsList.removeContact();
|
|
|
|
//$.console.log('contacts-- ', pointsList.contacts);
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// 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 {
|
2022-03-23 12:22:13 +03:00
|
|
|
// NOTE: updatePointerUp(): pointerup on untracked gPoint
|
|
|
|
// ...we'll start to track pointer again
|
2020-08-13 07:22:48 +03:00
|
|
|
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
|
|
|
if ( tracker.dragHandler || tracker.dragEndHandler || tracker.pinchHandler ) {
|
|
|
|
$.MouseTracker.gesturePointVelocityTracker.removePoint( tracker, updateGPoint );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pointsList.contacts === 0 ) {
|
|
|
|
|
|
|
|
// Release (pressed in our element)
|
2022-03-23 12:22:13 +03:00
|
|
|
if ( tracker.releaseHandler && releasePoint ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
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,
|
|
|
|
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
|
2021-11-19 00:45:50 +03:00
|
|
|
if ( tracker.dragEndHandler && delegate.sentDragEvent ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
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,
|
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-19 00:45:50 +03:00
|
|
|
// We want to clear this flag regardless of whether we fired the dragEndHandler
|
|
|
|
delegate.sentDragEvent = false;
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
// 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,
|
2021-09-20 21:41:23 +03:00
|
|
|
originalTarget: updateGPoint.originalTarget,
|
2014-03-30 04:02:24 +04:00
|
|
|
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,
|
|
|
|
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)
|
2022-04-16 17:53:30 +03:00
|
|
|
if ( tracker.releaseHandler && releasePoint ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
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,
|
|
|
|
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 {
|
2021-05-03 21:38:20 +03:00
|
|
|
// Should never get here, but due to user agent bugs (e.g. legacy touch) it sometimes happens
|
|
|
|
return;
|
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
|
|
|
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
|
|
|
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
|
|
|
userData: tracker.userData
|
|
|
|
}
|
|
|
|
);
|
2020-08-13 07:22:48 +03:00
|
|
|
eventInfo.preventDefault = true;
|
2021-11-19 00:45:50 +03:00
|
|
|
delegate.sentDragEvent = 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
|
|
|
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
|
|
|
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,
|
|
|
|
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));
|