mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-28 16:16:08 +03:00
Merge pull request #262 from avandecreme/mousestop
Add mouse stop event
This commit is contained in:
commit
047129e817
@ -59,11 +59,14 @@
|
||||
* 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
|
||||
* The number of milliseconds within which multiple 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 {Number} options.stopDelay
|
||||
* The number of milliseconds without mouse move before the mouse stop
|
||||
* event is fired.
|
||||
* @param {Function} options.enterHandler
|
||||
* An optional handler for mouse enter.
|
||||
* @param {Function} options.exitHandler
|
||||
@ -116,6 +119,7 @@
|
||||
this.clickTimeThreshold = options.clickTimeThreshold;
|
||||
this.clickDistThreshold = options.clickDistThreshold;
|
||||
this.userData = options.userData || null;
|
||||
this.stopDelay = options.stopDelay || 50;
|
||||
|
||||
this.enterHandler = options.enterHandler || null;
|
||||
this.exitHandler = options.exitHandler || null;
|
||||
@ -125,6 +129,7 @@
|
||||
this.scrollHandler = options.scrollHandler || null;
|
||||
this.clickHandler = options.clickHandler || null;
|
||||
this.dragHandler = options.dragHandler || null;
|
||||
this.stopHandler = options.stopHandler || null;
|
||||
this.keyHandler = options.keyHandler || null;
|
||||
this.focusHandler = options.focusHandler || null;
|
||||
this.blurHandler = options.blurHandler || null;
|
||||
@ -221,7 +226,7 @@
|
||||
},
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -244,7 +249,7 @@
|
||||
enterHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -267,7 +272,7 @@
|
||||
exitHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -285,7 +290,7 @@
|
||||
pressHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -308,7 +313,7 @@
|
||||
releaseHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -326,7 +331,7 @@
|
||||
moveHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -348,7 +353,7 @@
|
||||
scrollHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -370,7 +375,7 @@
|
||||
clickHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -392,7 +397,25 @@
|
||||
dragHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* 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 {Boolean} event.isTouchEvent
|
||||
* True if the original event is a touch event, otherwise false.
|
||||
* @param {Object} event.originalEvent
|
||||
* The original event object.
|
||||
* @param {Object} event.userData
|
||||
* Arbitrary user-defined object.
|
||||
*/
|
||||
stopHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -410,7 +433,7 @@
|
||||
keyHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -424,7 +447,7 @@
|
||||
focusHandler: function () { },
|
||||
|
||||
/**
|
||||
* Implement or assign implmentation to these handlers during or after
|
||||
* Implement or assign implementation to these handlers during or after
|
||||
* calling the constructor.
|
||||
* @function
|
||||
* @param {Object} event
|
||||
@ -1073,8 +1096,29 @@
|
||||
$.cancelEvent( event );
|
||||
}
|
||||
}
|
||||
if ( tracker.stopHandler ) {
|
||||
clearTimeout( tracker.stopTimeOut );
|
||||
tracker.stopTimeOut = setTimeout( function() {
|
||||
onMouseStop( tracker, event );
|
||||
}, tracker.stopDelay );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @inner
|
||||
*/
|
||||
function onMouseStop( tracker, originalMoveEvent ) {
|
||||
if ( tracker.stopHandler ) {
|
||||
tracker.stopHandler( {
|
||||
eventSource: tracker,
|
||||
position: getMouseRelative( originalMoveEvent, tracker.element ),
|
||||
isTouchEvent: false,
|
||||
originalEvent: originalMoveEvent,
|
||||
userData: tracker.userData
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
Loading…
Reference in New Issue
Block a user