From 6da2e4cef4c96472b40f59bad94bc515c00b9590 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 29 Jun 2018 10:09:10 +0200 Subject: [PATCH] More precise Event typing --- src/ol/control/Attribution.js | 2 +- src/ol/control/FullScreen.js | 2 +- src/ol/control/OverviewMap.js | 2 +- src/ol/control/Rotate.js | 2 +- src/ol/control/Zoom.js | 2 +- src/ol/control/ZoomSlider.js | 2 +- src/ol/control/ZoomToExtent.js | 2 +- src/ol/pointer/MouseSource.js | 12 +++++----- src/ol/pointer/TouchSource.js | 40 +++++++++++++++++----------------- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/ol/control/Attribution.js b/src/ol/control/Attribution.js index 64b7065ce8..2f000ed2c9 100644 --- a/src/ol/control/Attribution.js +++ b/src/ol/control/Attribution.js @@ -256,7 +256,7 @@ Attribution.prototype.updateElement_ = function(frameState) { /** - * @param {Event} event The event to handle + * @param {MouseEvent} event The event to handle * @private */ Attribution.prototype.handleClick_ = function(event) { diff --git a/src/ol/control/FullScreen.js b/src/ol/control/FullScreen.js index 2a1f7b2d1b..74b0459f40 100644 --- a/src/ol/control/FullScreen.js +++ b/src/ol/control/FullScreen.js @@ -136,7 +136,7 @@ inherits(FullScreen, Control); /** - * @param {Event} event The event to handle + * @param {MouseEvent} event The event to handle * @private */ FullScreen.prototype.handleClick_ = function(event) { diff --git a/src/ol/control/OverviewMap.js b/src/ol/control/OverviewMap.js index 46878ca856..6241ff3374 100644 --- a/src/ol/control/OverviewMap.js +++ b/src/ol/control/OverviewMap.js @@ -498,7 +498,7 @@ OverviewMap.prototype.calculateCoordinateRotate_ = function( /** - * @param {Event} event The event to handle + * @param {MouseEvent} event The event to handle * @private */ OverviewMap.prototype.handleClick_ = function(event) { diff --git a/src/ol/control/Rotate.js b/src/ol/control/Rotate.js index 3ef8d413f6..8d73e37ab4 100644 --- a/src/ol/control/Rotate.js +++ b/src/ol/control/Rotate.js @@ -113,7 +113,7 @@ inherits(Rotate, Control); /** - * @param {Event} event The event to handle + * @param {MouseEvent} event The event to handle * @private */ Rotate.prototype.handleClick_ = function(event) { diff --git a/src/ol/control/Zoom.js b/src/ol/control/Zoom.js index 09bb800c1c..235e216d80 100644 --- a/src/ol/control/Zoom.js +++ b/src/ol/control/Zoom.js @@ -98,7 +98,7 @@ inherits(Zoom, Control); /** * @param {number} delta Zoom delta. - * @param {Event} event The event to handle + * @param {MouseEvent} event The event to handle * @private */ Zoom.prototype.handleClick_ = function(delta, event) { diff --git a/src/ol/control/ZoomSlider.js b/src/ol/control/ZoomSlider.js index 567c4bd660..982e946c08 100644 --- a/src/ol/control/ZoomSlider.js +++ b/src/ol/control/ZoomSlider.js @@ -227,7 +227,7 @@ export function render(mapEvent) { /** - * @param {Event} event The browser event to handle. + * @param {MouseEvent} event The browser event to handle. * @private */ ZoomSlider.prototype.handleContainerClick_ = function(event) { diff --git a/src/ol/control/ZoomToExtent.js b/src/ol/control/ZoomToExtent.js index 5007605f09..49c8cf1b8b 100644 --- a/src/ol/control/ZoomToExtent.js +++ b/src/ol/control/ZoomToExtent.js @@ -68,7 +68,7 @@ inherits(ZoomToExtent, Control); /** - * @param {Event} event The event to handle + * @param {MouseEvent} event The event to handle * @private */ ZoomToExtent.prototype.handleClick_ = function(event) { diff --git a/src/ol/pointer/MouseSource.js b/src/ol/pointer/MouseSource.js index 8db1313423..f9a00a40ce 100644 --- a/src/ol/pointer/MouseSource.js +++ b/src/ol/pointer/MouseSource.js @@ -106,7 +106,7 @@ const DEDUP_DIST = 25; * or detect that the positions are invalid. * * @private - * @param {Event} inEvent The in event. + * @param {MouseEvent} inEvent The in event. * @return {boolean} True, if the event was generated by a touch. */ MouseSource.prototype.isEventSimulatedFromTouch_ = function(inEvent) { @@ -154,7 +154,7 @@ function prepareEvent(inEvent, dispatcher) { /** * Handler for `mousedown`. * - * @param {Event} inEvent The in event. + * @param {MouseEvent} inEvent The in event. */ MouseSource.prototype.mousedown = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { @@ -173,7 +173,7 @@ MouseSource.prototype.mousedown = function(inEvent) { /** * Handler for `mousemove`. * - * @param {Event} inEvent The in event. + * @param {MouseEvent} inEvent The in event. */ MouseSource.prototype.mousemove = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { @@ -186,7 +186,7 @@ MouseSource.prototype.mousemove = function(inEvent) { /** * Handler for `mouseup`. * - * @param {Event} inEvent The in event. + * @param {MouseEvent} inEvent The in event. */ MouseSource.prototype.mouseup = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { @@ -204,7 +204,7 @@ MouseSource.prototype.mouseup = function(inEvent) { /** * Handler for `mouseover`. * - * @param {Event} inEvent The in event. + * @param {MouseEvent} inEvent The in event. */ MouseSource.prototype.mouseover = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { @@ -217,7 +217,7 @@ MouseSource.prototype.mouseover = function(inEvent) { /** * Handler for `mouseout`. * - * @param {Event} inEvent The in event. + * @param {MouseEvent} inEvent The in event. */ MouseSource.prototype.mouseout = function(inEvent) { if (!this.isEventSimulatedFromTouch_(inEvent)) { diff --git a/src/ol/pointer/TouchSource.js b/src/ol/pointer/TouchSource.js index 8615e1242c..fd54196370 100644 --- a/src/ol/pointer/TouchSource.js +++ b/src/ol/pointer/TouchSource.js @@ -131,7 +131,7 @@ TouchSource.prototype.setPrimaryTouch_ = function(inTouch) { /** * @private - * @param {Object} inPointer The in pointer object. + * @param {PointerEvent} inPointer The in pointer object. */ TouchSource.prototype.removePrimaryPointer_ = function(inPointer) { if (inPointer.isPrimary) { @@ -172,9 +172,9 @@ TouchSource.prototype.cancelResetClickCount_ = function() { /** * @private - * @param {Event} browserEvent Browser event + * @param {TouchEvent} browserEvent Browser event * @param {Touch} inTouch Touch event - * @return {Object} A pointer object. + * @return {PointerEvent} A pointer object. */ TouchSource.prototype.touchToPointer_ = function(browserEvent, inTouch) { const e = this.dispatcher.cloneEvent(browserEvent, inTouch); @@ -208,8 +208,8 @@ TouchSource.prototype.touchToPointer_ = function(browserEvent, inTouch) { /** * @private - * @param {Event} inEvent Touch event - * @param {function(Event, Object)} inFunction In function. + * @param {TouchEvent} inEvent Touch event + * @param {function(TouchEvent, PointerEvent)} inFunction In function. */ TouchSource.prototype.processTouches_ = function(inEvent, inFunction) { const touches = Array.prototype.slice.call(inEvent.changedTouches); @@ -253,7 +253,7 @@ TouchSource.prototype.findTouch_ = function(touchList, searchId) { * this "abandoned" touch * * @private - * @param {Event} inEvent The in event. + * @param {TouchEvent} inEvent The in event. */ TouchSource.prototype.vacuumTouches_ = function(inEvent) { const touchList = inEvent.touches; @@ -284,7 +284,7 @@ TouchSource.prototype.vacuumTouches_ = function(inEvent) { * Handler for `touchstart`, triggers `pointerover`, * `pointerenter` and `pointerdown` events. * - * @param {Event} inEvent The in event. + * @param {TouchEvent} inEvent The in event. */ TouchSource.prototype.touchstart = function(inEvent) { this.vacuumTouches_(inEvent); @@ -297,8 +297,8 @@ TouchSource.prototype.touchstart = function(inEvent) { /** * @private - * @param {Event} browserEvent The event. - * @param {Object} inPointer The in pointer object. + * @param {TouchEvent} browserEvent The event. + * @param {PointerEvent} inPointer The in pointer object. */ TouchSource.prototype.overDown_ = function(browserEvent, inPointer) { this.pointerMap[inPointer.pointerId] = { @@ -315,7 +315,7 @@ TouchSource.prototype.overDown_ = function(browserEvent, inPointer) { /** * Handler for `touchmove`. * - * @param {Event} inEvent The in event. + * @param {TouchEvent} inEvent The in event. */ TouchSource.prototype.touchmove = function(inEvent) { inEvent.preventDefault(); @@ -325,8 +325,8 @@ TouchSource.prototype.touchmove = function(inEvent) { /** * @private - * @param {Event} browserEvent The event. - * @param {Object} inPointer The in pointer. + * @param {TouchEvent} browserEvent The event. + * @param {PointerEvent} inPointer The in pointer. */ TouchSource.prototype.moveOverOut_ = function(browserEvent, inPointer) { const event = inPointer; @@ -362,7 +362,7 @@ TouchSource.prototype.moveOverOut_ = function(browserEvent, inPointer) { * Handler for `touchend`, triggers `pointerup`, * `pointerout` and `pointerleave` events. * - * @param {Event} inEvent The event. + * @param {TouchEvent} inEvent The event. */ TouchSource.prototype.touchend = function(inEvent) { this.dedupSynthMouse_(inEvent); @@ -372,8 +372,8 @@ TouchSource.prototype.touchend = function(inEvent) { /** * @private - * @param {Event} browserEvent An event. - * @param {Object} inPointer The inPointer object. + * @param {TouchEvent} browserEvent An event. + * @param {PointerEvent} inPointer The inPointer object. */ TouchSource.prototype.upOut_ = function(browserEvent, inPointer) { this.dispatcher.up(inPointer, browserEvent); @@ -387,7 +387,7 @@ TouchSource.prototype.upOut_ = function(browserEvent, inPointer) { * Handler for `touchcancel`, triggers `pointercancel`, * `pointerout` and `pointerleave` events. * - * @param {Event} inEvent The in event. + * @param {TouchEvent} inEvent The in event. */ TouchSource.prototype.touchcancel = function(inEvent) { this.processTouches_(inEvent, this.cancelOut_); @@ -396,8 +396,8 @@ TouchSource.prototype.touchcancel = function(inEvent) { /** * @private - * @param {Event} browserEvent The event. - * @param {Object} inPointer The in pointer. + * @param {TouchEvent} browserEvent The event. + * @param {PointerEvent} inPointer The in pointer. */ TouchSource.prototype.cancelOut_ = function(browserEvent, inPointer) { this.dispatcher.cancel(inPointer, browserEvent); @@ -409,7 +409,7 @@ TouchSource.prototype.cancelOut_ = function(browserEvent, inPointer) { /** * @private - * @param {Object} inPointer The inPointer object. + * @param {PointerEvent} inPointer The inPointer object. */ TouchSource.prototype.cleanUpPointer_ = function(inPointer) { delete this.pointerMap[inPointer.pointerId]; @@ -421,7 +421,7 @@ TouchSource.prototype.cleanUpPointer_ = function(inPointer) { * Prevent synth mouse events from creating pointer events. * * @private - * @param {Event} inEvent The in event. + * @param {TouchEvent} inEvent The in event. */ TouchSource.prototype.dedupSynthMouse_ = function(inEvent) { const lts = this.mouseSource.lastTouches;