2013-05-01 08:46:16 +04:00
/ *
2013-05-14 08:00:24 +04:00
* OpenSeadragon - MouseTracker
2013-05-01 08:46:16 +04:00
*
* Copyright ( C ) 2009 CodePlex Foundation
2013-05-14 07:32:09 +04:00
* Copyright ( C ) 2010 - 2013 OpenSeadragon contributors
2013-05-01 08:46:16 +04:00
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions are
* met :
*
* - Redistributions of source code must retain the above copyright notice ,
* this list of conditions and the following disclaimer .
*
* - Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
*
* - Neither the name of CodePlex Foundation nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT
* LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL ,
* SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED
* TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR
* PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING
* NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* /
2013-09-06 04:20:17 +04:00
( function ( $ ) {
2013-09-06 21:43:39 +04:00
// is any button currently being pressed while mouse events occur
2013-09-06 04:20:17 +04:00
var IS _BUTTON _DOWN = false ,
2013-09-06 21:43:39 +04:00
// is any tracker currently capturing?
IS _CAPTURING = false ,
// dictionary from hash to MouseTracker
ACTIVE = { } ,
// list of trackers interested in capture
CAPTURING = [ ] ,
// dictionary from hash to private properties
THIS = { } ;
2011-12-06 07:50:25 +04:00
2012-01-25 23:14:02 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* The MouseTracker allows other classes to set handlers for common mouse
* events on a specific element like , 'enter' , 'exit' , 'press' , 'release' ,
* 'scroll' , 'click' , and 'drag' .
* @ class
* @ param { Object } options
* Allows configurable properties to be entirely specified by passing
* an options object to the constructor . The constructor also supports
* the original positional arguments 'elements' , 'clickTimeThreshold' ,
* and 'clickDistThreshold' in that order .
* @ param { Element | String } options . element
* A reference to an element or an element id for which the mouse
* events will be monitored .
* @ param { Number } options . clickTimeThreshold
* The number of milliseconds within which mutliple mouse clicks
* will be treated as a single event .
* @ param { Number } options . clickDistThreshold
* The distance between mouse click within multiple mouse clicks
* will be treated as a single event .
* @ param { Function } options . enterHandler
* An optional handler for mouse enter .
* @ param { Function } options . exitHandler
* An optional handler for mouse exit .
* @ param { Function } options . pressHandler
* An optional handler for mouse press .
* @ param { Function } options . releaseHandler
* An optional handler for mouse release .
* @ param { Function } options . moveHandler
* An optional handler for mouse move .
* @ param { Function } options . scrollHandler
* An optional handler for mouse scroll .
* @ param { Function } options . clickHandler
* An optional handler for mouse click .
* @ param { Function } options . dragHandler
* An optional handler for mouse drag .
* @ param { Function } options . keyHandler
* An optional handler for keypress .
* @ param { Function } options . focusHandler
* An optional handler for focus .
* @ param { Function } options . blurHandler
* 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
* @ property { Number } hash
* An unique hash for this tracker .
* @ property { Element } element
* The element for which mouse event are being monitored .
* @ property { Number } clickTimeThreshold
* The number of milliseconds within which mutliple mouse clicks
* will be treated as a single event .
* @ property { Number } clickDistThreshold
* The distance between mouse click within multiple mouse clicks
* will be treated as a single event .
* /
2012-02-03 04:12:45 +04:00
$ . MouseTracker = function ( options ) {
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-06-19 21:33:25 +04:00
this . hash = Math . random ( ) ;
2012-02-03 04:12:45 +04:00
this . element = $ . getElement ( options . element ) ;
this . clickTimeThreshold = options . clickTimeThreshold ;
this . clickDistThreshold = options . clickDistThreshold ;
2013-09-06 21:43:39 +04:00
this . userData = options . userData || null ;
2012-02-03 04:12:45 +04:00
2013-09-06 21:43:39 +04:00
this . enterHandler = options . enterHandler || null ;
this . exitHandler = options . exitHandler || null ;
this . pressHandler = options . pressHandler || null ;
2012-02-03 04:12:45 +04:00
this . releaseHandler = options . releaseHandler || null ;
2013-09-06 21:43:39 +04:00
this . moveHandler = options . moveHandler || null ;
this . scrollHandler = options . scrollHandler || null ;
this . clickHandler = options . clickHandler || null ;
this . dragHandler = options . dragHandler || null ;
this . keyHandler = options . keyHandler || null ;
this . focusHandler = options . focusHandler || null ;
this . blurHandler = options . blurHandler || null ;
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
* Are we currently tracking mouse events .
* @ property { Boolean } capturing
* Are we curruently capturing mouse events .
2013-09-10 01:27:58 +04:00
* @ property { Boolean } insideElementPressed
2013-09-06 21:43:39 +04:00
* True if the left mouse button is currently being pressed and was
* initiated inside the tracked element , otherwise false .
* @ property { Boolean } insideElement
* Are we currently inside the screen area of the tracked element .
* @ property { OpenSeadragon . Point } lastPoint
* Position of last mouse down / move
* @ property { Number } lastMouseDownTime
* Time of last mouse down .
* @ property { OpenSeadragon . Point } lastMouseDownPoint
* Position of last mouse down
* /
2013-09-20 20:58:18 +04:00
THIS [ this . hash ] = {
2013-09-10 01:27:58 +04:00
mouseover : function ( event ) { onMouseOver ( _this , event , false ) ; } ,
mouseout : function ( event ) { onMouseOut ( _this , event , false ) ; } ,
mousedown : function ( event ) { onMouseDown ( _this , event ) ; } ,
mouseup : function ( event ) { onMouseUp ( _this , event , false ) ; } ,
mousemove : function ( event ) { onMouseMove ( _this , event ) ; } ,
click : function ( event ) { onMouseClick ( _this , event ) ; } ,
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-09-10 01:27:58 +04:00
mouseupie : function ( event ) { onMouseUpIE ( _this , event ) ; } ,
mousemovecapturedie : function ( event ) { onMouseMoveCapturedIE ( _this , event ) ; } ,
mouseupcaptured : function ( event ) { onMouseUpCaptured ( _this , event ) ; } ,
mousemovecaptured : function ( event ) { onMouseMoveCaptured ( _this , event , false ) ; } ,
touchstart : function ( event ) { onTouchStart ( _this , event ) ; } ,
touchmove : function ( event ) { onTouchMove ( _this , event ) ; } ,
touchend : function ( event ) { onTouchEnd ( _this , event ) ; } ,
keypress : function ( event ) { onKeyPress ( _this , event ) ; } ,
focus : function ( event ) { onFocus ( _this , event ) ; } ,
blur : function ( event ) { onBlur ( _this , event ) ; } ,
tracking : false ,
capturing : false ,
insideElementPressed : false ,
insideElement : false ,
lastPoint : null ,
lastMouseDownTime : null ,
lastMouseDownPoint : null ,
lastPinchDelta : 0
2012-02-02 01:56:04 +04:00
} ;
} ;
2011-12-06 07:50:25 +04:00
2012-02-02 01:56:04 +04:00
$ . MouseTracker . prototype = {
2011-12-06 07:50:25 +04:00
2013-08-08 11:49:24 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* Clean up any events or objects created by the mouse tracker .
* @ function
* /
2013-09-06 04:20:17 +04:00
destroy : function ( ) {
2013-08-08 11:49:24 +04:00
stopTracking ( this ) ;
this . element = null ;
} ,
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
2012-02-02 01:56:04 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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 { 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 { 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
2013-09-12 21:05:50 +04:00
* Was the button down anywhere in the screen during the event .
2013-10-11 04:00:15 +04:00
* @ param { Boolean } event . isTouchEvent
2013-09-12 21:05:50 +04:00
* True if the original event is a touch event , otherwise false .
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-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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 { 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 { 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
2013-09-12 21:05:50 +04:00
* Was the button down anywhere in the screen during the event .
2013-10-11 04:00:15 +04:00
* @ param { Boolean } event . isTouchEvent
2013-09-12 21:05:50 +04:00
* True if the original event is a touch event , otherwise false .
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
2012-02-02 01:56:04 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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 { 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 { Boolean } event . isTouchEvent
2013-09-12 21:05:50 +04:00
* True if the original event is a touch event , otherwise false .
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
/ * *
2013-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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 { 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 { 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
2013-09-12 21:05:50 +04:00
* True if the cursor still inside the tracked element when the button was released .
2013-10-11 04:00:15 +04:00
* @ param { Boolean } event . isTouchEvent
2013-09-12 21:05:50 +04:00
* True if the original event is a touch event , otherwise false .
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
2012-02-02 01:56:04 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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 { 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 { Boolean } event . isTouchEvent
2013-09-12 21:05:50 +04:00
* True if the original event is a touch event , otherwise false .
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-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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 { 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
2013-09-12 21:05:50 +04:00
* True if the original event is a touch event , otherwise false .
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
scrollHandler : function ( ) { } ,
2011-12-06 07:50:25 +04:00
2012-02-02 01:56:04 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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 { 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 . quick
2013-09-12 21:05:50 +04:00
* True only if the clickDistThreshold and clickDeltaThreshold are both pased . Useful for ignoring 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
2013-09-12 21:05:50 +04:00
* True if the original event is a touch event , otherwise false .
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
clickHandler : function ( ) { } ,
2011-12-06 07:50:25 +04:00
2012-02-02 01:56:04 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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 { 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 { OpenSeadragon . Point } event . delta
2013-09-12 21:05:50 +04:00
* The x , y components of the difference between start drag and end drag . Usefule for ignoring or weighting the 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
2013-09-12 21:05:50 +04:00
* True if the original event is a touch event , otherwise false .
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
2012-03-16 19:36:28 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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 .
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 { 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
keyHandler : function ( ) { } ,
/ * *
2013-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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-09-06 21:43:39 +04:00
* Implement or assign implmentation to these handlers during or after
* 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
2013-10-23 23:58:36 +04:00
/ * *
* Detect available mouse wheel event .
* /
$ . MouseTracker . wheelEventName = ( ( $ . Browser . vendor == $ . BROWSERS . IE && $ . Browser . version > 8 ) || ( "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
2012-02-03 04:12:45 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* Starts tracking mouse events on this element .
* @ private
* @ inner
* /
2012-02-03 04:12:45 +04:00
function startTracking ( tracker ) {
var events = [
2013-09-06 04:20:17 +04:00
"mouseover" , "mouseout" , "mousedown" , "mouseup" , "mousemove" ,
2012-02-10 07:16:09 +04:00
"click" ,
2013-10-23 23:58:36 +04:00
$ . MouseTracker . wheelEventName ,
2012-03-16 19:36:28 +04:00
"touchstart" , "touchmove" , "touchend" ,
"keypress" ,
"focus" , "blur"
2013-06-19 21:33:25 +04:00
] ,
2013-09-20 20:58:18 +04:00
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 ) {
2013-09-06 04:20:17 +04:00
for ( i = 0 ; i < events . length ; i ++ ) {
2013-09-20 20:58:18 +04:00
event = events [ i ] ;
2013-06-19 21:33:25 +04:00
$ . addEvent (
tracker . element ,
event ,
2013-09-20 20:58:18 +04:00
delegate [ event ] ,
2012-02-03 04:12:45 +04:00
false
) ;
2011-12-06 07:50:25 +04:00
}
2012-02-03 04:12:45 +04:00
delegate . tracking = true ;
2013-09-20 20:58:18 +04:00
ACTIVE [ tracker . hash ] = tracker ;
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-03 04:12:45 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* Stops tracking mouse events on this element .
* @ private
* @ inner
* /
2012-02-03 04:12:45 +04:00
function stopTracking ( tracker ) {
var events = [
2013-09-06 04:20:17 +04:00
"mouseover" , "mouseout" , "mousedown" , "mouseup" , "mousemove" ,
2012-02-10 07:16:09 +04:00
"click" ,
2013-10-23 23:58:36 +04:00
$ . MouseTracker . wheelEventName ,
2012-03-16 19:36:28 +04:00
"touchstart" , "touchmove" , "touchend" ,
"keypress" ,
"focus" , "blur"
2012-02-03 04:12:45 +04:00
] ,
2013-09-20 20:58:18 +04:00
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 ) {
2013-09-06 04:20:17 +04:00
for ( i = 0 ; i < events . length ; i ++ ) {
2013-09-20 20:58:18 +04:00
event = events [ 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
}
2012-02-03 04:12:45 +04:00
releaseMouse ( tracker ) ;
delegate . tracking = false ;
2013-09-20 20:58:18 +04:00
delete ACTIVE [ tracker . hash ] ;
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-03 04:12:45 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2012-02-03 04:12:45 +04:00
function hasMouse ( tracker ) {
2013-09-20 20:58:18 +04:00
return THIS [ tracker . hash ] . insideElement ;
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
* Begin capturing mouse events on this element .
* @ private
* @ inner
* /
2012-02-03 04:12:45 +04:00
function captureMouse ( tracker ) {
2013-09-20 20:58:18 +04:00
var delegate = THIS [ tracker . hash ] ;
2012-02-03 04:12:45 +04:00
if ( ! delegate . capturing ) {
2012-04-11 01:02:24 +04:00
if ( $ . Browser . vendor == $ . BROWSERS . IE && $ . Browser . version < 9 ) {
2013-06-19 21:33:25 +04:00
$ . removeEvent (
tracker . element ,
"mouseup" ,
delegate . mouseup ,
false
2012-02-03 04:12:45 +04:00
) ;
2013-06-19 21:33:25 +04:00
$ . addEvent (
tracker . element ,
"mouseup" ,
delegate . mouseupie ,
true
2012-02-03 04:12:45 +04:00
) ;
2013-06-19 21:33:25 +04:00
$ . addEvent (
tracker . element ,
"mousemove" ,
2013-09-10 01:27:58 +04:00
delegate . mousemovecapturedie ,
2013-06-19 21:33:25 +04:00
true
2012-02-03 04:12:45 +04:00
) ;
} else {
2013-06-19 21:33:25 +04:00
$ . addEvent (
window ,
"mouseup" ,
2013-09-10 01:27:58 +04:00
delegate . mouseupcaptured ,
2013-06-19 21:33:25 +04:00
true
2012-02-03 04:12:45 +04:00
) ;
2013-06-19 21:33:25 +04:00
$ . addEvent (
window ,
"mousemove" ,
2013-09-10 01:27:58 +04:00
delegate . mousemovecaptured ,
2013-06-19 21:33:25 +04:00
true
2012-02-03 04:12:45 +04:00
) ;
}
delegate . capturing = true ;
}
2013-01-29 21:32:58 +04:00
}
2012-02-02 01:56:04 +04:00
2013-06-19 21:33:25 +04:00
2012-02-03 04:12:45 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* Stop capturing mouse events on this element .
* @ private
* @ inner
* /
2012-02-03 04:12:45 +04:00
function releaseMouse ( tracker ) {
2013-09-20 20:58:18 +04:00
var delegate = THIS [ tracker . hash ] ;
2012-02-03 04:12:45 +04:00
if ( delegate . capturing ) {
2012-04-11 01:02:24 +04:00
if ( $ . Browser . vendor == $ . BROWSERS . IE && $ . Browser . version < 9 ) {
2013-06-19 21:33:25 +04:00
$ . removeEvent (
tracker . element ,
"mousemove" ,
2013-09-10 01:27:58 +04:00
delegate . mousemovecapturedie ,
2013-06-19 21:33:25 +04:00
true
2012-02-03 04:12:45 +04:00
) ;
2013-06-19 21:33:25 +04:00
$ . removeEvent (
tracker . element ,
"mouseup" ,
delegate . mouseupie ,
true
2012-02-03 04:12:45 +04:00
) ;
2013-06-19 21:33:25 +04:00
$ . addEvent (
tracker . element ,
"mouseup" ,
delegate . mouseup ,
false
2012-02-03 04:12:45 +04:00
) ;
} else {
2013-06-19 21:33:25 +04:00
$ . removeEvent (
window ,
"mousemove" ,
2013-09-10 01:27:58 +04:00
delegate . mousemovecaptured ,
2013-06-19 21:33:25 +04:00
true
2012-02-03 04:12:45 +04:00
) ;
2013-06-19 21:33:25 +04:00
$ . removeEvent (
window ,
"mouseup" ,
2013-09-10 01:27:58 +04:00
delegate . mouseupcaptured ,
2013-06-19 21:33:25 +04:00
true
2012-02-03 04:12:45 +04:00
) ;
2011-12-06 07:50:25 +04:00
}
2012-02-03 04:12:45 +04:00
delegate . capturing = 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
2012-02-03 04:12:45 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2013-09-06 04:20:17 +04:00
function triggerOthers ( tracker , handler , event , isTouch ) {
2012-02-03 04:12:45 +04:00
var otherHash ;
for ( otherHash in ACTIVE ) {
2012-04-03 11:08:27 +04:00
if ( ACTIVE . hasOwnProperty ( otherHash ) && tracker . hash != otherHash ) {
2013-09-20 20:58:18 +04:00
handler ( ACTIVE [ otherHash ] , event , isTouch ) ;
2011-12-06 07:50:25 +04:00
}
2012-02-03 04:12:45 +04:00
}
2013-01-29 21:32:58 +04:00
}
2011-12-06 07:50:25 +04:00
2012-02-10 07:16:09 +04:00
2012-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 onFocus ( tracker , event ) {
2012-03-20 03:03:58 +04:00
//console.log( "focus %s", event );
2012-04-03 11:08:27 +04:00
var propagate ;
2012-03-16 19:36:28 +04:00
if ( tracker . focusHandler ) {
2013-06-19 21:33:25 +04:00
propagate = tracker . focusHandler (
2013-09-06 04:20:17 +04:00
{
2013-10-11 04:00:15 +04:00
eventSource : tracker ,
2013-09-06 04:20:17 +04:00
originalEvent : event ,
userData : tracker . userData
}
2012-04-11 01:02:24 +04:00
) ;
2013-09-06 04:20:17 +04:00
if ( propagate === false ) {
2012-04-11 01:02:24 +04:00
$ . cancelEvent ( event ) ;
2012-03-16 19:36:28 +04:00
}
}
2013-01-29 21:32:58 +04:00
}
2012-03-16 19:36:28 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2013-09-06 04:20:17 +04:00
function onBlur ( tracker , event ) {
2012-03-20 03:03:58 +04:00
//console.log( "blur %s", event );
2012-04-03 11:08:27 +04:00
var propagate ;
2012-03-16 19:36:28 +04:00
if ( tracker . blurHandler ) {
2013-06-19 21:33:25 +04:00
propagate = tracker . blurHandler (
2013-09-06 04:20:17 +04:00
{
2013-10-11 04:00:15 +04:00
eventSource : tracker ,
2013-09-06 04:20:17 +04:00
originalEvent : event ,
userData : tracker . userData
}
2012-04-11 01:02:24 +04:00
) ;
2013-09-06 04:20:17 +04:00
if ( propagate === false ) {
2012-04-11 01:02:24 +04:00
$ . cancelEvent ( event ) ;
2012-03-16 19:36:28 +04:00
}
}
2013-01-29 21:32:58 +04:00
}
2012-03-16 19:36:28 +04:00
2013-06-19 21:33:25 +04:00
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 ) {
2012-03-21 05:58:23 +04:00
//console.log( "keypress %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
2012-03-20 23:30:29 +04:00
var propagate ;
2012-03-16 19:36:28 +04:00
if ( tracker . keyHandler ) {
2013-06-19 21:33:25 +04:00
propagate = tracker . keyHandler (
2013-09-06 04:20:17 +04:00
{
2013-10-11 04:00:15 +04:00
eventSource : tracker ,
2013-09-06 04:20:17 +04:00
position : getMouseRelative ( event , tracker . element ) ,
keyCode : event . keyCode ? event . keyCode : event . charCode ,
shift : event . shiftKey ,
originalEvent : event ,
userData : tracker . userData
}
2012-04-11 01:02:24 +04:00
) ;
2013-09-06 04:20:17 +04:00
if ( ! propagate ) {
2012-04-11 01:02:24 +04:00
$ . cancelEvent ( event ) ;
2012-03-16 19:36:28 +04:00
}
}
2013-01-29 21:32:58 +04:00
}
2012-03-16 19:36:28 +04:00
2012-02-03 04:12:45 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2013-09-06 04:20:17 +04:00
function onMouseOver ( tracker , event , isTouch ) {
2012-02-10 07:16:09 +04:00
2013-09-20 20:58:18 +04:00
var delegate = THIS [ tracker . hash ] ,
2012-04-03 11:08:27 +04:00
propagate ;
2011-12-06 07:50:25 +04:00
2013-09-10 01:27:58 +04:00
isTouch = isTouch || false ;
2013-09-06 04:20:17 +04:00
2013-02-13 07:40:08 +04:00
event = $ . getEvent ( event ) ;
2013-09-11 04:23:19 +04:00
if ( ! isTouch ) {
if ( $ . Browser . vendor == $ . BROWSERS . IE &&
$ . Browser . version < 9 &&
delegate . capturing &&
! isChild ( event . srcElement , tracker . element ) ) {
2011-12-06 07:50:25 +04:00
2013-09-11 04:23:19 +04:00
triggerOthers ( tracker , onMouseOver , event , isTouch ) ;
}
2011-12-06 07:50:25 +04:00
2013-09-11 04:23:19 +04:00
var to = event . target ?
event . target :
event . srcElement ,
from = event . relatedTarget ?
event . relatedTarget :
event . fromElement ;
2011-12-06 07:50:25 +04:00
2013-09-11 04:23:19 +04:00
if ( ! isChild ( tracker . element , to ) ||
isChild ( tracker . element , from ) ) {
return ;
}
2012-02-03 04:12:45 +04:00
}
2011-12-06 07:50:25 +04:00
2012-02-03 04:12:45 +04:00
delegate . insideElement = true ;
2011-12-06 07:50:25 +04:00
2012-02-03 04:12:45 +04:00
if ( tracker . enterHandler ) {
2012-04-11 01:02:24 +04:00
propagate = tracker . enterHandler (
2013-09-06 04:20:17 +04:00
{
2013-10-11 04:00:15 +04:00
eventSource : tracker ,
2013-09-11 04:23:19 +04:00
position : getMouseRelative ( isTouch ? event . changedTouches [ 0 ] : event , tracker . element ) ,
2013-09-10 01:27:58 +04:00
insideElementPressed : delegate . insideElementPressed ,
2013-09-06 04:20:17 +04:00
buttonDownAny : IS _BUTTON _DOWN ,
isTouchEvent : isTouch ,
originalEvent : event ,
userData : tracker . userData
}
2012-04-11 01:02:24 +04:00
) ;
2013-09-06 04:20:17 +04:00
if ( propagate === false ) {
2012-04-11 01:02:24 +04:00
$ . cancelEvent ( event ) ;
2011-12-06 07:50:25 +04:00
}
2012-02-03 04:12:45 +04:00
}
2013-01-29 21:32:58 +04:00
}
2011-12-06 07:50:25 +04:00
2012-02-10 07:16:09 +04:00
2012-02-03 04:12:45 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2013-09-06 04:20:17 +04:00
function onMouseOut ( tracker , event , isTouch ) {
2013-09-20 20:58:18 +04:00
var delegate = THIS [ tracker . hash ] ,
2012-04-03 11:08:27 +04:00
propagate ;
2011-12-06 07:50:25 +04:00
2013-09-10 01:27:58 +04:00
isTouch = isTouch || false ;
2013-09-06 04:20:17 +04:00
2013-02-13 07:40:08 +04:00
event = $ . getEvent ( event ) ;
2013-09-11 04:23:19 +04:00
if ( ! isTouch ) {
if ( $ . Browser . vendor == $ . BROWSERS . IE &&
$ . Browser . version < 9 &&
delegate . capturing &&
! isChild ( event . srcElement , tracker . element ) ) {
2012-02-02 01:56:04 +04:00
2013-09-11 04:23:19 +04:00
triggerOthers ( tracker , onMouseOut , event , isTouch ) ;
2011-12-06 07:50:25 +04:00
2013-09-11 04:23:19 +04:00
}
2011-12-06 07:50:25 +04:00
2013-09-11 04:23:19 +04:00
var from = event . target ?
event . target :
event . srcElement ,
to = event . relatedTarget ?
event . relatedTarget :
event . toElement ;
2011-12-06 07:50:25 +04:00
2013-09-11 04:23:19 +04:00
if ( ! isChild ( tracker . element , from ) ||
isChild ( tracker . element , to ) ) {
return ;
}
2012-02-03 04:12:45 +04:00
}
2011-12-06 07:50:25 +04:00
2012-02-03 04:12:45 +04:00
delegate . insideElement = false ;
if ( tracker . exitHandler ) {
2013-06-19 21:33:25 +04:00
propagate = tracker . exitHandler (
2013-09-06 04:20:17 +04:00
{
2013-10-11 04:00:15 +04:00
eventSource : tracker ,
2013-09-11 04:23:19 +04:00
position : getMouseRelative ( isTouch ? event . changedTouches [ 0 ] : event , tracker . element ) ,
2013-09-10 01:27:58 +04:00
insideElementPressed : delegate . insideElementPressed ,
2013-09-06 04:20:17 +04:00
buttonDownAny : IS _BUTTON _DOWN ,
isTouchEvent : isTouch ,
originalEvent : event ,
userData : tracker . userData
}
2012-04-11 01:02:24 +04:00
) ;
2013-09-06 04:20:17 +04:00
if ( propagate === false ) {
2012-04-11 01:02:24 +04:00
$ . cancelEvent ( event ) ;
2011-12-06 07:50:25 +04:00
}
2012-02-03 04:12:45 +04:00
}
2013-01-29 21:32:58 +04:00
}
2011-12-06 07:50:25 +04:00
2012-02-10 07:16:09 +04:00
2012-02-03 04:12:45 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2013-09-06 04:20:17 +04:00
function onMouseDown ( tracker , event , noCapture , isTouch ) {
2013-09-20 20:58:18 +04:00
var delegate = THIS [ tracker . hash ] ,
2012-04-03 11:08:27 +04:00
propagate ;
2011-12-06 07:50:25 +04:00
2013-09-10 01:27:58 +04:00
isTouch = isTouch || false ;
2013-09-06 04:20:17 +04:00
2013-09-12 21:05:50 +04:00
event = $ . getEvent ( event ) ;
var eventOrTouchPoint = isTouch ? event . touches [ 0 ] : event ;
2013-02-13 07:40:08 +04:00
2012-02-03 04:12:45 +04:00
if ( event . button == 2 ) {
return ;
}
2011-12-06 07:50:25 +04:00
2013-09-10 01:27:58 +04:00
delegate . insideElementPressed = true ;
2011-12-06 07:50:25 +04:00
2013-09-12 21:05:50 +04:00
delegate . lastPoint = getMouseAbsolute ( eventOrTouchPoint ) ;
2012-02-03 04:12:45 +04:00
delegate . lastMouseDownPoint = delegate . lastPoint ;
2013-06-21 00:15:04 +04:00
delegate . lastMouseDownTime = $ . now ( ) ;
2012-02-03 04:12:45 +04:00
if ( tracker . pressHandler ) {
2013-06-19 21:33:25 +04:00
propagate = tracker . pressHandler (
2013-09-06 04:20:17 +04:00
{
2013-10-11 04:00:15 +04:00
eventSource : tracker ,
2013-09-12 21:05:50 +04:00
position : getMouseRelative ( eventOrTouchPoint , tracker . element ) ,
2013-09-06 04:20:17 +04:00
isTouchEvent : isTouch ,
2013-09-12 21:05:50 +04:00
originalEvent : event ,
2013-09-06 04:20:17 +04:00
userData : tracker . userData
}
2012-04-11 01:02:24 +04:00
) ;
2013-09-06 04:20:17 +04:00
if ( propagate === false ) {
2013-09-12 21:05:50 +04:00
$ . cancelEvent ( event ) ;
2011-12-06 07:50:25 +04:00
}
2012-02-03 04:12:45 +04:00
}
if ( tracker . pressHandler || tracker . dragHandler ) {
2013-09-12 21:05:50 +04:00
$ . cancelEvent ( event ) ;
2012-02-03 04:12:45 +04:00
}
2012-02-02 01:56:04 +04:00
2013-07-23 10:40:04 +04:00
if ( noCapture ) {
return ;
}
2013-09-06 04:20:17 +04:00
2013-09-11 04:23:19 +04:00
if ( isTouch ||
! ( $ . Browser . vendor == $ . BROWSERS . IE && $ . Browser . version < 9 ) ||
2012-04-11 01:02:24 +04:00
! IS _CAPTURING ) {
2012-02-03 04:12:45 +04:00
captureMouse ( tracker ) ;
IS _CAPTURING = true ;
// reset to empty & add us
2013-09-20 20:58:18 +04:00
CAPTURING = [ tracker ] ;
2013-09-06 04:20:17 +04:00
} else if ( $ . Browser . vendor == $ . BROWSERS . IE && $ . Browser . version < 9 ) {
2012-02-03 04:12:45 +04:00
// add us to the list
2013-06-19 21:33:25 +04:00
CAPTURING . push ( tracker ) ;
2012-02-03 04:12:45 +04:00
}
2013-01-29 21:32:58 +04:00
}
2012-02-03 04:12:45 +04:00
2012-02-10 07:16:09 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2012-02-10 07:16:09 +04:00
function onTouchStart ( tracker , event ) {
var touchA ,
touchB ;
2013-09-06 04:20:17 +04:00
if ( event . touches . length == 1 &&
2013-06-19 21:33:25 +04:00
event . targetTouches . length == 1 &&
2013-09-06 04:20:17 +04:00
event . changedTouches . length == 1 ) {
2013-06-19 21:33:25 +04:00
2013-09-20 20:58:18 +04:00
THIS [ tracker . hash ] . lastTouch = event . touches [ 0 ] ;
2013-09-07 00:12:11 +04:00
onMouseOver ( tracker , event , true ) ;
2013-09-10 01:27:58 +04:00
// call with no capture as the onMouseMoveCaptured will
2013-07-23 10:40:04 +04:00
// be triggered by onTouchMove
2013-09-07 00:12:11 +04:00
onMouseDown ( tracker , event , true , true ) ;
2012-02-10 07:16:09 +04:00
}
2013-09-06 04:20:17 +04:00
if ( event . touches . length == 2 ) {
2013-06-19 21:33:25 +04:00
2013-09-20 20:58:18 +04:00
touchA = getMouseAbsolute ( event . touches [ 0 ] ) ;
touchB = getMouseAbsolute ( event . touches [ 1 ] ) ;
THIS [ tracker . hash ] . lastPinchDelta =
2012-02-10 07:16:09 +04:00
Math . abs ( touchA . x - touchB . x ) +
Math . abs ( touchA . y - touchB . y ) ;
2013-09-20 20:58:18 +04:00
THIS [ tracker . hash ] . pinchMidpoint = new $ . Point (
2013-09-06 04:20:17 +04:00
( touchA . x + touchB . x ) / 2 ,
2013-02-27 15:57:06 +04:00
( touchA . y + touchB . y ) / 2
) ;
2012-02-10 07:16:09 +04:00
//$.console.debug("pinch start : "+THIS[ tracker.hash ].lastPinchDelta);
}
event . preventDefault ( ) ;
2013-01-29 21:32:58 +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
* /
2013-09-06 04:20:17 +04:00
function onMouseUp ( tracker , event , isTouch ) {
2013-09-20 20:58:18 +04:00
var delegate = THIS [ tracker . hash ] ,
2013-09-10 01:27:58 +04:00
//were we inside the tracked element when we were pressed
insideElementPressed = delegate . insideElementPressed ,
//are we still inside the tracked element when we released
2013-09-11 04:31:51 +04:00
insideElementReleased = delegate . insideElement ,
2012-04-03 11:08:27 +04:00
propagate ;
2012-02-03 04:12:45 +04:00
2013-09-10 01:27:58 +04:00
isTouch = isTouch || false ;
2013-09-06 04:20:17 +04:00
2013-09-12 21:05:50 +04:00
event = $ . getEvent ( event ) ;
2013-02-13 07:40:08 +04:00
2012-02-03 04:12:45 +04:00
if ( event . button == 2 ) {
return ;
}
2013-09-10 01:27:58 +04:00
delegate . insideElementPressed = false ;
2012-02-03 04:12:45 +04:00
if ( tracker . releaseHandler ) {
2012-04-11 01:02:24 +04:00
propagate = tracker . releaseHandler (
2013-09-06 04:20:17 +04:00
{
2013-10-11 04:00:15 +04:00
eventSource : tracker ,
2013-09-12 21:05:50 +04:00
position : getMouseRelative ( isTouch ? event . changedTouches [ 0 ] : event , tracker . element ) ,
2013-09-10 01:27:58 +04:00
insideElementPressed : insideElementPressed ,
2013-09-11 04:31:51 +04:00
insideElementReleased : insideElementReleased ,
2013-09-06 04:20:17 +04:00
isTouchEvent : isTouch ,
2013-09-12 21:05:50 +04:00
originalEvent : event ,
2013-09-06 04:20:17 +04:00
userData : tracker . userData
}
2012-04-11 01:02:24 +04:00
) ;
2013-09-06 04:20:17 +04:00
if ( propagate === false ) {
2013-09-12 21:05:50 +04:00
$ . cancelEvent ( event ) ;
2011-12-06 07:50:25 +04:00
}
2012-02-03 04:12:45 +04:00
}
2011-12-06 07:50:25 +04:00
2013-09-11 04:31:51 +04:00
if ( insideElementPressed && insideElementReleased ) {
2013-09-12 21:05:50 +04:00
handleMouseClick ( tracker , event , isTouch ) ;
2012-02-03 04:12:45 +04:00
}
2013-01-29 21:32:58 +04:00
}
2012-02-03 04:12:45 +04:00
2012-02-10 07:16:09 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2012-02-10 07:16:09 +04:00
function onTouchEnd ( tracker , event ) {
2013-09-06 04:20:17 +04:00
if ( event . touches . length === 0 &&
2013-06-19 21:33:25 +04:00
event . targetTouches . length === 0 &&
2013-09-06 04:20:17 +04:00
event . changedTouches . length == 1 ) {
2013-09-20 20:58:18 +04:00
THIS [ tracker . hash ] . lastTouch = null ;
2012-02-10 07:16:09 +04:00
2013-07-23 10:40:04 +04:00
// call with no release, as the mouse events are
// not registered in onTouchStart
2013-09-10 01:27:58 +04:00
onMouseUpCaptured ( tracker , event , true , true ) ;
2013-09-07 00:12:11 +04:00
onMouseOut ( tracker , event , true ) ;
2012-02-10 07:16:09 +04:00
}
2013-09-06 04:20:17 +04:00
if ( event . touches . length + event . changedTouches . length == 2 ) {
2013-09-20 20:58:18 +04:00
THIS [ tracker . hash ] . lastPinchDelta = null ;
THIS [ tracker . hash ] . pinchMidpoint = null ;
2012-02-10 07:16:09 +04:00
//$.console.debug("pinch end");
}
event . preventDefault ( ) ;
2013-01-29 21:32:58 +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
* Only triggered once by the deepest element that initially received
* the mouse down event . We want to make sure THIS event doesn ' t bubble .
* Instead , we want to trigger the elements that initially received the
* mouse down event ( including this one ) only if the mouse is no longer
* inside them . Then , we want to release capture , and emulate a regular
* mouseup on the event that this event was meant for .
* @ private
* @ inner
* /
2012-02-03 04:12:45 +04:00
function onMouseUpIE ( tracker , event ) {
2013-02-13 07:40:08 +04:00
var othertracker ,
2012-02-03 04:12:45 +04:00
i ;
2013-02-13 07:40:08 +04:00
event = $ . getEvent ( event ) ;
2012-02-03 04:12:45 +04:00
if ( event . button == 2 ) {
return ;
}
for ( i = 0 ; i < CAPTURING . length ; i ++ ) {
2013-09-20 20:58:18 +04:00
othertracker = CAPTURING [ i ] ;
2012-02-03 04:12:45 +04:00
if ( ! hasMouse ( othertracker ) ) {
2013-09-06 04:20:17 +04:00
onMouseUp ( othertracker , event , false ) ;
2011-12-06 07:50:25 +04:00
}
2012-02-03 04:12:45 +04:00
}
2011-12-06 07:50:25 +04:00
2012-02-03 04:12:45 +04:00
releaseMouse ( tracker ) ;
IS _CAPTURING = false ;
event . srcElement . fireEvent (
"on" + event . type ,
document . createEventObject ( event )
) ;
2011-12-06 07:50:25 +04:00
2012-02-03 04:12:45 +04:00
$ . stopEvent ( event ) ;
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
/ * *
2013-09-06 21:43:39 +04:00
* Only triggered in W3C browsers by elements within which the mouse was
* initially pressed , since they are now listening to the window for
* mouseup during the capture phase . We shouldn ' t handle the mouseup
* here if the mouse is still inside this element , since the regular
* mouseup handler will still fire .
* @ private
* @ inner
* /
2013-09-10 01:27:58 +04:00
function onMouseUpCaptured ( tracker , event , noRelease , isTouch ) {
isTouch = isTouch || false ;
2013-09-07 00:12:11 +04:00
2013-10-03 23:11:33 +04:00
if ( ! THIS [ tracker . hash ] . insideElement || isTouch ) {
2013-09-07 00:12:11 +04:00
onMouseUp ( tracker , event , isTouch ) ;
2012-02-03 04:12:45 +04:00
}
2013-07-23 10:40:04 +04:00
2013-09-06 04:20:17 +04:00
if ( noRelease ) {
2013-07-23 10:40:04 +04:00
return ;
}
2012-02-03 04:12:45 +04:00
releaseMouse ( tracker ) ;
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
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2013-09-06 04:20:17 +04:00
function onMouseMove ( tracker , event ) {
if ( tracker . moveHandler ) {
event = $ . getEvent ( event ) ;
var propagate = tracker . moveHandler (
{
2013-10-11 04:00:15 +04:00
eventSource : tracker ,
2013-09-06 04:20:17 +04:00
position : getMouseRelative ( event , tracker . element ) ,
isTouchEvent : false ,
originalEvent : event ,
userData : tracker . userData
}
) ;
if ( propagate === false ) {
$ . cancelEvent ( event ) ;
}
}
}
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2012-02-03 04:12:45 +04:00
function onMouseClick ( tracker , event ) {
if ( tracker . clickHandler ) {
$ . cancelEvent ( event ) ;
}
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
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2013-10-23 23:58:36 +04:00
function onWheel ( tracker , event ) {
handleWheelEvent ( tracker , event , event , false ) ;
}
/ * *
* @ private
* @ inner
* /
function onMouseWheel ( tracker , originalEvent ) {
// For legacy IE, access the global (window) event object
originalEvent = originalEvent || window . event ;
// Simulate a 'wheel' event
var event = {
target : originalEvent . target || originalEvent . srcElement ,
type : "wheel" ,
shiftKey : originalEvent . shiftKey || false ,
clientX : originalEvent . clientX ,
clientY : originalEvent . clientY ,
pageX : originalEvent . pageX ? originalEvent . pageX : originalEvent . clientX ,
pageY : originalEvent . pageY ? originalEvent . pageY : originalEvent . clientY ,
deltaMode : originalEvent . type == "MozMousePixelScroll" ? 0 : 1 , // 0=pixel, 1=line, 2=page
deltaX : 0 ,
deltaZ : 0 ,
preventDefault : function ( ) {
if ( originalEvent . preventDefault ) {
originalEvent . preventDefault ( ) ;
} else {
originalEvent . returnValue = false ;
}
}
} ;
// Calculate event.deltaY
if ( $ . MouseTracker . wheelEventName == "mousewheel" ) {
event . deltaY = - 1 / $ . DEFAULT _SETTINGS . pixelsPerWheelLine * originalEvent . wheelDelta ;
} else {
event . deltaY = originalEvent . detail ;
}
handleWheelEvent ( tracker , event , originalEvent , false ) ;
}
/ * *
* Handles 'wheel' events .
* The event may be simulated by the legacy mouse wheel event handler ( onMouseWheel ( ) ) or onTouchMove ( ) .
*
* @ private
* @ inner
* /
function handleWheelEvent ( tracker , event , originalEvent , isTouch ) {
2012-04-03 11:08:27 +04:00
var nDelta = 0 ,
propagate ;
2013-06-19 21:33:25 +04:00
2013-09-10 01:27:58 +04:00
isTouch = isTouch || false ;
2013-09-06 04:20:17 +04:00
2013-10-23 23:58:36 +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 ;
2011-12-06 07:50:25 +04:00
2012-02-03 04:12:45 +04:00
if ( tracker . scrollHandler ) {
2012-04-11 01:02:24 +04:00
propagate = tracker . scrollHandler (
2013-09-06 04:20:17 +04:00
{
2013-10-23 23:58:36 +04:00
eventSource : tracker ,
position : getMouseRelative ( event , tracker . element ) ,
scroll : nDelta ,
shift : event . shiftKey ,
isTouchEvent : isTouch ,
originalEvent : originalEvent ,
userData : tracker . userData
2013-09-06 04:20:17 +04:00
}
2012-04-11 01:02:24 +04:00
) ;
2013-09-06 04:20:17 +04:00
if ( propagate === false ) {
2012-04-11 01:02:24 +04:00
$ . cancelEvent ( event ) ;
2011-12-06 07:50:25 +04:00
}
2012-02-03 04:12:45 +04:00
}
2013-01-29 21:32:58 +04:00
}
2012-02-03 04:12:45 +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
* /
2013-09-11 04:23:19 +04:00
function handleMouseClick ( tracker , event , isTouch ) {
2013-09-20 20:58:18 +04:00
var delegate = THIS [ tracker . hash ] ,
2012-04-03 11:08:27 +04:00
propagate ;
2012-02-03 04:12:45 +04:00
2013-09-11 04:23:19 +04:00
isTouch = isTouch || false ;
2013-09-12 21:05:50 +04:00
event = $ . getEvent ( event ) ;
2013-09-11 04:23:19 +04:00
2013-09-20 20:58:18 +04:00
var eventOrTouchPoint = isTouch ? event . changedTouches [ 0 ] : event ;
2013-02-13 07:40:08 +04:00
2012-02-03 04:12:45 +04:00
if ( event . button == 2 ) {
return ;
}
2013-09-06 04:20:17 +04:00
var time = $ . now ( ) - delegate . lastMouseDownTime ,
2013-09-12 21:05:50 +04:00
point = getMouseAbsolute ( eventOrTouchPoint ) ,
2012-02-03 04:12:45 +04:00
distance = delegate . lastMouseDownPoint . distanceTo ( point ) ,
2013-09-06 04:20:17 +04:00
quick = time <= tracker . clickTimeThreshold &&
2012-02-03 04:12:45 +04:00
distance <= tracker . clickDistThreshold ;
if ( tracker . clickHandler ) {
2012-04-11 01:02:24 +04:00
propagate = tracker . clickHandler (
2013-09-06 04:20:17 +04:00
{
2013-10-11 04:00:15 +04:00
eventSource : tracker ,
2013-09-12 21:05:50 +04:00
position : getMouseRelative ( eventOrTouchPoint , tracker . element ) ,
2013-09-06 04:20:17 +04:00
quick : quick ,
2013-09-12 21:05:50 +04:00
shift : event . shiftKey ,
2013-09-11 04:23:19 +04:00
isTouchEvent : isTouch ,
2013-09-12 21:05:50 +04:00
originalEvent : event ,
2013-09-06 04:20:17 +04:00
userData : tracker . userData
}
2012-04-11 01:02:24 +04:00
) ;
2013-09-06 04:20:17 +04:00
if ( propagate === false ) {
2013-09-12 21:05:50 +04:00
$ . cancelEvent ( event ) ;
2011-12-06 07:50:25 +04:00
}
2012-02-03 04:12:45 +04:00
}
2013-01-29 21:32:58 +04:00
}
2011-12-06 07:50:25 +04:00
2012-02-10 07:16:09 +04:00
2012-02-03 04:12:45 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2013-09-10 01:27:58 +04:00
function onMouseMoveCaptured ( tracker , event , isTouch ) {
2013-09-20 20:58:18 +04:00
var delegate = THIS [ tracker . hash ] ,
2013-02-13 07:40:08 +04:00
delta ,
propagate ,
point ;
2013-09-10 01:27:58 +04:00
isTouch = isTouch || false ;
2013-09-06 04:20:17 +04:00
2013-09-12 21:05:50 +04:00
event = $ . getEvent ( event ) ;
2013-09-20 20:58:18 +04:00
var eventOrTouchPoint = isTouch ? event . touches [ 0 ] : event ;
2013-09-12 21:05:50 +04:00
point = getMouseAbsolute ( eventOrTouchPoint ) ;
2013-02-13 07:40:08 +04:00
delta = point . minus ( delegate . lastPoint ) ;
2012-02-03 04:12:45 +04:00
delegate . lastPoint = point ;
if ( tracker . dragHandler ) {
2012-04-11 01:02:24 +04:00
propagate = tracker . dragHandler (
2013-09-06 04:20:17 +04:00
{
2013-10-11 04:00:15 +04:00
eventSource : tracker ,
2013-09-12 21:05:50 +04:00
position : getMouseRelative ( eventOrTouchPoint , tracker . element ) ,
2013-09-06 04:20:17 +04:00
delta : delta ,
2013-09-12 21:05:50 +04:00
shift : event . shiftKey ,
2013-09-06 04:20:17 +04:00
isTouchEvent : isTouch ,
2013-09-12 21:05:50 +04:00
originalEvent : event ,
2013-09-06 04:20:17 +04:00
userData : tracker . userData
}
2012-04-11 01:02:24 +04:00
) ;
2013-09-06 04:20:17 +04:00
if ( propagate === false ) {
2013-09-12 21:05:50 +04:00
$ . cancelEvent ( event ) ;
2011-12-06 07:50:25 +04:00
}
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
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2012-02-10 07:16:09 +04:00
function onTouchMove ( tracker , event ) {
var touchA ,
touchB ,
pinchDelta ;
2013-09-20 20:58:18 +04:00
if ( ! THIS [ tracker . hash ] . lastTouch ) {
2013-09-06 04:20:17 +04:00
return ;
2013-08-16 21:09:49 +04:00
}
2013-09-06 04:20:17 +04:00
if ( event . touches . length === 1 &&
2013-06-19 21:33:25 +04:00
event . targetTouches . length === 1 &&
event . changedTouches . length === 1 &&
2013-09-20 20:58:18 +04:00
THIS [ tracker . hash ] . lastTouch . identifier === event . touches [ 0 ] . identifier ) {
2012-02-10 07:16:09 +04:00
2013-09-10 01:27:58 +04:00
onMouseMoveCaptured ( tracker , event , true ) ;
2012-02-10 07:16:09 +04:00
2013-09-06 04:20:17 +04:00
} else if ( event . touches . length === 2 ) {
2012-02-10 07:16:09 +04:00
2013-09-20 20:58:18 +04:00
touchA = getMouseAbsolute ( event . touches [ 0 ] ) ;
touchB = getMouseAbsolute ( event . touches [ 1 ] ) ;
2012-02-10 07:16:09 +04:00
pinchDelta =
Math . abs ( touchA . x - touchB . x ) +
Math . abs ( touchA . y - touchB . y ) ;
2013-06-19 21:33:25 +04:00
2012-02-10 07:16:09 +04:00
//TODO: make the 75px pinch threshold configurable
2013-09-20 20:58:18 +04:00
if ( Math . abs ( THIS [ tracker . hash ] . lastPinchDelta - pinchDelta ) > 75 ) {
2012-02-10 07:16:09 +04:00
//$.console.debug( "pinch delta : " + pinchDelta + " | previous : " + THIS[ tracker.hash ].lastPinchDelta);
2013-10-23 23:58:36 +04:00
// Simulate a 'wheel' event
2013-10-04 02:30:40 +04:00
var simulatedEvent = {
2013-10-23 23:58:36 +04:00
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 ,
deltaMode : 1 , // 0=pixel, 1=line, 2=page
deltaX : 0 ,
deltaY : ( THIS [ tracker . hash ] . lastPinchDelta > pinchDelta ) ? 1 : - 1 ,
deltaZ : 0 ,
preventDefault : function ( ) {
if ( event . preventDefault ) {
event . preventDefault ( ) ;
} else {
event . returnValue = false ;
}
}
2013-10-04 02:30:40 +04:00
} ;
2013-10-23 23:58:36 +04:00
handleWheelEvent ( tracker , simulatedEvent , event , true ) ;
2012-02-10 07:16:09 +04:00
2013-09-20 20:58:18 +04:00
THIS [ tracker . hash ] . lastPinchDelta = pinchDelta ;
2012-02-10 07:16:09 +04:00
}
}
event . preventDefault ( ) ;
2013-01-29 21:32:58 +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
* Only triggered once by the deepest element that initially received
* the mouse down event . Since no other element has captured the mouse ,
* we want to trigger the elements that initially received the mouse
* down event ( including this one ) . The the param tracker isn ' t used
* but for consistency with the other event handlers we include it .
* @ private
* @ inner
* /
2013-09-10 01:27:58 +04:00
function onMouseMoveCapturedIE ( tracker , event ) {
2012-02-03 04:12:45 +04:00
var i ;
for ( i = 0 ; i < CAPTURING . length ; i ++ ) {
2013-09-20 20:58:18 +04:00
onMouseMoveCaptured ( CAPTURING [ i ] , event , false ) ;
2012-02-03 04:12:45 +04:00
}
$ . stopEvent ( event ) ;
2013-01-29 21:32:58 +04:00
}
2011-12-06 07:50:25 +04:00
2012-02-01 06:01:37 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2011-12-14 05:04:38 +04:00
function getMouseAbsolute ( event ) {
2012-02-02 01:56:04 +04:00
return $ . getMousePosition ( event ) ;
2013-01-29 21:32:58 +04:00
}
2011-12-06 07:50:25 +04:00
2012-02-01 06:01:37 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2012-02-02 01:56:04 +04:00
function getMouseRelative ( event , element ) {
2013-09-10 01:27:58 +04:00
var mouse = $ . getMousePosition ( event ) ,
2013-09-06 04:20:17 +04:00
offset = $ . getElementOffset ( element ) ;
2011-12-06 07:50:25 +04:00
2012-02-02 01:56:04 +04:00
return mouse . minus ( offset ) ;
2013-01-29 21:32:58 +04:00
}
2011-12-06 07:50:25 +04:00
2011-12-14 05:04:38 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* Returns true if elementB is a child node of elementA , or if they ' re equal .
* /
2012-02-02 01:56:04 +04:00
function isChild ( elementA , elementB ) {
2011-12-14 05:04:38 +04:00
var body = document . body ;
2012-02-02 01:56:04 +04:00
while ( elementB && elementA != elementB && body != elementB ) {
2011-12-14 05:04:38 +04:00
try {
2012-02-02 01:56:04 +04:00
elementB = elementB . parentNode ;
2013-09-06 04:20:17 +04:00
} catch ( e ) {
2011-12-14 05:04:38 +04:00
return false ;
2011-12-06 07:50:25 +04:00
}
2011-12-14 05:04:38 +04:00
}
2012-02-02 01:56:04 +04:00
return elementA == elementB ;
2013-01-29 21:32:58 +04:00
}
2011-12-14 05:04:38 +04:00
2012-02-01 06:01:37 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2011-12-14 05:04:38 +04:00
function onGlobalMouseDown ( ) {
2012-02-03 04:12:45 +04:00
IS _BUTTON _DOWN = true ;
2013-01-29 21:32:58 +04:00
}
2011-12-14 05:04:38 +04:00
2012-02-01 06:01:37 +04:00
/ * *
2013-09-06 21:43:39 +04:00
* @ private
* @ inner
* /
2011-12-14 05:04:38 +04:00
function onGlobalMouseUp ( ) {
2012-02-03 04:12:45 +04:00
IS _BUTTON _DOWN = false ;
2013-01-29 21:32:58 +04:00
}
2011-12-06 07:50:25 +04:00
2011-12-14 05:04:38 +04:00
( function ( ) {
2012-04-11 01:02:24 +04:00
if ( $ . Browser . vendor == $ . BROWSERS . IE && $ . Browser . version < 9 ) {
2012-02-02 01:56:04 +04:00
$ . addEvent ( document , "mousedown" , onGlobalMouseDown , false ) ;
$ . addEvent ( document , "mouseup" , onGlobalMouseUp , false ) ;
2011-12-14 05:04:38 +04:00
} else {
2012-02-02 01:56:04 +04:00
$ . addEvent ( window , "mousedown" , onGlobalMouseDown , true ) ;
$ . addEvent ( window , "mouseup" , onGlobalMouseUp , true ) ;
2011-12-14 05:04:38 +04:00
}
2013-09-06 04:20:17 +04:00
} ) ( ) ;
2013-06-19 21:33:25 +04:00
2013-09-06 04:20:17 +04:00
} ( OpenSeadragon ) ) ;