From cfb8cd3d628860682931bc52355ddd4382f54b1c Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 14 Mar 2018 12:29:40 +0100 Subject: [PATCH 01/24] No olx and ol types for ol/interaction/DoubleClickZoom --- externs/olx.js | 23 ----------------------- externs/xol.js | 7 ------- src/ol/interaction/DoubleClickZoom.js | 14 +++++++++++--- 3 files changed, 11 insertions(+), 33 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 5dcc2c040b..90bd5f5313 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,29 +5,6 @@ let olx; -/** - * @typedef {{duration: (number|undefined), - * delta: (number|undefined)}} - */ -olx.interaction.DoubleClickZoomOptions; - - -/** - * Animation duration in milliseconds. Default is `250`. - * @type {number|undefined} - * @api - */ -olx.interaction.DoubleClickZoomOptions.prototype.duration; - - -/** - * The zoom delta applied on each double click, default is `1`. - * @type {number|undefined} - * @api - */ -olx.interaction.DoubleClickZoomOptions.prototype.delta; - - /** * @typedef {{formatConstructors: (Array.|undefined), * source: (ol.source.Vector|undefined), diff --git a/externs/xol.js b/externs/xol.js index 9193164f13..e92673df2d 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,11 +1,4 @@ -/** - * @typedef {Object} interaction_DoubleClickZoomOptions - * @property {number|undefined} duration Animation duration in milliseconds. Default is `250`. - * @property {number|undefined} delta The zoom delta applied on each double click, default is `1`. - */ - - /** * @typedef {Object} interaction_DragAndDropOptions * @property {Array.|undefined} formatConstructors Format constructors. diff --git a/src/ol/interaction/DoubleClickZoom.js b/src/ol/interaction/DoubleClickZoom.js index 2dadd72287..9058896ebf 100644 --- a/src/ol/interaction/DoubleClickZoom.js +++ b/src/ol/interaction/DoubleClickZoom.js @@ -5,13 +5,21 @@ import {inherits} from '../index.js'; import MapBrowserEventType from '../MapBrowserEventType.js'; import Interaction, {zoomByDelta} from '../interaction/Interaction.js'; + +/** + * @typedef {Object} Options + * @property {number} [duration] Animation duration in milliseconds. Default is `250`. + * @property {number} [delta] The zoom delta applied on each double click, default is `1`. + */ + + /** * @classdesc * Allows the user to zoom by double-clicking on the map. * * @constructor - * @extends {ol.interaction.Interaction} - * @param {olx.interaction.DoubleClickZoomOptions=} opt_options Options. + * @extends {module:ol/interaction/Interaction~Interaction} + * @param {module:ol/interaction/DoubleClickZoom~Options=} opt_options Options. * @api */ const DoubleClickZoom = function(opt_options) { @@ -44,7 +52,7 @@ inherits(DoubleClickZoom, Interaction); * doubleclick) and eventually zooms the map. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @return {boolean} `false` to stop event propagation. - * @this {ol.interaction.DoubleClickZoom} + * @this {module:ol/interaction/DoubleClickZoom~DoubleClickZoom} */ function handleEvent(mapBrowserEvent) { let stopEvent = false; From 7c7e002ee4e041fbe152f5e6054a6d504e060d05 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 14 Mar 2018 12:33:58 +0100 Subject: [PATCH 02/24] No olx and ol types for ol/interaction/DragAndDrop --- externs/olx.js | 45 ------------------------------- externs/xol.js | 42 ++++++++++------------------- src/ol/interaction/DragAndDrop.js | 27 ++++++++++++++----- 3 files changed, 34 insertions(+), 80 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 90bd5f5313..9b9b73ceee 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,51 +5,6 @@ let olx; -/** - * @typedef {{formatConstructors: (Array.|undefined), - * source: (ol.source.Vector|undefined), - * projection: ol.ProjectionLike, - * target: (Element|undefined)}} - */ -olx.interaction.DragAndDropOptions; - - -/** - * Format constructors. - * @type {Array.|undefined} - * @api - */ -olx.interaction.DragAndDropOptions.prototype.formatConstructors; - - -/** - * Optional vector source where features will be added. If a source is provided - * all existing features will be removed and new features will be added when - * they are dropped on the target. If you want to add features to a vector - * source without removing the existing features (append only), instead of - * providing the source option listen for the "addfeatures" event. - * @type {ol.source.Vector|undefined} - * @api - */ -olx.interaction.DragAndDropOptions.prototype.source; - - -/** - * Target projection. By default, the map's view's projection is used. - * @type {ol.ProjectionLike} - * @api - */ -olx.interaction.DragAndDropOptions.prototype.projection; - - -/** - * The element that is used as the drop target, default is the viewport element. - * @type {Element|undefined} - * @api - */ -olx.interaction.DragAndDropOptions.prototype.target; - - /** * @typedef {{className: (string|undefined), * condition: (ol.EventsConditionType|undefined), diff --git a/externs/xol.js b/externs/xol.js index e92673df2d..d3c261c4b2 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,17 +1,4 @@ -/** - * @typedef {Object} interaction_DragAndDropOptions - * @property {Array.|undefined} formatConstructors Format constructors. - * @property {ol.source.Vector|undefined} source Optional vector source where features will be added. If a source is provided - * all existing features will be removed and new features will be added when - * they are dropped on the target. If you want to add features to a vector - * source without removing the existing features (append only), instead of - * providing the source option listen for the "addfeatures" event. - * @property {ol.ProjectionLike} projection Target projection. By default, the map's view's projection is used. - * @property {Element|undefined} target The element that is used as the drop target, default is the viewport element. - */ - - /** * @typedef {Object} interaction_DragBoxOptions * @property {string|undefined} className CSS class name for styling the box. The default is `ol-dragbox`. @@ -452,7 +439,7 @@ * rendered as vectors and can stay upright on rotated views. * * `'vector'`: Vector tiles are rendered as vectors. Most accurate rendering * even during animations, but slower performance than the other options. - * + * * When `declutter` is set to `true`, `'hybrid'` will be used instead of * `'image'`. The default is `'hybrid'`. * @property {ol.RenderOrderFunction|undefined} renderOrder Render order. Function to be used when sorting features before rendering. By @@ -697,7 +684,7 @@ * access pixel data with the Canvas renderer. See * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} * for more detail. - * + * * Default is `anonymous`. * @property {number|undefined} maxZoom Max zoom. Default is `19`. * @property {boolean|undefined} opaque Whether the layer is opaque. Default is `true`. @@ -977,9 +964,9 @@ * @property {module:ol/Feature~FeatureLoader|undefined} loader The loader function used to load features, from a remote source for example. * If this is not set and `url` is set, the source will create and use an XHR * feature loader. - * + * * Example: - * + * * ```js * var vectorSource = new ol.source.Vector({ * format: new ol.format.GeoJSON(), @@ -1031,18 +1018,18 @@ * @property {boolean|undefined} useSpatialIndex By default, an RTree is used as spatial index. When features are removed and * added frequently, and the total number of features is low, setting this to * `false` may improve performance. - * + * * Note that * {@link ol.source.Vector#getFeaturesInExtent}, * {@link ol.source.Vector#getClosestFeatureToCoordinate} and * {@link ol.source.Vector#getExtent} cannot be used when `useSpatialIndex` is * set to `false`, and {@link ol.source.Vector#forEachFeatureInExtent} will loop * through all features. - * + * * When set to `false`, the features will be maintained in an * {@link ol.Collection}, which can be retrieved through * {@link ol.source.Vector#getFeaturesCollection}. - * + * * The default is `true`. * @property {boolean|undefined} wrapX Wrap the world horizontally. Default is `true`. For vector editing across the * -180° and 180° meridians to work properly, this should be set to `false`. The @@ -1306,9 +1293,9 @@ * Internet Explorer 10 and lower [do not support][mdn] the `setLineDash` * method on the `CanvasRenderingContext2D` and therefore this option will * have no visual effect in these browsers. - * + * * [mdn]: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility - * + * * @property {number|undefined} lineDashOffset Line dash offset. Default is '0'. * @property {number|undefined} miterLimit Miter limit. Default is `10`. * @property {number|undefined} width Width. @@ -1362,7 +1349,7 @@ * @property {ol.StyleRenderFunction|undefined} renderer Custom renderer. When configured, `fill`, `stroke` and `image` will be * ignored, and the provided function will be called with each render frame for * each geometry. - * + * * @property {ol.style.Stroke|undefined} stroke Stroke style. * @property {ol.style.Text|undefined} text Text style. * @property {number|undefined} zIndex Z index. @@ -1445,10 +1432,10 @@ /** * @typedef {Object} ViewState - * @property {ol.Coordinate} center - * @property {module:ol/proj/Projection~Projection} projection - * @property {number} resolution - * @property {number} rotation + * @property {ol.Coordinate} center + * @property {module:ol/proj/Projection~Projection} projection + * @property {number} resolution + * @property {number} rotation * @property {number} zoom The current zoom level. */ @@ -1460,4 +1447,3 @@ * `WEBGL_MAX_TEXTURE_SIZE` or 2048 if WebGL is not supported. * @property {number|undefined} space The space in pixels between images (default: 1). */ - diff --git a/src/ol/interaction/DragAndDrop.js b/src/ol/interaction/DragAndDrop.js index 00750a29de..542dba32ba 100644 --- a/src/ol/interaction/DragAndDrop.js +++ b/src/ol/interaction/DragAndDrop.js @@ -12,13 +12,26 @@ import Interaction from '../interaction/Interaction.js'; import {get as getProjection} from '../proj.js'; +/** + * @typedef {Object} Options + * @property {Array.|undefined} formatConstructors Format constructors. + * @property {ol.source.Vector|undefined} source Optional vector source where features will be added. If a source is provided + * all existing features will be removed and new features will be added when + * they are dropped on the target. If you want to add features to a vector + * source without removing the existing features (append only), instead of + * providing the source option listen for the "addfeatures" event. + * @property {ol.ProjectionLike} projection Target projection. By default, the map's view's projection is used. + * @property {Element|undefined} target The element that is used as the drop target, default is the viewport element. + */ + + /** * @enum {string} */ const DragAndDropEventType = { /** * Triggered when features are added - * @event ol.interaction.DragAndDropEvent#addfeatures + * @event module:ol/interaction/DragAndDrop~DragAndDropEvent#addfeatures * @api */ ADD_FEATURES: 'addfeatures' @@ -27,13 +40,13 @@ const DragAndDropEventType = { /** * @classdesc - * Events emitted by {@link ol.interaction.DragAndDrop} instances are instances + * Events emitted by {@link module:ol/interaction/DragAndDrop~DragAndDrop} instances are instances * of this type. * * @constructor * @extends {ol.events.Event} * @implements {oli.interaction.DragAndDropEvent} - * @param {ol.interaction.DragAndDropEventType} type Type. + * @param {module:ol/interaction/DragAndDrop~DragAndDropEventType} type Type. * @param {File} file File. * @param {Array.=} opt_features Features. * @param {module:ol/proj/Projection~Projection=} opt_projection Projection. @@ -72,9 +85,9 @@ inherits(DragAndDropEvent, Event); * Handles input of vector data by drag and drop. * * @constructor - * @extends {ol.interaction.Interaction} - * @fires ol.interaction.DragAndDropEvent - * @param {olx.interaction.DragAndDropOptions=} opt_options Options. + * @extends {module:ol/interaction/Interaction~Interaction} + * @fires module:ol/interaction/DragAndDrop~DragAndDropEvent + * @param {module:ol/interaction/DragAndDrop~Options=} opt_options Options. * @api */ const DragAndDrop = function(opt_options) { @@ -124,7 +137,7 @@ inherits(DragAndDrop, Interaction); /** * @param {Event} event Event. - * @this {ol.interaction.DragAndDrop} + * @this {module:ol/interaction/DragAndDrop~DragAndDrop} */ function handleDrop(event) { const files = event.dataTransfer.files; From 12581b6a7762b808bd0d2f109975a8c300797c0c Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 14 Mar 2018 13:33:54 +0100 Subject: [PATCH 03/24] No olx and ol types for ol/interaction/DragBox --- externs/olx.js | 46 ------------------ externs/xol.js | 14 ------ src/ol/events/condition.js | 8 ++++ src/ol/interaction/DragBox.js | 64 +++++++++++++++++-------- src/ol/interaction/DragPan.js | 2 +- src/ol/interaction/DragRotate.js | 2 +- src/ol/interaction/DragRotateAndZoom.js | 2 +- src/ol/interaction/Draw.js | 6 +-- src/ol/interaction/KeyboardPan.js | 2 +- src/ol/interaction/Modify.js | 6 +-- src/ol/interaction/MouseWheelZoom.js | 2 +- src/ol/interaction/Select.js | 8 ++-- src/ol/typedefs.js | 18 ------- 13 files changed, 66 insertions(+), 114 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 9b9b73ceee..0366d4ad1c 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,52 +5,6 @@ let olx; -/** - * @typedef {{className: (string|undefined), - * condition: (ol.EventsConditionType|undefined), - * minArea: (number|undefined), - * boxEndCondition: (ol.DragBoxEndConditionType|undefined)}} - */ -olx.interaction.DragBoxOptions; - - -/** - * CSS class name for styling the box. The default is `ol-dragbox`. - * @type {string|undefined} - * @api - */ -olx.interaction.DragBoxOptions.prototype.className; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.always}. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.DragBoxOptions.prototype.condition; - - -/** - * The minimum area of the box in pixel, this value is used by the default - * `boxEndCondition` function. Default is `64`. - * @type {number|undefined} - * @api - */ -olx.interaction.DragBoxOptions.prototype.minArea; - - -/** - * A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two - * {@link ol.Pixel}s to indicate whether a `boxend` event should be fired. - * Default is `true` if the area of the box is bigger than the `minArea` option. - * @type {ol.DragBoxEndConditionType|undefined} - * @api - */ -olx.interaction.DragBoxOptions.prototype.boxEndCondition; - - /** * @typedef {{condition: (ol.EventsConditionType|undefined), * kinetic: (ol.Kinetic|undefined)}} diff --git a/externs/xol.js b/externs/xol.js index d3c261c4b2..b6ccfff443 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,18 +1,4 @@ -/** - * @typedef {Object} interaction_DragBoxOptions - * @property {string|undefined} className CSS class name for styling the box. The default is `ol-dragbox`. - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.always}. - * @property {number|undefined} minArea The minimum area of the box in pixel, this value is used by the default - * `boxEndCondition` function. Default is `64`. - * @property {ol.DragBoxEndConditionType|undefined} boxEndCondition A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two - * {@link ol.Pixel}s to indicate whether a `boxend` event should be fired. - * Default is `true` if the area of the box is bigger than the `minArea` option. - */ - - /** * @typedef {Object} interaction_DragPanOptions * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean diff --git a/src/ol/events/condition.js b/src/ol/events/condition.js index 3bee5ece34..536ba83697 100644 --- a/src/ol/events/condition.js +++ b/src/ol/events/condition.js @@ -7,6 +7,14 @@ import {TRUE, FALSE} from '../functions.js'; import {WEBKIT, MAC} from '../has.js'; +/** + * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * `{boolean}`. If the condition is met, true should be returned. + * + * @typedef {function(module:ol/MapBrowserEvent~MapBrowserEvent): boolean} Condition + */ + + /** * Return `true` if only the alt-key is pressed, `false` otherwise (e.g. when * additionally the shift-key is pressed). diff --git a/src/ol/interaction/DragBox.js b/src/ol/interaction/DragBox.js index 845ae42db8..55f20514ee 100644 --- a/src/ol/interaction/DragBox.js +++ b/src/ol/interaction/DragBox.js @@ -10,27 +10,49 @@ import PointerInteraction from '../interaction/Pointer.js'; import RenderBox from '../render/Box.js'; +/** + * A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two + * {@link module:ol~Pixel}s and returns a `{boolean}`. If the condition is met, + * true should be returned. + * @typedef {function(module:ol/MapBrowserEvent~MapBrowserEvent, module:ol~Pixel, module:ol~Pixel):boolean} EndCondition + */ + + +/** + * @typedef {Object} Options + * @property {string|undefined} className CSS class name for styling the box. The default is `ol-dragbox`. + * @property {module:ol/events/condition~Condition|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean + * to indicate whether that event should be handled. + * Default is {@link ol/events/condition~always}. + * @property {number|undefined} minArea The minimum area of the box in pixel, this value is used by the default + * `boxEndCondition` function. Default is `64`. + * @property {module:ol/interaction/DragBox~EndCondition|undefined} boxEndCondition A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two + * {@link module:ol~Pixel}s to indicate whether a `boxend` event should be fired. + * Default is `true` if the area of the box is bigger than the `minArea` option. + */ + + /** * @enum {string} */ const DragBoxEventType = { /** * Triggered upon drag box start. - * @event ol.interaction.DragBoxEvent#boxstart + * @event module:ol/interaction/DragBox~DragBoxEvent#boxstart * @api */ BOXSTART: 'boxstart', /** * Triggered on drag when box is active. - * @event ol.interaction.DragBoxEvent#boxdrag + * @event module:ol/interaction/DragBox~DragBoxEvent#boxdrag * @api */ BOXDRAG: 'boxdrag', /** * Triggered upon drag box end. - * @event ol.interaction.DragBoxEvent#boxend + * @event module:ol/interaction/DragBox~DragBoxEvent#boxend * @api */ BOXEND: 'boxend' @@ -39,13 +61,13 @@ const DragBoxEventType = { /** * @classdesc - * Events emitted by {@link ol.interaction.DragBox} instances are instances of + * Events emitted by {@link module:ol/interaction/DragBox~DragBox} instances are instances of * this type. * * @param {string} type The event type. * @param {module:ol/coordinate~Coordinate} coordinate The event coordinate. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Originating event. - * @extends {ol.events.Event} + * @extends {module:ol/events/Event~Event} * @constructor * @implements {oli.DragBoxEvent} */ @@ -75,18 +97,18 @@ inherits(DragBoxEvent, Event); /** * @classdesc * Allows the user to draw a vector box by clicking and dragging on the map, - * normally combined with an {@link ol.events.condition} that limits + * normally combined with an {@link module:ol/events/condition} that limits * it to when the shift or other key is held down. This is used, for example, * for zooming to a specific area of the map - * (see {@link ol.interaction.DragZoom} and - * {@link ol.interaction.DragRotateAndZoom}). + * (see {@link module:ol/interaction/DragZoom~DragZoom} and + * {@link module:ol/interaction/DragRotateAndZoom}). * * This interaction is only supported for mouse devices. * * @constructor - * @extends {ol.interaction.Pointer} - * @fires ol.interaction.DragBoxEvent - * @param {olx.interaction.DragBoxOptions=} opt_options Options. + * @extends {module:ol/interaction/Pointer} + * @fires module:ol/interaction/DragBox~DragBoxEvent + * @param {module:ol/interaction/DragBox~Options=} opt_options Options. * @api */ const DragBox = function(opt_options) { @@ -100,7 +122,7 @@ const DragBox = function(opt_options) { const options = opt_options ? opt_options : {}; /** - * @type {ol.render.Box} + * @type {module:ol/render/Box~Box} * @private */ this.box_ = new RenderBox(options.className || 'ol-dragbox'); @@ -119,13 +141,13 @@ const DragBox = function(opt_options) { /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.condition_ = options.condition ? options.condition : always; /** * @private - * @type {ol.DragBoxEndConditionType} + * @type {module:ol/interaction/DragBox~EndCondition} */ this.boxEndCondition_ = options.boxEndCondition ? options.boxEndCondition : defaultBoxEndCondition; @@ -142,7 +164,7 @@ inherits(DragBox, PointerInteraction); * @param {module:ol~Pixel} startPixel The starting pixel of the box. * @param {module:ol~Pixel} endPixel The end pixel of the box. * @return {boolean} Whether or not the boxend condition should be fired. - * @this {ol.interaction.DragBox} + * @this {module:ol/interaction/DragBox~DragBox} */ function defaultBoxEndCondition(mapBrowserEvent, startPixel, endPixel) { const width = endPixel[0] - startPixel[0]; @@ -152,8 +174,8 @@ function defaultBoxEndCondition(mapBrowserEvent, startPixel, endPixel) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. - * @this {ol.interaction.DragBox} + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. + * @this {module:ol/interaction/DragBox~DragBox} */ function handleDragEvent(mapBrowserEvent) { if (!mouseOnly(mapBrowserEvent)) { @@ -187,9 +209,9 @@ DragBox.prototype.onBoxEnd = UNDEFINED; /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.DragBox} + * @this {module:ol/interaction/DragBox~DragBox} */ function handleUpEvent(mapBrowserEvent) { if (!mouseOnly(mapBrowserEvent)) { @@ -209,9 +231,9 @@ function handleUpEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Start drag sequence? - * @this {ol.interaction.DragBox} + * @this {module:ol/interaction/DragBox~DragBox} */ function handleDownEvent(mapBrowserEvent) { if (!mouseOnly(mapBrowserEvent)) { diff --git a/src/ol/interaction/DragPan.js b/src/ol/interaction/DragPan.js index 3252c9fe44..d575d13a84 100644 --- a/src/ol/interaction/DragPan.js +++ b/src/ol/interaction/DragPan.js @@ -46,7 +46,7 @@ const DragPan = function(opt_options) { /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.condition_ = options.condition ? options.condition : noModifierKeys; diff --git a/src/ol/interaction/DragRotate.js b/src/ol/interaction/DragRotate.js index b1d4f897d6..9eb2ddeded 100644 --- a/src/ol/interaction/DragRotate.js +++ b/src/ol/interaction/DragRotate.js @@ -34,7 +34,7 @@ const DragRotate = function(opt_options) { /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.condition_ = options.condition ? options.condition : altShiftKeysOnly; diff --git a/src/ol/interaction/DragRotateAndZoom.js b/src/ol/interaction/DragRotateAndZoom.js index 6513fe4187..79ac4b5321 100644 --- a/src/ol/interaction/DragRotateAndZoom.js +++ b/src/ol/interaction/DragRotateAndZoom.js @@ -35,7 +35,7 @@ const DragRotateAndZoom = function(opt_options) { /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.condition_ = options.condition ? options.condition : shiftKeyOnly; diff --git a/src/ol/interaction/Draw.js b/src/ol/interaction/Draw.js index c887c5f671..21004f9c98 100644 --- a/src/ol/interaction/Draw.js +++ b/src/ol/interaction/Draw.js @@ -201,7 +201,7 @@ const Draw = function(options) { /** * A function to decide if a potential finish coordinate is permissible * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.finishCondition_ = options.finishCondition ? options.finishCondition : TRUE; @@ -348,13 +348,13 @@ const Draw = function(options) { /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.condition_ = options.condition ? options.condition : noModifierKeys; /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.freehandCondition_; if (options.freehand) { diff --git a/src/ol/interaction/KeyboardPan.js b/src/ol/interaction/KeyboardPan.js index 5a900c5a2c..867e4219a6 100644 --- a/src/ol/interaction/KeyboardPan.js +++ b/src/ol/interaction/KeyboardPan.js @@ -45,7 +45,7 @@ const KeyboardPan = function(opt_options) { /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.condition_ = options.condition !== undefined ? options.condition : this.defaultCondition_; diff --git a/src/ol/interaction/Modify.js b/src/ol/interaction/Modify.js index ed191ae210..84c0e8222a 100644 --- a/src/ol/interaction/Modify.js +++ b/src/ol/interaction/Modify.js @@ -108,7 +108,7 @@ const Modify = function(options) { /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.condition_ = options.condition ? options.condition : primaryAction; @@ -123,14 +123,14 @@ const Modify = function(options) { }; /** - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} * @private */ this.deleteCondition_ = options.deleteCondition ? options.deleteCondition : this.defaultDeleteCondition_; /** - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} * @private */ this.insertVertexCondition_ = options.insertVertexCondition ? diff --git a/src/ol/interaction/MouseWheelZoom.js b/src/ol/interaction/MouseWheelZoom.js index e47019a04e..cc8949cbe9 100644 --- a/src/ol/interaction/MouseWheelZoom.js +++ b/src/ol/interaction/MouseWheelZoom.js @@ -76,7 +76,7 @@ const MouseWheelZoom = function(opt_options) { /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.condition_ = options.condition ? options.condition : always; diff --git a/src/ol/interaction/Select.js b/src/ol/interaction/Select.js index 51a29c854f..22010432ec 100644 --- a/src/ol/interaction/Select.js +++ b/src/ol/interaction/Select.js @@ -99,25 +99,25 @@ const Select = function(opt_options) { /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.condition_ = options.condition ? options.condition : singleClick; /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.addCondition_ = options.addCondition ? options.addCondition : never; /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.removeCondition_ = options.removeCondition ? options.removeCondition : never; /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.toggleCondition_ = options.toggleCondition ? options.toggleCondition : shiftKeyOnly; diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index d23d00afcf..bae4445dda 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -153,15 +153,6 @@ ol.CircleRenderOptions; ol.DeclutterGroup; -/** - * A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two - * {@link module:ol~Pixel}s and returns a `{boolean}`. If the condition is met, - * true should be returned. - * @typedef {function(module:ol/MapBrowserEvent~MapBrowserEvent, module:ol~Pixel, module:ol~Pixel):boolean} - */ -ol.DragBoxEndConditionType; - - /** * Function that takes an array of coordinates and an optional existing geometry as * arguments, and returns a geometry. The optional existing geometry is the @@ -173,15 +164,6 @@ ol.DragBoxEndConditionType; ol.DrawGeometryFunctionType; -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a - * `{boolean}`. If the condition is met, true should be returned. - * - * @typedef {function(module:ol/MapBrowserEvent~MapBrowserEvent): boolean} - */ -ol.EventsConditionType; - - /** * @typedef {{x: number, xunits: (ol.style.IconAnchorUnits|undefined), * y: number, yunits: (ol.style.IconAnchorUnits|undefined), From a71ad16995f16b59d5215995dd23c11350c2f392 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 14 Mar 2018 13:40:46 +0100 Subject: [PATCH 04/24] No olx and ol types for ol/interaction/DragPan --- externs/olx.js | 25 ------------------------- externs/xol.js | 9 --------- src/ol/interaction/DragPan.js | 28 +++++++++++++++++++--------- 3 files changed, 19 insertions(+), 43 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 0366d4ad1c..6a0b21326b 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,31 +5,6 @@ let olx; -/** - * @typedef {{condition: (ol.EventsConditionType|undefined), - * kinetic: (ol.Kinetic|undefined)}} - */ -olx.interaction.DragPanOptions; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.noModifierKeys}. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.DragPanOptions.prototype.condition; - - -/** - * Kinetic inertia to apply to the pan. - * @type {ol.Kinetic|undefined} - * @api - */ -olx.interaction.DragPanOptions.prototype.kinetic; - - /** * @typedef {{condition: (ol.EventsConditionType|undefined), * duration: (number|undefined)}} diff --git a/externs/xol.js b/externs/xol.js index b6ccfff443..9dfa27601f 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,13 +1,4 @@ -/** - * @typedef {Object} interaction_DragPanOptions - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.noModifierKeys}. - * @property {ol.Kinetic|undefined} kinetic Kinetic inertia to apply to the pan. - */ - - /** * @typedef {Object} interaction_DragRotateAndZoomOptions * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean diff --git a/src/ol/interaction/DragPan.js b/src/ol/interaction/DragPan.js index d575d13a84..dc4af231e9 100644 --- a/src/ol/interaction/DragPan.js +++ b/src/ol/interaction/DragPan.js @@ -9,13 +9,23 @@ import {noModifierKeys} from '../events/condition.js'; import {FALSE} from '../functions.js'; import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js'; + +/** + * @typedef {Object} Options + * @property {module:ol/events/condition~Condition} [condition] A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean + * to indicate whether that event should be handled. + * Default is {@link module:ol/events/condition~noModifierKeys}. + * @property {module:ol/Kinetic~Kinetic} [kinetic] Kinetic inertia to apply to the pan. + */ + + /** * @classdesc * Allows the user to pan the map by dragging the map. * * @constructor - * @extends {ol.interaction.Pointer} - * @param {olx.interaction.DragPanOptions=} opt_options Options. + * @extends {module:ol/interaction/Pointer~Pointer} + * @param {module:ol/interaction/DragPan~Options=} opt_options Options. * @api */ const DragPan = function(opt_options) { @@ -30,7 +40,7 @@ const DragPan = function(opt_options) { /** * @private - * @type {ol.Kinetic|undefined} + * @type {module:ol/Kinetic~Kinetic|undefined} */ this.kinetic_ = options.kinetic; @@ -62,8 +72,8 @@ inherits(DragPan, PointerInteraction); /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. - * @this {ol.interaction.DragPan} + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. + * @this {module:ol/interaction/DragPan~DragPan} */ function handleDragEvent(mapBrowserEvent) { const targetPointers = this.targetPointers; @@ -95,9 +105,9 @@ function handleDragEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.DragPan} + * @this {module:ol/interaction/DragPan~DragPan} */ function handleUpEvent(mapBrowserEvent) { const map = mapBrowserEvent.map; @@ -133,9 +143,9 @@ function handleUpEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Start drag sequence? - * @this {ol.interaction.DragPan} + * @this {module:ol/interaction/DragPan~DragPan} */ function handleDownEvent(mapBrowserEvent) { if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) { From 5d0ea1118903372c04414f323a292634a03c91e6 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 15 Mar 2018 17:08:32 +0100 Subject: [PATCH 05/24] No olx and ol types for ol/interaction/DragRotate --- externs/olx.js | 50 -------------------------------- externs/xol.js | 18 ------------ src/ol/interaction/DragRotate.js | 29 ++++++++++++------ 3 files changed, 20 insertions(+), 77 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 6a0b21326b..aba6f65df3 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,56 +5,6 @@ let olx; -/** - * @typedef {{condition: (ol.EventsConditionType|undefined), - * duration: (number|undefined)}} - */ -olx.interaction.DragRotateAndZoomOptions; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.shiftKeyOnly}. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.DragRotateAndZoomOptions.prototype.condition; - - -/** - * Animation duration in milliseconds. Default is `400`. - * @type {number|undefined} - * @api - */ -olx.interaction.DragRotateAndZoomOptions.prototype.duration; - - -/** - * @typedef {{condition: (ol.EventsConditionType|undefined), - * duration: (number|undefined)}} - */ -olx.interaction.DragRotateOptions; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.altShiftKeysOnly}. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.DragRotateOptions.prototype.condition; - - -/** - * Animation duration in milliseconds. Default is `250`. - * @type {number|undefined} - * @api - */ -olx.interaction.DragRotateOptions.prototype.duration; - - /** * @typedef {{className: (string|undefined), * condition: (ol.EventsConditionType|undefined), diff --git a/externs/xol.js b/externs/xol.js index 9dfa27601f..bad56e6d09 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,22 +1,4 @@ -/** - * @typedef {Object} interaction_DragRotateAndZoomOptions - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.shiftKeyOnly}. - * @property {number|undefined} duration Animation duration in milliseconds. Default is `400`. - */ - - -/** - * @typedef {Object} interaction_DragRotateOptions - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.altShiftKeysOnly}. - * @property {number|undefined} duration Animation duration in milliseconds. Default is `250`. - */ - - /** * @typedef {Object} interaction_DragZoomOptions * @property {string|undefined} className CSS class name for styling the box. The default is `ol-dragzoom`. diff --git a/src/ol/interaction/DragRotate.js b/src/ol/interaction/DragRotate.js index 9eb2ddeded..d3c25bd362 100644 --- a/src/ol/interaction/DragRotate.js +++ b/src/ol/interaction/DragRotate.js @@ -9,17 +9,28 @@ import {FALSE} from '../functions.js'; import {rotate, rotateWithoutConstraints} from '../interaction/Interaction.js'; import PointerInteraction from '../interaction/Pointer.js'; + +/** + * @typedef {Object} Options + * @property {module:ol/events/condition~Condition} [condition] A function that takes an + * {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean + * to indicate whether that event should be handled. + * Default is {@link module:ol/events/condition~altShiftKeysOnly}. + * @property {number} [duration=250] Animation duration in milliseconds. + */ + + /** * @classdesc * Allows the user to rotate the map by clicking and dragging on the map, - * normally combined with an {@link ol.events.condition} that limits + * normally combined with an {@link module:ol/events/condition} that limits * it to when the alt and shift keys are held down. * * This interaction is only supported for mouse devices. * * @constructor - * @extends {ol.interaction.Pointer} - * @param {olx.interaction.DragRotateOptions=} opt_options Options. + * @extends {module:ol/interaction/Pointer~Pointer} + * @param {ol/interaction/DragRotate~Options=} opt_options Options. * @api */ const DragRotate = function(opt_options) { @@ -55,8 +66,8 @@ inherits(DragRotate, PointerInteraction); /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. - * @this {ol.interaction.DragRotate} + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. + * @this {module:ol/interaction/DragRotate~DragRotate} */ function handleDragEvent(mapBrowserEvent) { if (!mouseOnly(mapBrowserEvent)) { @@ -82,9 +93,9 @@ function handleDragEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.DragRotate} + * @this {module:ol/interaction/DragRotate~DragRotate} */ function handleUpEvent(mapBrowserEvent) { if (!mouseOnly(mapBrowserEvent)) { @@ -101,9 +112,9 @@ function handleUpEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Start drag sequence? - * @this {ol.interaction.DragRotate} + * @this {module:ol/interaction/DragRotate~DragRotate} */ function handleDownEvent(mapBrowserEvent) { if (!mouseOnly(mapBrowserEvent)) { From 47d49a802e832b4d0423b7e4e7510b00b0752439 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 15 Mar 2018 17:12:48 +0100 Subject: [PATCH 06/24] No olx and ol types for ol/interaction/DragRotateAndZoom --- src/ol/interaction/DragRotateAndZoom.js | 27 +++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/ol/interaction/DragRotateAndZoom.js b/src/ol/interaction/DragRotateAndZoom.js index 79ac4b5321..0e30540b69 100644 --- a/src/ol/interaction/DragRotateAndZoom.js +++ b/src/ol/interaction/DragRotateAndZoom.js @@ -8,6 +8,17 @@ import {shiftKeyOnly, mouseOnly} from '../events/condition.js'; import {rotate, rotateWithoutConstraints, zoom, zoomWithoutConstraints} from '../interaction/Interaction.js'; import PointerInteraction from '../interaction/Pointer.js'; + +/** + * @typedef {Object} Options + * @property {module:ol/events/condition~Condition} [condition] A function that + * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. + * Default is {@link module:ol/events/condition~shiftKeyOnly}. + * @property {number} [dura00tion=4] Animation duration in milliseconds. + */ + + /** * @classdesc * Allows the user to zoom and rotate the map by clicking and dragging @@ -19,8 +30,8 @@ import PointerInteraction from '../interaction/Pointer.js'; * And this interaction is not included in the default interactions. * * @constructor - * @extends {ol.interaction.Pointer} - * @param {olx.interaction.DragRotateAndZoomOptions=} opt_options Options. + * @extends {module:ol/interaction/Pointer~Pointer} + * @param {module:ol/interaction/DragRotateAndZoom~Options=} opt_options Options. * @api */ const DragRotateAndZoom = function(opt_options) { @@ -69,8 +80,8 @@ inherits(DragRotateAndZoom, PointerInteraction); /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. - * @this {ol.interaction.DragRotateAndZoom} + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. + * @this {module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom} */ function handleDragEvent(mapBrowserEvent) { if (!mouseOnly(mapBrowserEvent)) { @@ -102,9 +113,9 @@ function handleDragEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.DragRotateAndZoom} + * @this {module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom} */ function handleUpEvent(mapBrowserEvent) { if (!mouseOnly(mapBrowserEvent)) { @@ -123,9 +134,9 @@ function handleUpEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Start drag sequence? - * @this {ol.interaction.DragRotateAndZoom} + * @this {module:ol/interaction/DragRotateAndZoom~DragRotateAndZoom} */ function handleDownEvent(mapBrowserEvent) { if (!mouseOnly(mapBrowserEvent)) { From 2c6afdd5bb2d882d359bc477fc02eeff25b7f452 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 15 Mar 2018 17:18:52 +0100 Subject: [PATCH 07/24] No olx and ol types for ol/interaction/DragZoom --- externs/olx.js | 43 ---------------------------------- externs/xol.js | 11 --------- src/ol/interaction/DragZoom.js | 22 +++++++++++++---- 3 files changed, 18 insertions(+), 58 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index aba6f65df3..6f7253638a 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,49 +5,6 @@ let olx; -/** - * @typedef {{className: (string|undefined), - * condition: (ol.EventsConditionType|undefined), - * duration: (number|undefined), - * out: (boolean|undefined)}} - */ -olx.interaction.DragZoomOptions; - - -/** - * CSS class name for styling the box. The default is `ol-dragzoom`. - * @type {string|undefined} - * @api - */ -olx.interaction.DragZoomOptions.prototype.className; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.shiftKeyOnly}. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.DragZoomOptions.prototype.condition; - - -/** - * Animation duration in milliseconds. Default is `200`. - * @type {number|undefined} - * @api - */ -olx.interaction.DragZoomOptions.prototype.duration; - - -/** - * Use interaction for zooming out. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.interaction.DragZoomOptions.prototype.out; - - /** * @typedef {{clickTolerance: (number|undefined), * features: (ol.Collection.|undefined), diff --git a/externs/xol.js b/externs/xol.js index bad56e6d09..7dc83663ef 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,15 +1,4 @@ -/** - * @typedef {Object} interaction_DragZoomOptions - * @property {string|undefined} className CSS class name for styling the box. The default is `ol-dragzoom`. - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.shiftKeyOnly}. - * @property {number|undefined} duration Animation duration in milliseconds. Default is `200`. - * @property {boolean|undefined} out Use interaction for zooming out. Default is `false`. - */ - - /** * @typedef {Object} interaction_DrawOptions * @property {number|undefined} clickTolerance The maximum distance in pixels between "down" and "up" for a "up" event diff --git a/src/ol/interaction/DragZoom.js b/src/ol/interaction/DragZoom.js index 839d892c64..ffaa340c8b 100644 --- a/src/ol/interaction/DragZoom.js +++ b/src/ol/interaction/DragZoom.js @@ -7,18 +7,32 @@ import {shiftKeyOnly} from '../events/condition.js'; import {createOrUpdateFromCoordinates, getBottomLeft, getCenter, getTopRight, scaleFromCenter} from '../extent.js'; import DragBox from '../interaction/DragBox.js'; + +/** + * @typedef {Object} Options + * @property {string} [className='ol-dragzoom'] CSS class name for styling the + * box. + * @property {module:ol/events/condition~Condition} [condition] A function that + * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. + * Default is {@link module:ol/events/condition~shiftKeyOnly}. + * @property {number} [duration=200] Animation duration in milliseconds. + * @property {boolean} [out=false] Use interaction for zooming out. + */ + + /** * @classdesc * Allows the user to zoom the map by clicking and dragging on the map, - * normally combined with an {@link ol.events.condition} that limits + * normally combined with an {@link module:ol/events/condition} that limits * it to when a key, shift by default, is held down. * * To change the style of the box, use CSS and the `.ol-dragzoom` selector, or * your custom one configured with `className`. * * @constructor - * @extends {ol.interaction.DragBox} - * @param {olx.interaction.DragZoomOptions=} opt_options Options. + * @extends {module:ol/interaction/DragBox~DragBox} + * @param {ol/interaction/DragZoom~Options=} opt_options Options. * @api */ const DragZoom = function(opt_options) { @@ -54,7 +68,7 @@ inherits(DragZoom, DragBox); DragZoom.prototype.onBoxEnd = function() { const map = this.getMap(); - const view = /** @type {!ol.View} */ (map.getView()); + const view = /** @type {!module:ol/View~View} */ (map.getView()); const size = /** @type {!module:ol/size~Size} */ (map.getSize()); From b19f00d893ac5f865dcec1a59f1e8ddcf1d22697 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 15 Mar 2018 17:51:19 +0100 Subject: [PATCH 08/24] No olx and ol types for ol/interaction/Draw --- externs/olx.js | 176 ------------------------------------- externs/xol.js | 41 --------- src/ol/interaction/Draw.js | 113 ++++++++++++++++++------ src/ol/typedefs.js | 11 --- 4 files changed, 88 insertions(+), 253 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 6f7253638a..ab415199de 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,182 +5,6 @@ let olx; -/** - * @typedef {{clickTolerance: (number|undefined), - * features: (ol.Collection.|undefined), - * source: (ol.source.Vector|undefined), - * dragVertexDelay: (number|undefined), - * snapTolerance: (number|undefined), - * type: (module:ol/geom/GeometryType~GeometryType|string), - * stopClick: (boolean|undefined), - * maxPoints: (number|undefined), - * minPoints: (number|undefined), - * finishCondition: (ol.EventsConditionType|undefined), - * style: (ol.style.Style|Array.|ol.StyleFunction|undefined), - * geometryFunction: (ol.DrawGeometryFunctionType|undefined), - * geometryName: (string|undefined), - * condition: (ol.EventsConditionType|undefined), - * freehand: (boolean|undefined), - * freehandCondition: (ol.EventsConditionType|undefined), - * wrapX: (boolean|undefined)}} - */ -olx.interaction.DrawOptions; - - -/** - * The maximum distance in pixels between "down" and "up" for a "up" event - * to be considered a "click" event and actually add a point/vertex to the - * geometry being drawn. Default is 6 pixels. That value was chosen for - * the draw interaction to behave correctly on mouse as well as on touch - * devices. - * @type {number|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.clickTolerance; - - -/** - * Destination collection for the drawn features. - * @type {ol.Collection.|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.features; - - -/** - * Destination source for the drawn features. - * @type {ol.source.Vector|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.source; - - -/** - * Delay in milliseconds after pointerdown before the current vertex can be - * dragged to its exact position. Default is 500 ms. - * @type {number|undefined} - */ -olx.interaction.DrawOptions.prototype.dragVertexDelay; - - -/** - * Pixel distance for snapping to the drawing finish. Default is `12`. - * @type {number|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.snapTolerance; - - -/** - * Drawing type ('Point', 'LineString', 'Polygon', 'MultiPoint', - * 'MultiLineString', 'MultiPolygon' or 'Circle'). - * @type {module:ol/geom/GeometryType~GeometryType|string} - * @api - */ -olx.interaction.DrawOptions.prototype.type; - - -/** - * Stop click, singleclick, and doubleclick events from firing during drawing. - * Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.stopClick; - - -/** - * The number of points that can be drawn before a polygon ring or line string - * is finished. The default is no restriction. - * @type {number|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.maxPoints; - - -/** - * The number of points that must be drawn before a polygon ring or line string - * can be finished. Default is `3` for polygon rings and `2` for line strings. - * @type {number|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.minPoints; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether the drawing can be finished. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.finishCondition; - - -/** - * Style for sketch features. - * @type {ol.style.Style|Array.|ol.StyleFunction|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.style; - - -/** - * Function that is called when a geometry's coordinates are updated. - * @type {ol.DrawGeometryFunctionType|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.geometryFunction; - - -/** - * Geometry name to use for features created by the draw interaction. - * @type {string|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.geometryName; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * By default {@link ol.events.condition.noModifierKeys}, i.e. a click, adds a - * vertex or deactivates freehand drawing. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.condition; - - -/** - * Operate in freehand mode for lines, polygons, and circles. This makes the - * interaction always operate in freehand mode and takes precedence over any - * `freehandCondition` option. - * @type {boolean|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.freehand; - - -/** - * Condition that activates freehand drawing for lines and polygons. This - * function takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean to - * indicate whether that event should be handled. The default is - * {@link ol.events.condition.shiftKeyOnly}, meaning that the Shift key - * activates freehand drawing. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.freehandCondition; - - -/** - * Wrap the world horizontally on the sketch overlay. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.interaction.DrawOptions.prototype.wrapX; - - /** * @typedef {{extent: (ol.Extent|undefined), * boxStyle: (ol.style.Style|Array.|ol.StyleFunction|undefined), diff --git a/externs/xol.js b/externs/xol.js index 7dc83663ef..c83167936d 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,45 +1,4 @@ -/** - * @typedef {Object} interaction_DrawOptions - * @property {number|undefined} clickTolerance The maximum distance in pixels between "down" and "up" for a "up" event - * to be considered a "click" event and actually add a point/vertex to the - * geometry being drawn. Default is 6 pixels. That value was chosen for - * the draw interaction to behave correctly on mouse as well as on touch - * devices. - * @property {ol.Collection.|undefined} features Destination collection for the drawn features. - * @property {ol.source.Vector|undefined} source Destination source for the drawn features. - * @property {number|undefined} dragVertexDelay Delay in milliseconds after pointerdown before the current vertex can be - * dragged to its exact position. Default is 500 ms. - * @property {number|undefined} snapTolerance Pixel distance for snapping to the drawing finish. Default is `12`. - * @property {module:ol/geom/GeometryType~GeometryType|string} type Drawing type ('Point', 'LineString', 'Polygon', 'MultiPoint', - * 'MultiLineString', 'MultiPolygon' or 'Circle'). - * @property {boolean|undefined} stopClick Stop click, singleclick, and doubleclick events from firing during drawing. - * Default is `false`. - * @property {number|undefined} maxPoints The number of points that can be drawn before a polygon ring or line string - * is finished. The default is no restriction. - * @property {number|undefined} minPoints The number of points that must be drawn before a polygon ring or line string - * can be finished. Default is `3` for polygon rings and `2` for line strings. - * @property {ol.EventsConditionType|undefined} finishCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether the drawing can be finished. - * @property {ol.style.Style|Array.|ol.StyleFunction|undefined} style Style for sketch features. - * @property {ol.DrawGeometryFunctionType|undefined} geometryFunction Function that is called when a geometry's coordinates are updated. - * @property {string|undefined} geometryName Geometry name to use for features created by the draw interaction. - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * By default {@link ol.events.condition.noModifierKeys}, i.e. a click, adds a - * vertex or deactivates freehand drawing. - * @property {boolean|undefined} freehand Operate in freehand mode for lines, polygons, and circles. This makes the - * interaction always operate in freehand mode and takes precedence over any - * `freehandCondition` option. - * @property {ol.EventsConditionType|undefined} freehandCondition Condition that activates freehand drawing for lines and polygons. This - * function takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean to - * indicate whether that event should be handled. The default is - * {@link ol.events.condition.shiftKeyOnly}, meaning that the Shift key - * activates freehand drawing. - * @property {boolean|undefined} wrapX Wrap the world horizontally on the sketch overlay. Default is `false`. - */ - - /** * @typedef {Object} interaction_ExtentOptions * @property {ol.Extent|undefined} extent Initial extent. Defaults to no initial extent diff --git a/src/ol/interaction/Draw.js b/src/ol/interaction/Draw.js index 21004f9c98..a7795bae57 100644 --- a/src/ol/interaction/Draw.js +++ b/src/ol/interaction/Draw.js @@ -29,6 +29,69 @@ import VectorSource from '../source/Vector.js'; import {createEditingStyle} from '../style/Style.js'; +/** + * @typedef {Object} Options + * @property {module:ol/geom/GeometryType~GeometryType} type Geometry type of + * the geometries being drawn with this instance. + * @property {number} [clickTolerance=6] The maximum distance in pixels between + * "down" and "up" for a "up" event to be considered a "click" event and + * actually add a point/vertex to the geometry being drawn. The default of `6` + * was chosen for the draw interaction to behave correctly on mouse as well as + * on touch devices. + * @property {module:ol/Collection~Collection.} [features] + * Destination collection for the drawn features. + * @property {module:ol/source/Vector~Vector} [source] Destination source for + * the drawn features. + * @property {number} [dragVertexDelay=500] Delay in milliseconds after pointerdown + * before the current vertex can be dragged to its exact position. + * @property {number} [snapTolerance=12] Pixel distance for snapping to the + * drawing finish. + * @property {boolean} [stopClick=false] Stop click, singleclick, and + * doubleclick events from firing during drawing. + * @property {number} [maxPoints] The number of points that can be drawn before + * a polygon ring or line string is finished. By default there is no + * restriction. + * @property {number} [minPoints] The number of points that must be drawn + * before a polygon ring or line string can be finished. Default is `3` for + * polygon rings and `2` for line strings. + * @property {module:ol/events/condition~Condition} [finishCondition] A function + * that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether the drawing can be finished. + * @property {module:ol/style/Style~Style|Array.|module:ol/style~StyleFunction} [style] + * Style for sketch features. + * @property {module:ol/interaction/Draw~GeometryFunction} [geometryFunction] + * Function that is called when a geometry's coordinates are updated. + * @property {string} [geometryName] Geometry name to use for features created + * by the draw interaction. + * @property {module:ol/events/condition~Condition} [condition] A function that + * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. + * By default {@link module:ol/events/condition~noModifierKeys}, i.e. a click, + * adds a vertex or deactivates freehand drawing. + * @property {boolean} [freehand=false] Operate in freehand mode for lines, + * polygons, and circles. This makes the interaction always operate in freehand + * mode and takes precedence over any `freehandCondition` option. + * @property {module:ol/events/condition~Condition} [freehandCondition] + * Condition that activates freehand drawing for lines and polygons. This + * function takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and + * returns a boolean to indicate whether that event should be handled. The + * default is {@link module:ol/events/condition~shiftKeyOnly}, meaning that the + * Shift key activates freehand drawing. + * @property {boolean} [wrapX=false] Wrap the world horizontally on the sketch + * overlay. + */ + + +/** + * Function that takes an array of coordinates and an optional existing geometry as + * arguments, and returns a geometry. The optional existing geometry is the + * geometry that is returned when the function is called without a second + * argument. + * @typedef {function(!Array., module:ol/geom/SimpleGeometry~SimpleGeometry=): + * module:ol/geom/SimpleGeometry~SimpleGeometry} GeometryFunction + */ + + /** * Draw mode. This collapses multi-part geometry types with their single-part * cousins. @@ -48,13 +111,13 @@ const Mode = { const DrawEventType = { /** * Triggered upon feature draw start - * @event ol.interaction.Draw.Event#drawstart + * @event module:ol/interaction/Draw~DrawEvent#drawstart * @api */ DRAWSTART: 'drawstart', /** * Triggered upon feature draw end - * @event ol.interaction.Draw.Event#drawend + * @event module:ol/interaction/Draw~DrawEvent#drawend * @api */ DRAWEND: 'drawend' @@ -63,13 +126,13 @@ const DrawEventType = { /** * @classdesc - * Events emitted by {@link ol.interaction.Draw} instances are instances of - * this type. + * Events emitted by {@link module:ol/interaction/Draw~Draw} instances are + * instances of this type. * * @constructor - * @extends {ol.events.Event} + * @extends {module:ol/events/Event~Event} * @implements {oli.DrawEvent} - * @param {ol.interaction.DrawEventType} type Type. + * @param {module:ol/interaction/Draw~DrawEventType} type Type. * @param {module:ol/Feature~Feature} feature The feature drawn. */ const DrawEvent = function(type, feature) { @@ -93,9 +156,9 @@ inherits(DrawEvent, Event); * Interaction for drawing feature geometries. * * @constructor - * @extends {ol.interaction.Pointer} - * @fires ol.interaction.DrawEvent - * @param {olx.interaction.DrawOptions} options Options. + * @extends {module:ol/interaction/Pointer~Pointer} + * @fires module:ol/interaction/Draw~DrawEvent + * @param {module:ol/interaction/Draw~Options} options Options. * @api */ const Draw = function(options) { @@ -138,14 +201,14 @@ const Draw = function(options) { /** * Target source for drawn features. - * @type {ol.source.Vector} + * @type {module:ol/source/Vector~Vector} * @private */ this.source_ = options.source ? options.source : null; /** * Target collection for drawn features. - * @type {ol.Collection.} + * @type {module:ol/Collection~Collection.} * @private */ this.features_ = options.features ? options.features : null; @@ -166,7 +229,7 @@ const Draw = function(options) { /** * Drawing mode (derived from geometry type. - * @type {ol.interaction.Mode} + * @type {module:ol/interaction/Draw~Mode} * @private */ this.mode_ = getMode(this.type_); @@ -260,7 +323,7 @@ const Draw = function(options) { } /** - * @type {ol.DrawGeometryFunctionType} + * @type {module:ol/interaction/Draw~GeometryFunction} * @private */ this.geometryFunction_ = geometryFunction; @@ -326,7 +389,7 @@ const Draw = function(options) { /** * Draw overlay where our sketch features are drawn. - * @type {ol.layer.Vector} + * @type {module:ol/layer/Vector~Vector} * @private */ this.overlay_ = new VectorLayer({ @@ -398,7 +461,7 @@ Draw.prototype.setMap = function(map) { * draw or finish the drawing. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} event Map browser event. * @return {boolean} `false` to stop event propagation. - * @this {ol.interaction.Draw} + * @this {module:ol/interaction/Draw~Draw} * @api */ export function handleEvent(event) { @@ -448,9 +511,9 @@ export function handleEvent(event) { /** - * @param {ol.MapBrowserPointerEvent} event Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event. * @return {boolean} Start drag sequence? - * @this {ol.interaction.Draw} + * @this {module:ol/interaction/Draw~Draw} */ function handleDownEvent(event) { this.shouldHandle_ = !this.freehand_; @@ -476,9 +539,9 @@ function handleDownEvent(event) { /** - * @param {ol.MapBrowserPointerEvent} event Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.Draw} + * @this {module:ol/interaction/Draw~Draw} */ function handleUpEvent(event) { let pass = true; @@ -764,8 +827,8 @@ Draw.prototype.removeLastPoint = function() { /** * Stop drawing and add the sketch feature to the target layer. - * The {@link ol.interaction.DrawEventType.DRAWEND} event is dispatched before - * inserting the feature. + * The {@link module:ol/interaction/Draw~DrawEventType.DRAWEND} event is + * dispatched before inserting the feature. * @api */ Draw.prototype.finishDrawing = function() { @@ -895,7 +958,7 @@ Draw.prototype.updateState_ = function() { * @param {number=} opt_angle Angle of the first point in radians. 0 means East. * Default is the angle defined by the heading from the center of the * regular polygon to the current pointer position. - * @return {ol.DrawGeometryFunctionType} Function that draws a + * @return {module:ol/interaction/Draw~GeometryFunction} Function that draws a * polygon. * @api */ @@ -921,7 +984,7 @@ export function createRegularPolygon(opt_sides, opt_angle) { * Create a `geometryFunction` that will create a box-shaped polygon (aligned * with the coordinate system axes). Use this with the draw interaction and * `type: 'Circle'` to return a box instead of a circle geometry. - * @return {ol.DrawGeometryFunctionType} Function that draws a box-shaped polygon. + * @return {module:ol/interaction/Draw~GeometryFunction} Function that draws a box-shaped polygon. * @api */ export function createBox() { @@ -946,7 +1009,7 @@ export function createBox() { * Get the drawing mode. The mode for mult-part geometries is the same as for * their single-part cousins. * @param {module:ol/geom/GeometryType~GeometryType} type Geometry type. - * @return {ol.interaction.Mode} Drawing mode. + * @return {module:ol/interaction/Draw~Mode} Drawing mode. */ function getMode(type) { let mode; @@ -962,7 +1025,7 @@ function getMode(type) { } else if (type === GeometryType.CIRCLE) { mode = Mode.CIRCLE; } - return /** @type {!ol.interaction.Mode} */ (mode); + return /** @type {!module:ol/interaction/Draw~Mode} */ (mode); } diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index bae4445dda..2b400dc76b 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -153,17 +153,6 @@ ol.CircleRenderOptions; ol.DeclutterGroup; -/** - * Function that takes an array of coordinates and an optional existing geometry as - * arguments, and returns a geometry. The optional existing geometry is the - * geometry that is returned when the function is called without a second - * argument. - * @typedef {function(!Array., module:ol/geom/SimpleGeometry~SimpleGeometry=): - * module:ol/geom/SimpleGeometry~SimpleGeometry} - */ -ol.DrawGeometryFunctionType; - - /** * @typedef {{x: number, xunits: (ol.style.IconAnchorUnits|undefined), * y: number, yunits: (ol.style.IconAnchorUnits|undefined), From 080a156f3febf9c88c45696c4886c8a5a9868d44 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 15 Mar 2018 18:04:19 +0100 Subject: [PATCH 09/24] No olx and ol types for ol/interaction/Extent --- externs/olx.js | 50 --------------------- externs/xol.js | 14 ------ src/ol/interaction/Extent.js | 64 +++++++++++++++++++-------- src/ol/interaction/ExtentEventType.js | 15 ------- 4 files changed, 46 insertions(+), 97 deletions(-) delete mode 100644 src/ol/interaction/ExtentEventType.js diff --git a/externs/olx.js b/externs/olx.js index ab415199de..b995059006 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,56 +5,6 @@ let olx; -/** - * @typedef {{extent: (ol.Extent|undefined), - * boxStyle: (ol.style.Style|Array.|ol.StyleFunction|undefined), - * pixelTolerance: (number|undefined), - * pointerStyle: (ol.style.Style|Array.|ol.StyleFunction|undefined), - * wrapX: (boolean|undefined)}} - * @api - */ -olx.interaction.ExtentOptions; - -/** - * Initial extent. Defaults to no initial extent - * @type {ol.Extent|undefined} - * @api - */ -olx.interaction.ExtentOptions.prototype.extent; - -/** - * Style for the drawn extent box. - * Defaults to ol.style.Style.createDefaultEditing()[module:ol/geom/GeometryType~GeometryType.POLYGON] - * @type {ol.style.Style|Array.|ol.StyleFunction|undefined} - * @api - */ -olx.interaction.ExtentOptions.prototype.boxStyle; - -/** - * Pixel tolerance for considering the pointer close enough to a segment or - * vertex for editing. Default is `10`. - * @type {number|undefined} - * @api - */ -olx.interaction.ExtentOptions.prototype.pixelTolerance; - -/** - * Style for the cursor used to draw the extent. - * Defaults to ol.style.Style.createDefaultEditing()[module:ol/geom/GeometryType~GeometryType.POINT] - * @type {ol.style.Style|Array.|ol.StyleFunction|undefined} - * @api - */ -olx.interaction.ExtentOptions.prototype.pointerStyle; - -/** - * Wrap the drawn extent across multiple maps in the X direction? - * Only affects visuals, not functionality. Defaults to false. - * @type {boolean|undefined} - * @api - */ -olx.interaction.ExtentOptions.prototype.wrapX; - - /** * @typedef {{ * features: (ol.Collection.|undefined), diff --git a/externs/xol.js b/externs/xol.js index c83167936d..e4a3039795 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,18 +1,4 @@ -/** - * @typedef {Object} interaction_ExtentOptions - * @property {ol.Extent|undefined} extent Initial extent. Defaults to no initial extent - * @property {ol.style.Style|Array.|ol.StyleFunction|undefined} boxStyle Style for the drawn extent box. - * Defaults to ol.style.Style.createDefaultEditing()[module:ol/geom/GeometryType~GeometryType.POLYGON] - * @property {number|undefined} pixelTolerance Pixel tolerance for considering the pointer close enough to a segment or - * vertex for editing. Default is `10`. - * @property {ol.style.Style|Array.|ol.StyleFunction|undefined} pointerStyle Style for the cursor used to draw the extent. - * Defaults to ol.style.Style.createDefaultEditing()[module:ol/geom/GeometryType~GeometryType.POINT] - * @property {boolean|undefined} wrapX Wrap the drawn extent across multiple maps in the X direction? - * Only affects visuals, not functionality. Defaults to false. - */ - - /** * @typedef {Object} interaction_TranslateOptions * @property {ol.Collection.|undefined} features Only features contained in this collection will be able to be translated. If diff --git a/src/ol/interaction/Extent.js b/src/ol/interaction/Extent.js index b6fb0903ed..02eaa0bedd 100644 --- a/src/ol/interaction/Extent.js +++ b/src/ol/interaction/Extent.js @@ -11,22 +11,51 @@ import {boundingExtent, getArea} from '../extent.js'; import GeometryType from '../geom/GeometryType.js'; import Point from '../geom/Point.js'; import {fromExtent as polygonFromExtent} from '../geom/Polygon.js'; -import ExtentEventType from '../interaction/ExtentEventType.js'; import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js'; import VectorLayer from '../layer/Vector.js'; import VectorSource from '../source/Vector.js'; import {createEditingStyle} from '../style/Style.js'; +/** + * @typedef {Object} Options + * @property {module:ol/extent~Extent} [extent] Initial extent. Defaults to no + * initial extent. + * @property {module:ol/style/Style~Style|Array.|module:ol/style~StyleFunction} [boxStyle] + * Style for the drawn extent box. Defaults to + * {@link module:ol/style/Style~createEditing()[module:ol/geom/GeometryType~GeometryType.POLYGON]} + * @property {number} [pixelTolerance=10] Pixel tolerance for considering the + * pointer close enough to a segment or vertex for editing. + * @property {module:ol/style/Style~Style|Array.|module:ol/style~StyleFunction} [pointerStyle] + * Style for the cursor used to draw the extent. Defaults to + * {@link module:ol/style/Style~createEditing()[module:ol/geom/GeometryType~GeometryType.POINT]} + * @property {boolean} [wrapX=false] Wrap the drawn extent across multiple maps + * in the X direction? Only affects visuals, not functionality. + */ + + + /** + * @enum {string} + */ + const ExtentEventType = { + /** + * Triggered after the extent is changed + * @event module:ol/interaction/Extent~ExtentEventType#extentchanged + * @api + */ + EXTENTCHANGED: 'extentchanged' + }; + + /** * @classdesc - * Events emitted by {@link ol.interaction.Extent} instances are instances of - * this type. + * Events emitted by {@link module:ol/interaction/Extent~Extent} instances are + * instances of this type. * * @constructor * @implements {oli.ExtentEvent} * @param {module:ol/extent~Extent} extent the new extent - * @extends {ol.events.Event} + * @extends {module:ol/events/Event~Event} */ const ExtentInteractionEvent = function(extent) { Event.call(this, ExtentEventType.EXTENTCHANGED); @@ -49,9 +78,9 @@ inherits(ExtentInteractionEvent, Event); * This interaction is only supported for mouse devices. * * @constructor - * @extends {ol.interaction.Pointer} - * @fires ol.interaction.Extent.Event - * @param {olx.interaction.ExtentOptions=} opt_options Options. + * @extends {module:ol/interaction/Pointer~Pointer} + * @fires module:ol/interaction/Extent~Event + * @param {ol/interaction/Extent~Options=} opt_options Options. * @api */ const ExtentInteraction = function(opt_options) { @@ -105,7 +134,6 @@ const ExtentInteraction = function(opt_options) { opt_options = {}; } - /* Inherit ol.interaction.Pointer */ PointerInteraction.call(this, { handleDownEvent: handleDownEvent, handleDragEvent: handleDragEvent, @@ -115,7 +143,7 @@ const ExtentInteraction = function(opt_options) { /** * Layer for the extentFeature - * @type {ol.layer.Vector} + * @type {module:ol/layer/Vector~Vector} * @private */ this.extentOverlay_ = new VectorLayer({ @@ -130,7 +158,7 @@ const ExtentInteraction = function(opt_options) { /** * Layer for the vertexFeature - * @type {ol.layer.Vector} + * @type {module:ol/layer/Vector~Vector} * @private */ this.vertexOverlay_ = new VectorLayer({ @@ -153,7 +181,7 @@ inherits(ExtentInteraction, PointerInteraction); /** * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Event. * @return {boolean} Propagate event? - * @this {ol.interaction.Extent} + * @this {module:ol/interaction/Extent~Extent} */ function handleEvent(mapBrowserEvent) { if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) { @@ -170,9 +198,9 @@ function handleEvent(mapBrowserEvent) { } /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Event handled? - * @this {ol.interaction.Extent} + * @this {module:ol/interaction/Extent~Extent} */ function handleDownEvent(mapBrowserEvent) { const pixel = mapBrowserEvent.pixel; @@ -229,9 +257,9 @@ function handleDownEvent(mapBrowserEvent) { } /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Event handled? - * @this {ol.interaction.Extent} + * @this {module:ol/interaction/Extent~Extent} */ function handleDragEvent(mapBrowserEvent) { if (this.pointerHandler_) { @@ -243,9 +271,9 @@ function handleDragEvent(mapBrowserEvent) { } /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.Extent} + * @this {module:ol/interaction/Extent~Extent} */ function handleUpEvent(mapBrowserEvent) { this.pointerHandler_ = null; @@ -325,7 +353,7 @@ function getSegments(extent) { /** * @param {module:ol~Pixel} pixel cursor location - * @param {ol.PluggableMap} map map + * @param {module:ol/PluggableMap~PluggableMap} map map * @returns {module:ol/coordinate~Coordinate|null} snapped vertex on extent * @private */ diff --git a/src/ol/interaction/ExtentEventType.js b/src/ol/interaction/ExtentEventType.js deleted file mode 100644 index 5602a26d35..0000000000 --- a/src/ol/interaction/ExtentEventType.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @module ol/interaction/ExtentEventType - */ - -/** - * @enum {string} - */ -export default { - /** - * Triggered after the extent is changed - * @event ol.interaction.Extent.Event#extentchanged - * @api - */ - EXTENTCHANGED: 'extentchanged' -}; From edf65366454786e61ebd238c565f73d53e918f2e Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 15 Mar 2018 18:09:01 +0100 Subject: [PATCH 10/24] Remove ununed namespace doc file --- src/ol/interaction/interaction.jsdoc | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 src/ol/interaction/interaction.jsdoc diff --git a/src/ol/interaction/interaction.jsdoc b/src/ol/interaction/interaction.jsdoc deleted file mode 100644 index 6da0d140d4..0000000000 --- a/src/ol/interaction/interaction.jsdoc +++ /dev/null @@ -1,3 +0,0 @@ -/** - * @namespace ol.interaction - */ From a4a4a0cdcad9aa936b2eca901ff5ad32d5e55916 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 15:35:11 +0100 Subject: [PATCH 11/24] No olx and ol types for ol/interaction/KeyboardPan --- externs/olx.js | 35 ------------------------------- externs/xol.js | 11 ---------- src/ol/interaction/KeyboardPan.js | 28 ++++++++++++++++++------- 3 files changed, 21 insertions(+), 53 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index b995059006..26151c997c 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -46,41 +46,6 @@ olx.interaction.TranslateOptions.prototype.layers; olx.interaction.TranslateOptions.prototype.hitTolerance; -/** - * @typedef {{condition: (ol.EventsConditionType|undefined), - * duration: (number|undefined), - * pixelDelta: (number|undefined)}} - */ -olx.interaction.KeyboardPanOptions; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.noModifierKeys} and - * {@link ol.events.condition.targetNotEditable}. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.KeyboardPanOptions.prototype.condition; - - -/** - * Animation duration in milliseconds. Default is `100`. - * @type {number|undefined} - * @api - */ -olx.interaction.KeyboardPanOptions.prototype.duration; - - -/** - * Pixel The amount to pan on each key press. Default is `128` pixels. - * @type {number|undefined} - * @api - */ -olx.interaction.KeyboardPanOptions.prototype.pixelDelta; - - /** * @typedef {{duration: (number|undefined), * condition: (ol.EventsConditionType|undefined), diff --git a/externs/xol.js b/externs/xol.js index e4a3039795..dde9189e32 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -14,17 +14,6 @@ */ -/** - * @typedef {Object} interaction_KeyboardPanOptions - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.noModifierKeys} and - * {@link ol.events.condition.targetNotEditable}. - * @property {number|undefined} duration Animation duration in milliseconds. Default is `100`. - * @property {number|undefined} pixelDelta Pixel The amount to pan on each key press. Default is `128` pixels. - */ - - /** * @typedef {Object} interaction_KeyboardZoomOptions * @property {number|undefined} duration Animation duration in milliseconds. Default is `100`. diff --git a/src/ol/interaction/KeyboardPan.js b/src/ol/interaction/KeyboardPan.js index 867e4219a6..74510f73a0 100644 --- a/src/ol/interaction/KeyboardPan.js +++ b/src/ol/interaction/KeyboardPan.js @@ -8,6 +8,20 @@ import KeyCode from '../events/KeyCode.js'; import {noModifierKeys, targetNotEditable} from '../events/condition.js'; import Interaction, {pan} from '../interaction/Interaction.js'; + +/** + * @typedef {Object} Options + * @property {module:ol/events/condition~Condition} [condition] A function that + * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. Default is + * {@link module:ol/events/condition~noModifierKeys} and + * {@link module:ol/events/condition~targetNotEditable}. + * @property {number} [duration=100] Animation duration in milliseconds. + * @property {number} [pixelDelta=128] The amount of pixels to pan on each key + * press. + */ + + /** * @classdesc * Allows the user to pan the map using keyboard arrows. @@ -15,14 +29,14 @@ import Interaction, {pan} from '../interaction/Interaction.js'; * the keys can only be used when browser focus is on the element to which * the keyboard events are attached. By default, this is the map div, * though you can change this with the `keyboardEventTarget` in - * {@link ol.Map}. `document` never loses focus but, for any other element, - * focus will have to be on, and returned to, this element if the keys are to - * function. - * See also {@link ol.interaction.KeyboardZoom}. + * {@link module:ol/Map~Map}. `document` never loses focus but, for any other + * element, focus will have to be on, and returned to, this element if the keys + * are to function. + * See also {@link module:ol/interaction/KeyboardZoom~KeyboardZoom}. * * @constructor - * @extends {ol.interaction.Interaction} - * @param {olx.interaction.KeyboardPanOptions=} opt_options Options. + * @extends {module:ol/interaction/Interaction~Interaction} + * @param {module:ol/interaction/KeyboardPan~Options=} opt_options Options. * @api */ const KeyboardPan = function(opt_options) { @@ -73,7 +87,7 @@ inherits(KeyboardPan, Interaction); * pressed). * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @return {boolean} `false` to stop event propagation. - * @this {ol.interaction.KeyboardPan} + * @this {module:ol/interaction/KeyboardPan~KeyboardPan} */ function handleEvent(mapBrowserEvent) { let stopEvent = false; From 438ec66c4caaed640b5b4f87f39012b2fcc7a358 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 15:46:47 +0100 Subject: [PATCH 12/24] No olx and ol types for ol/interaction/KeyboardZoom --- externs/olx.js | 34 ------------------------------ externs/xol.js | 10 --------- src/ol/interaction/KeyboardZoom.js | 28 +++++++++++++++++------- 3 files changed, 20 insertions(+), 52 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 26151c997c..3431002110 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -46,40 +46,6 @@ olx.interaction.TranslateOptions.prototype.layers; olx.interaction.TranslateOptions.prototype.hitTolerance; -/** - * @typedef {{duration: (number|undefined), - * condition: (ol.EventsConditionType|undefined), - * delta: (number|undefined)}} - */ -olx.interaction.KeyboardZoomOptions; - - -/** - * Animation duration in milliseconds. Default is `100`. - * @type {number|undefined} - * @api - */ -olx.interaction.KeyboardZoomOptions.prototype.duration; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.targetNotEditable}. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.KeyboardZoomOptions.prototype.condition; - - -/** - * The amount to zoom on each key press. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.interaction.KeyboardZoomOptions.prototype.delta; - - /** * @typedef {{ * condition: (ol.EventsConditionType|undefined), diff --git a/externs/xol.js b/externs/xol.js index dde9189e32..37ea9fe5f0 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -14,16 +14,6 @@ */ -/** - * @typedef {Object} interaction_KeyboardZoomOptions - * @property {number|undefined} duration Animation duration in milliseconds. Default is `100`. - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * Default is {@link ol.events.condition.targetNotEditable}. - * @property {number|undefined} delta The amount to zoom on each key press. Default is `1`. - */ - - /** * @typedef {Object} interaction_ModifyOptions * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean diff --git a/src/ol/interaction/KeyboardZoom.js b/src/ol/interaction/KeyboardZoom.js index 8051046db3..830ea94e71 100644 --- a/src/ol/interaction/KeyboardZoom.js +++ b/src/ol/interaction/KeyboardZoom.js @@ -6,6 +6,18 @@ import EventType from '../events/EventType.js'; import {targetNotEditable} from '../events/condition.js'; import Interaction, {zoomByDelta} from '../interaction/Interaction.js'; + +/** + * @typedef {Object} Options + * @property {number} [duration=100] Animation duration in milliseconds. + * @property {module:ol/events/condition~Condition} [condition] A function that + * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. Default is + * {@link module:ol/events/condition~targetNotEditable}. + * @property {number} [delta=1] The zoom level delta on each key press. + */ + + /** * @classdesc * Allows the user to zoom the map using keyboard + and -. @@ -13,14 +25,14 @@ import Interaction, {zoomByDelta} from '../interaction/Interaction.js'; * the keys can only be used when browser focus is on the element to which * the keyboard events are attached. By default, this is the map div, * though you can change this with the `keyboardEventTarget` in - * {@link ol.Map}. `document` never loses focus but, for any other element, - * focus will have to be on, and returned to, this element if the keys are to - * function. - * See also {@link ol.interaction.KeyboardPan}. + * {@link module:ol/Map~Map}. `document` never loses focus but, for any other + * element, focus will have to be on, and returned to, this element if the keys + * are to function. + * See also {@link moudle:ol/interaction/KeyboardPan~KeyboardPan}. * * @constructor - * @param {olx.interaction.KeyboardZoomOptions=} opt_options Options. - * @extends {ol.interaction.Interaction} + * @param {module:ol/interaction/KeyboardZoom~Options=} opt_options Options. + * @extends {module:ol/interaction/Interaction~Interaction} * @api */ const KeyboardZoom = function(opt_options) { @@ -33,7 +45,7 @@ const KeyboardZoom = function(opt_options) { /** * @private - * @type {ol.EventsConditionType} + * @type {module:ol/events/condition~Condition} */ this.condition_ = options.condition ? options.condition : targetNotEditable; @@ -60,7 +72,7 @@ inherits(KeyboardZoom, Interaction); * key pressed was '+' or '-'). * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @return {boolean} `false` to stop event propagation. - * @this {ol.interaction.KeyboardZoom} + * @this {module:ol/interaction/KeyboardZoom~KeyboardZoom} */ function handleEvent(mapBrowserEvent) { let stopEvent = false; From d6b177e847c94b748ea0523418036ff8822e179e Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 16:30:00 +0100 Subject: [PATCH 13/24] No olx and ol types for ol/interaction/Modify --- externs/olx.js | 91 ----------------------- externs/xol.js | 25 ------- src/ol/interaction/Modify.js | 138 +++++++++++++++++++++++------------ src/ol/typedefs.js | 11 --- 4 files changed, 91 insertions(+), 174 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 3431002110..f63dc86ff3 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -46,97 +46,6 @@ olx.interaction.TranslateOptions.prototype.layers; olx.interaction.TranslateOptions.prototype.hitTolerance; -/** - * @typedef {{ - * condition: (ol.EventsConditionType|undefined), - * deleteCondition: (ol.EventsConditionType|undefined), - * insertVertexCondition: (ol.EventsConditionType|undefined), - * pixelTolerance: (number|undefined), - * style: (ol.style.Style|Array.|ol.StyleFunction|undefined), - * source: (ol.source.Vector|undefined), - * features: (ol.Collection.|undefined), - * wrapX: (boolean|undefined) - * }} - */ -olx.interaction.ModifyOptions; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event will be considered to add or move a vertex - * to the sketch. - * Default is {@link ol.events.condition.primaryAction}. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.ModifyOptions.prototype.condition; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * By default, {@link ol.events.condition.singleClick} with - * {@link ol.events.condition.altKeyOnly} results in a vertex deletion. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.ModifyOptions.prototype.deleteCondition; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether a new vertex can be added to the sketch features. - * Default is {@link ol.events.condition.always} - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.ModifyOptions.prototype.insertVertexCondition; - - -/** - * Pixel tolerance for considering the pointer close enough to a segment or - * vertex for editing. Default is `10`. - * @type {number|undefined} - * @api - */ -olx.interaction.ModifyOptions.prototype.pixelTolerance; - - -/** - * Style used for the features being modified. By default the default edit - * style is used (see {@link ol.style}). - * @type {ol.style.Style|Array.|ol.StyleFunction|undefined} - * @api - */ -olx.interaction.ModifyOptions.prototype.style; - - -/** - * The vector source with features to modify. If a vector source is not - * provided, a feature collection must be provided with the features option. - * @type {ol.source.Vector|undefined} - * @api - */ -olx.interaction.ModifyOptions.prototype.source; - - -/** - * The features the interaction works on. If a feature collection is not - * provided, a vector source must be provided with the source option. - * @type {ol.Collection.|undefined} - * @api - */ -olx.interaction.ModifyOptions.prototype.features; - - -/** - * Wrap the world horizontally on the sketch overlay. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.interaction.ModifyOptions.prototype.wrapX; - - /** * @typedef {{constrainResolution: (boolean|undefined), * condition: (ol.EventsConditionType|undefined), diff --git a/externs/xol.js b/externs/xol.js index 37ea9fe5f0..ef9417d8d9 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -14,31 +14,6 @@ */ -/** - * @typedef {Object} interaction_ModifyOptions - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event will be considered to add or move a vertex - * to the sketch. - * Default is {@link ol.events.condition.primaryAction}. - * @property {ol.EventsConditionType|undefined} deleteCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * By default, {@link ol.events.condition.singleClick} with - * {@link ol.events.condition.altKeyOnly} results in a vertex deletion. - * @property {ol.EventsConditionType|undefined} insertVertexCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether a new vertex can be added to the sketch features. - * Default is {@link ol.events.condition.always} - * @property {number|undefined} pixelTolerance Pixel tolerance for considering the pointer close enough to a segment or - * vertex for editing. Default is `10`. - * @property {ol.style.Style|Array.|ol.StyleFunction|undefined} style Style used for the features being modified. By default the default edit - * style is used (see {@link ol.style}). - * @property {ol.source.Vector|undefined} source The vector source with features to modify. If a vector source is not - * provided, a feature collection must be provided with the features option. - * @property {ol.Collection.|undefined} features The features the interaction works on. If a feature collection is not - * provided, a vector source must be provided with the source option. - * @property {boolean|undefined} wrapX Wrap the world horizontally on the sketch overlay. Default is `false`. - */ - - /** * @typedef {Object} interaction_MouseWheelZoomOptions * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean diff --git a/src/ol/interaction/Modify.js b/src/ol/interaction/Modify.js index 84c0e8222a..e558adb12c 100644 --- a/src/ol/interaction/Modify.js +++ b/src/ol/interaction/Modify.js @@ -43,18 +43,62 @@ const ModifyEventType = { }; +/** + * @typedef {Object} SegmentData + * @property {Array.} [depth] + * @property {module:ol/Feature~Feature} feature + * @property {module:ol/geom/SimpleGeometry~SimpleGeometry} geometry + * @property {number} index + * @property {Array.} segment + * @property {Array.} [featureSegments] + */ + + +/** + * @typedef {Object} Options + * @property {module:ol/events/condition~Condition} [condition] A function that + * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event will be considered to add or move a + * vertex to the sketch. Default is + * {@link module:ol/events/condition~primaryAction}. + * @property {module:ol/events/condition~Condition} [deleteCondition] A function + * that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. By default, + * {@link module:ol/events/condition~singleClick} with + * {@link module:ol/events/condition~altKeyOnly} results in a vertex deletion. + * @property {module:ol/events/condition~Condition} [insertVertexCondition] A + * function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and + * returns a boolean to indicate whether a new vertex can be added to the sketch + * features. Default is {@link module:ol/events/condition~always}. + * @property {number} [pixelTolerance=10] Pixel tolerance for considering the + * pointer close enough to a segment or vertex for editing. + * @property {module:ol/style/Style~Style|Array.|module:ol/style~StyleFunction} [style] + * Style used for the features being modified. By default the default edit + * style is used (see {@link module:ol/style}). + * @property {module:ol/source/Vector~Vector} [source] The vector source with + * features to modify. If a vector source is not provided, a feature collection + * must be provided with the features option. + * @property {module:ol/Collection~Collection.} [features] + * The features the interaction works on. If a feature collection is not + * provided, a vector source must be provided with the source option. + * @property {boolean} [wrapX=false] Wrap the world horizontally on the sketch + * overlay. + */ + + /** * @classdesc - * Events emitted by {@link ol.interaction.Modify} instances are instances of - * this type. + * Events emitted by {@link module:ol/interaction/Modify~Modify} instances are + * instances of this type. * * @constructor - * @extends {ol.events.Event} + * @extends {module:ol/events/Event~Event} * @implements {oli.ModifyEvent} * @param {ModifyEventType} type Type. - * @param {ol.Collection.} features The features modified. - * @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated - * {@link ol.MapBrowserPointerEvent}. + * @param {module:ol/Collection~Collection.} features + * The features modified. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserPointerEvent + * Associated {@link module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent}. */ export const ModifyEvent = function(type, features, mapBrowserPointerEvent) { @@ -62,7 +106,7 @@ export const ModifyEvent = function(type, features, mapBrowserPointerEvent) { /** * The features being modified. - * @type {ol.Collection.} + * @type {module:ol/Collection~Collection.} * @api */ this.features = features; @@ -92,9 +136,9 @@ inherits(ModifyEvent, Event); * for deletion, use the `deleteCondition` option. * * @constructor - * @extends {ol.interaction.Pointer} - * @param {olx.interaction.ModifyOptions} options Options. - * @fires ol.interaction.ModifyEvent + * @extends {module:ol/interaction/Pointer~Pointer} + * @param {module:ol/interaction/Modify~Options} options Options. + * @fires module:ol/interaction/Modify~ModifyEvent * @api */ const Modify = function(options) { @@ -172,7 +216,7 @@ const Modify = function(options) { /** * Segment RTree for each layer - * @type {ol.structs.RBush.} + * @type {module:ol/structs/RBush~RBush.} * @private */ this.rBush_ = new RBush(); @@ -206,7 +250,7 @@ const Modify = function(options) { /** * Draw overlay where sketch features are drawn. - * @type {ol.layer.Vector} + * @type {module:ol/layer/Vector~Vector} * @private */ this.overlay_ = new VectorLayer({ @@ -239,7 +283,7 @@ const Modify = function(options) { /** - * @type {ol.source.Vector} + * @type {module:ol/source/Vector~Vector} * @private */ this.source_ = null; @@ -260,7 +304,7 @@ const Modify = function(options) { } /** - * @type {ol.Collection.} + * @type {module:ol/Collection~Collection.} * @private */ this.features_ = features; @@ -272,7 +316,7 @@ const Modify = function(options) { this.handleFeatureRemove_, this); /** - * @type {ol.MapBrowserPointerEvent} + * @type {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} * @private */ this.lastPointerEvent_ = null; @@ -316,7 +360,7 @@ Modify.prototype.addFeature_ = function(feature) { /** - * @param {ol.MapBrowserPointerEvent} evt Map browser event + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Map browser event * @private */ Modify.prototype.willModifyFeatures_ = function(evt) { @@ -351,10 +395,10 @@ Modify.prototype.removeFeature_ = function(feature) { */ Modify.prototype.removeFeatureSegmentData_ = function(feature) { const rBush = this.rBush_; - const /** @type {Array.} */ nodesToRemove = []; + const /** @type {Array.} */ nodesToRemove = []; rBush.forEach( /** - * @param {ol.ModifySegmentDataType} node RTree node. + * @param {module:ol/interaction/Modify~SegmentData} node RTree node. */ function(node) { if (feature === node.feature) { @@ -389,7 +433,7 @@ Modify.prototype.setMap = function(map) { /** - * @param {ol.source.Vector.Event} event Event. + * @param {module:ol/source/Vector~VectorSourceEvent} event Event. * @private */ Modify.prototype.handleSourceAdd_ = function(event) { @@ -400,7 +444,7 @@ Modify.prototype.handleSourceAdd_ = function(event) { /** - * @param {ol.source.Vector.Event} event Event. + * @param {module:ol/source/Vector~VectorSourceEvent} event Event. * @private */ Modify.prototype.handleSourceRemove_ = function(event) { @@ -411,7 +455,7 @@ Modify.prototype.handleSourceRemove_ = function(event) { /** - * @param {ol.CollectionEvent} evt Event. + * @param {module:ol/Collection~CollectionEvent} evt Event. * @private */ Modify.prototype.handleFeatureAdd_ = function(evt) { @@ -420,7 +464,7 @@ Modify.prototype.handleFeatureAdd_ = function(evt) { /** - * @param {ol.events.Event} evt Event. + * @param {module:ol/events/Event~Event} evt Event. * @private */ Modify.prototype.handleFeatureChange_ = function(evt) { @@ -433,7 +477,7 @@ Modify.prototype.handleFeatureChange_ = function(evt) { /** - * @param {ol.CollectionEvent} evt Event. + * @param {module:ol/Collection~CollectionEvent} evt Event. * @private */ Modify.prototype.handleFeatureRemove_ = function(evt) { @@ -449,7 +493,7 @@ Modify.prototype.handleFeatureRemove_ = function(evt) { */ Modify.prototype.writePointGeometry_ = function(feature, geometry) { const coordinates = geometry.getCoordinates(); - const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ feature: feature, geometry: geometry, segment: [coordinates, coordinates] @@ -467,7 +511,7 @@ Modify.prototype.writeMultiPointGeometry_ = function(feature, geometry) { const points = geometry.getCoordinates(); for (let i = 0, ii = points.length; i < ii; ++i) { const coordinates = points[i]; - const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ feature: feature, geometry: geometry, depth: [i], @@ -488,7 +532,7 @@ Modify.prototype.writeLineStringGeometry_ = function(feature, geometry) { const coordinates = geometry.getCoordinates(); for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { const segment = coordinates.slice(i, i + 2); - const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ feature: feature, geometry: geometry, index: i, @@ -510,7 +554,7 @@ Modify.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) { const coordinates = lines[j]; for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { const segment = coordinates.slice(i, i + 2); - const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ feature: feature, geometry: geometry, depth: [j], @@ -534,7 +578,7 @@ Modify.prototype.writePolygonGeometry_ = function(feature, geometry) { const coordinates = rings[j]; for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { const segment = coordinates.slice(i, i + 2); - const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ feature: feature, geometry: geometry, depth: [j], @@ -560,7 +604,7 @@ Modify.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) { const coordinates = rings[j]; for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { const segment = coordinates.slice(i, i + 2); - const segmentData = /** @type {ol.ModifySegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ feature: feature, geometry: geometry, depth: [j, k], @@ -587,13 +631,13 @@ Modify.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) { */ Modify.prototype.writeCircleGeometry_ = function(feature, geometry) { const coordinates = geometry.getCenter(); - const centerSegmentData = /** @type {ol.ModifySegmentDataType} */ ({ + const centerSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ feature: feature, geometry: geometry, index: CIRCLE_CENTER_INDEX, segment: [coordinates, coordinates] }); - const circumferenceSegmentData = /** @type {ol.ModifySegmentDataType} */ ({ + const circumferenceSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ feature: feature, geometry: geometry, index: CIRCLE_CIRCUMFERENCE_INDEX, @@ -639,8 +683,8 @@ Modify.prototype.createOrUpdateVertexFeature_ = function(coordinates) { /** - * @param {ol.ModifySegmentDataType} a The first segment data. - * @param {ol.ModifySegmentDataType} b The second segment data. + * @param {module:ol/interaction/Modify~SegmentData} a The first segment data. + * @param {module:ol/interaction/Modify~SegmentData} b The second segment data. * @return {number} The difference in indexes. */ function compareIndexes(a, b) { @@ -649,9 +693,9 @@ function compareIndexes(a, b) { /** - * @param {ol.MapBrowserPointerEvent} evt Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Event. * @return {boolean} Start drag sequence? - * @this {ol.interaction.Modify} + * @this {module:ol/interaction/Modify~Modify} */ function handleDownEvent(evt) { if (!this.condition_(evt)) { @@ -725,8 +769,8 @@ function handleDownEvent(evt) { /** - * @param {ol.MapBrowserPointerEvent} evt Event. - * @this {ol.interaction.Modify} + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Event. + * @this {module:ol/interaction/Modify~Modify} */ function handleDragEvent(evt) { this.ignoreNextSingleClick_ = false; @@ -801,9 +845,9 @@ function handleDragEvent(evt) { /** - * @param {ol.MapBrowserPointerEvent} evt Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.Modify} + * @this {module:ol/interaction/Modify~Modify} */ function handleUpEvent(evt) { for (let i = this.dragSegments_.length - 1; i >= 0; --i) { @@ -835,7 +879,7 @@ function handleUpEvent(evt) { * geometry. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @return {boolean} `false` to stop event propagation. - * @this {ol.interaction.Modify} + * @this {module:ol/interaction/Modify~Modify} */ function handleEvent(mapBrowserEvent) { if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) { @@ -877,7 +921,7 @@ Modify.prototype.handlePointerMove_ = function(evt) { /** * @param {module:ol~Pixel} pixel Pixel - * @param {ol.PluggableMap} map Map. + * @param {module:ol/PluggableMap~PluggableMap} map Map. * @private */ Modify.prototype.handlePointerAtPixel_ = function(pixel, map) { @@ -948,7 +992,7 @@ Modify.prototype.handlePointerAtPixel_ = function(pixel, map) { * * @param {module:ol/coordinate~Coordinate} pointCoordinates The coordinates of the point from * which to calculate the distance. - * @param {ol.ModifySegmentDataType} segmentData The object describing the line + * @param {module:ol/interaction/Modify~SegmentData} segmentData The object describing the line * segment we are calculating the distance to. * @return {number} The square of the distance between a point and a line segment. */ @@ -974,7 +1018,7 @@ function pointDistanceToSegmentDataSquared(pointCoordinates, segmentData) { * * @param {module:ol/coordinate~Coordinate} pointCoordinates The point to which a closest point * should be found. - * @param {ol.ModifySegmentDataType} segmentData The object describing the line + * @param {module:ol/interaction/Modify~SegmentData} segmentData The object describing the line * segment which should contain the closest point. * @return {module:ol/coordinate~Coordinate} The point closest to the specified line segment. */ @@ -990,7 +1034,7 @@ function closestOnSegmentData(pointCoordinates, segmentData) { /** - * @param {ol.ModifySegmentDataType} segmentData Segment data. + * @param {module:ol/interaction/Modify~SegmentData} segmentData Segment data. * @param {module:ol/coordinate~Coordinate} vertex Vertex. * @private */ @@ -1031,7 +1075,7 @@ Modify.prototype.insertVertex_ = function(segmentData, vertex) { const rTree = this.rBush_; rTree.remove(segmentData); this.updateSegmentIndices_(geometry, index, depth, 1); - const newSegmentData = /** @type {ol.ModifySegmentDataType} */ ({ + const newSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ segment: [segment[0], vertex], feature: feature, geometry: geometry, @@ -1042,7 +1086,7 @@ Modify.prototype.insertVertex_ = function(segmentData, vertex) { newSegmentData); this.dragSegments_.push([newSegmentData, 1]); - const newSegmentData2 = /** @type {ol.ModifySegmentDataType} */ ({ + const newSegmentData2 = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ segment: [vertex, segment[1]], feature: feature, geometry: geometry, @@ -1167,7 +1211,7 @@ Modify.prototype.removeVertex_ = function() { segments.push(right.segment[1]); } if (left !== undefined && right !== undefined) { - const newSegmentData = /** @type {ol.ModifySegmentDataType} */ ({ + const newSegmentData = /** @type {module:ol/interaction/Modify~SegmentData} */ ({ depth: segmentData.depth, feature: segmentData.feature, geometry: segmentData.geometry, diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 2b400dc76b..960dd8711d 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -201,17 +201,6 @@ ol.LoadingStrategy; ol.LRUCacheEntry; -/** - * @typedef {{depth: (Array.|undefined), - * feature: module:ol/Feature~Feature, - * geometry: module:ol/geom/SimpleGeometry~SimpleGeometry, - * index: (number), - * segment: Array., - * featureSegments: (Array.|undefined)}} - */ -ol.ModifySegmentDataType; - - /** * A function that takes an array of input data, performs some operation, and * returns an array of output data. From 54beb17b55e251c38969733813125acaffa474c7 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 16:35:39 +0100 Subject: [PATCH 14/24] No olx and ol types for ol/interaction/MouseWheelZoom --- externs/olx.js | 55 ---------------------------- externs/xol.js | 15 -------- src/ol/interaction/MouseWheelZoom.js | 27 +++++++++++--- 3 files changed, 22 insertions(+), 75 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index f63dc86ff3..91049d7314 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -46,61 +46,6 @@ olx.interaction.TranslateOptions.prototype.layers; olx.interaction.TranslateOptions.prototype.hitTolerance; -/** - * @typedef {{constrainResolution: (boolean|undefined), - * condition: (ol.EventsConditionType|undefined), - * duration: (number|undefined), - * timeout: (number|undefined), - * useAnchor: (boolean|undefined)}} - */ -olx.interaction.MouseWheelZoomOptions; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. Default is {@link ol.events.condition.always}. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.MouseWheelZoomOptions.prototype.condition; - - -/** - * Animation duration in milliseconds. Default is `250`. - * @type {number|undefined} - * @api - */ -olx.interaction.MouseWheelZoomOptions.prototype.duration; - - -/** - * Mouse wheel timeout duration in milliseconds. Default is `80`. - * @type {number|undefined} - * @api - */ -olx.interaction.MouseWheelZoomOptions.prototype.timeout; - - -/** - * When using a trackpad or magic mouse, zoom to the closest integer zoom level - * after the scroll gesture ends. - * Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.interaction.MouseWheelZoomOptions.prototype.constrainResolution; - - -/** - * Enable zooming using the mouse's location as the anchor. Default is `true`. - * When set to false, zooming in and out will zoom to the center of the screen - * instead of zooming on the mouse's location. - * @type {boolean|undefined} - * @api - */ -olx.interaction.MouseWheelZoomOptions.prototype.useAnchor; - - /** * @typedef {{threshold: (number|undefined), * duration: (number|undefined)}} diff --git a/externs/xol.js b/externs/xol.js index ef9417d8d9..7b38e3eedd 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -14,21 +14,6 @@ */ -/** - * @typedef {Object} interaction_MouseWheelZoomOptions - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. Default is {@link ol.events.condition.always}. - * @property {number|undefined} duration Animation duration in milliseconds. Default is `250`. - * @property {number|undefined} timeout Mouse wheel timeout duration in milliseconds. Default is `80`. - * @property {boolean|undefined} constrainResolution When using a trackpad or magic mouse, zoom to the closest integer zoom level - * after the scroll gesture ends. - * Default is `false`. - * @property {boolean|undefined} useAnchor Enable zooming using the mouse's location as the anchor. Default is `true`. - * When set to false, zooming in and out will zoom to the center of the screen - * instead of zooming on the mouse's location. - */ - - /** * @typedef {Object} interaction_PinchRotateOptions * @property {number|undefined} duration The duration of the animation in milliseconds. Default is `250`. diff --git a/src/ol/interaction/MouseWheelZoom.js b/src/ol/interaction/MouseWheelZoom.js index cc8949cbe9..28d49211e0 100644 --- a/src/ol/interaction/MouseWheelZoom.js +++ b/src/ol/interaction/MouseWheelZoom.js @@ -27,13 +27,30 @@ export const Mode = { }; +/** + * @typedef {Object} Options + * @property {module:ol/events/condition~Condition} [condition] A function that + * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. Default is + * {@link module:ol/events/condition~always}. + * @property {number} [duration=250] Animation duration in milliseconds. + * @property {number} [timeout=80] Mouse wheel timeout duration in milliseconds. + * @property {boolean} [constrainResolution=false] When using a trackpad or + * magic mouse, zoom to the closest integer zoom level after the scroll gesture + * ends. + * @property {boolean} [useAnchor=true] Enable zooming using the mouse's + * location as the anchor. When set to `false`, zooming in and out will zoom to + * the center of the screen instead of zooming on the mouse's location. + */ + + /** * @classdesc * Allows the user to zoom the map by scrolling the mouse wheel. * * @constructor - * @extends {ol.interaction.Interaction} - * @param {olx.interaction.MouseWheelZoomOptions=} opt_options Options. + * @extends {module:ol/interaction/Interaction~Interaction} + * @param {module:olx/interaction/MouseWheelZoom~Options=} opt_options Options. * @api */ const MouseWheelZoom = function(opt_options) { @@ -100,7 +117,7 @@ const MouseWheelZoom = function(opt_options) { /** * @private - * @type {ol.interaction.Mode|undefined} + * @type {module:ol/interaction/MouseWheelZoom~Mode|undefined} */ this.mode_ = undefined; @@ -140,7 +157,7 @@ inherits(MouseWheelZoom, Interaction); * mousewheel-event) and eventually zooms the map. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @return {boolean} Allow event propagation. - * @this {ol.interaction.MouseWheelZoom} + * @this {module:ol/interaction/MouseWheelZoom~MouseWheelZoom} */ function handleEvent(mapBrowserEvent) { if (!this.condition_(mapBrowserEvent)) { @@ -271,7 +288,7 @@ MouseWheelZoom.prototype.decrementInteractingHint_ = function() { /** * @private - * @param {ol.PluggableMap} map Map. + * @param {module:ol/PluggableMap~PluggableMap} map Map. */ MouseWheelZoom.prototype.handleWheelZoom_ = function(map) { const view = map.getView(); From 998b8df55d6b1769fdf87d95a42210a05ce12510 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 16:38:48 +0100 Subject: [PATCH 15/24] No olx and ol types for ol/interaction/PinchRotate --- externs/olx.js | 22 ---------------------- externs/xol.js | 7 ------- src/ol/interaction/PinchRotate.js | 25 +++++++++++++++++-------- 3 files changed, 17 insertions(+), 37 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 91049d7314..3fb7741c83 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -47,28 +47,6 @@ olx.interaction.TranslateOptions.prototype.hitTolerance; /** - * @typedef {{threshold: (number|undefined), - * duration: (number|undefined)}} - */ -olx.interaction.PinchRotateOptions; - - -/** - * The duration of the animation in milliseconds. Default is `250`. - * @type {number|undefined} - * @api - */ -olx.interaction.PinchRotateOptions.prototype.duration; - - -/** - * Minimal angle in radians to start a rotation. Default is `0.3`. - * @type {number|undefined} - * @api - */ -olx.interaction.PinchRotateOptions.prototype.threshold; - - /** * @typedef {{ * duration: (number|undefined), diff --git a/externs/xol.js b/externs/xol.js index 7b38e3eedd..112e9ded51 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -14,13 +14,6 @@ */ -/** - * @typedef {Object} interaction_PinchRotateOptions - * @property {number|undefined} duration The duration of the animation in milliseconds. Default is `250`. - * @property {number|undefined} threshold Minimal angle in radians to start a rotation. Default is `0.3`. - */ - - /** * @typedef {Object} interaction_PinchZoomOptions * @property {number|undefined} duration Animation duration in milliseconds. Default is `400`. diff --git a/src/ol/interaction/PinchRotate.js b/src/ol/interaction/PinchRotate.js index 2b3d10670f..b016c664d1 100644 --- a/src/ol/interaction/PinchRotate.js +++ b/src/ol/interaction/PinchRotate.js @@ -8,14 +8,23 @@ import {rotate, rotateWithoutConstraints} from '../interaction/Interaction.js'; import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js'; import {disable} from '../rotationconstraint.js'; + +/** + * @typedef {Object} Options + * @property {number} [duration=250] The duration of the animation in + * milliseconds. + * @property {number} [threshold=0.3] Minimal angle in radians to start a rotation. + */ + + /** * @classdesc * Allows the user to rotate the map by twisting with two fingers * on a touch screen. * * @constructor - * @extends {ol.interaction.Pointer} - * @param {olx.interaction.PinchRotateOptions=} opt_options Options. + * @extends {module:ol/interaction/Pointer~Pointer} + * @param {module:ol/interaction/PinchRotate~Options=} opt_options Options. * @api */ const PinchRotate = function(opt_options) { @@ -70,8 +79,8 @@ inherits(PinchRotate, PointerInteraction); /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. - * @this {ol.interaction.PinchRotate} + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. + * @this {module:ol/interaction/PinchRotate~PinchRotate} */ function handleDragEvent(mapBrowserEvent) { let rotationDelta = 0.0; @@ -120,9 +129,9 @@ function handleDragEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.PinchRotate} + * @this {module:ol/interaction/PinchRotate~PinchRotate} */ function handleUpEvent(mapBrowserEvent) { if (this.targetPointers.length < 2) { @@ -141,9 +150,9 @@ function handleUpEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Start drag sequence? - * @this {ol.interaction.PinchRotate} + * @this {module:ol/interaction/PinchRotate~PinchRotate} */ function handleDownEvent(mapBrowserEvent) { if (this.targetPointers.length >= 2) { From 89f6d74696331e8c14c0d1d3df6198a3823589bc Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 16:42:34 +0100 Subject: [PATCH 16/24] No olx and ol types for ol/interaction/PinchZoom --- externs/olx.js | 25 ------------------------- externs/xol.js | 7 ------- src/ol/interaction/PinchZoom.js | 25 +++++++++++++++++-------- 3 files changed, 17 insertions(+), 40 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 3fb7741c83..03989e6654 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -46,31 +46,6 @@ olx.interaction.TranslateOptions.prototype.layers; olx.interaction.TranslateOptions.prototype.hitTolerance; -/** -/** - * @typedef {{ - * duration: (number|undefined), - * constrainResolution: (boolean|undefined) - * }} - */ -olx.interaction.PinchZoomOptions; - - -/** - * Animation duration in milliseconds. Default is `400`. - * @type {number|undefined} - * @api - */ -olx.interaction.PinchZoomOptions.prototype.duration; - -/** - * Zoom to the closest integer zoom level after the pinch gesture ends. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.interaction.PinchZoomOptions.prototype.constrainResolution; - - /** * @typedef {{handleDownEvent: (function(ol.MapBrowserPointerEvent):boolean|undefined), * handleDragEvent: (function(ol.MapBrowserPointerEvent)|undefined), diff --git a/externs/xol.js b/externs/xol.js index 112e9ded51..9efaac4e4c 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -14,13 +14,6 @@ */ -/** - * @typedef {Object} interaction_PinchZoomOptions - * @property {number|undefined} duration Animation duration in milliseconds. Default is `400`. - * @property {boolean|undefined} constrainResolution Zoom to the closest integer zoom level after the pinch gesture ends. Default is `false`. - */ - - /** * @typedef {Object} interaction_PointerOptions * @property {(function(ol.MapBrowserPointerEvent):boolean|undefined)} handleDownEvent Function handling "down" events. If the function returns `true` then a drag diff --git a/src/ol/interaction/PinchZoom.js b/src/ol/interaction/PinchZoom.js index d57ffb4d2a..bc0856b183 100644 --- a/src/ol/interaction/PinchZoom.js +++ b/src/ol/interaction/PinchZoom.js @@ -7,14 +7,23 @@ import {FALSE} from '../functions.js'; import {zoom, zoomWithoutConstraints} from '../interaction/Interaction.js'; import PointerInteraction, {centroid as centroidFromPointers} from '../interaction/Pointer.js'; + +/** + * @typedef {Object} Options + * @property {number} [duration=400] Animation duration in milliseconds. + * @property {boolean} [constrainResolution=false] Zoom to the closest integer + * zoom level after the pinch gesture ends. + */ + + /** * @classdesc * Allows the user to zoom the map by pinching with two fingers * on a touch screen. * * @constructor - * @extends {ol.interaction.Pointer} - * @param {olx.interaction.PinchZoomOptions=} opt_options Options. + * @extends {module:ol/interaction/Pointer~Pointer} + * @param {module:ol/interaction/PinchZoom~Options=} opt_options Options. * @api */ const PinchZoom = function(opt_options) { @@ -63,8 +72,8 @@ inherits(PinchZoom, PointerInteraction); /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. - * @this {ol.interaction.PinchZoom} + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. + * @this {module:ol/interaction/PinchZoom~PinchZoom} */ function handleDragEvent(mapBrowserEvent) { let scaleDelta = 1.0; @@ -115,9 +124,9 @@ function handleDragEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.PinchZoom} + * @this {module:ol/interaction/PinchZoom~PinchZoom} */ function handleUpEvent(mapBrowserEvent) { if (this.targetPointers.length < 2) { @@ -142,9 +151,9 @@ function handleUpEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent/MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Start drag sequence? - * @this {ol.interaction.PinchZoom} + * @this {module:ol/interaction/PinchZoom~PinchZoom} */ function handleDownEvent(mapBrowserEvent) { if (this.targetPointers.length >= 2) { From c53a13fc2638775ee31a53a4f36746ff6c8d231c Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 16:47:04 +0100 Subject: [PATCH 17/24] No olx and ol types for ol/interaction/Pointer --- externs/olx.js | 58 -------------------------------- externs/xol.js | 18 ---------- src/ol/interaction/Pointer.js | 63 ++++++++++++++++++++++++----------- 3 files changed, 43 insertions(+), 96 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 03989e6654..07e49b02c8 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -46,64 +46,6 @@ olx.interaction.TranslateOptions.prototype.layers; olx.interaction.TranslateOptions.prototype.hitTolerance; -/** - * @typedef {{handleDownEvent: (function(ol.MapBrowserPointerEvent):boolean|undefined), - * handleDragEvent: (function(ol.MapBrowserPointerEvent)|undefined), - * handleEvent: (function(module:ol/MapBrowserEvent~MapBrowserEvent):boolean|undefined), - * handleMoveEvent: (function(ol.MapBrowserPointerEvent)|undefined), - * handleUpEvent: (function(ol.MapBrowserPointerEvent):boolean|undefined)}} - */ -olx.interaction.PointerOptions; - - -/** - * Function handling "down" events. If the function returns `true` then a drag - * sequence is started. - * @type {(function(ol.MapBrowserPointerEvent):boolean|undefined)} - * @api - */ -olx.interaction.PointerOptions.prototype.handleDownEvent; - - -/** - * Function handling "drag" events. This function is called on "move" events - * during a drag sequence. - * @type {(function(ol.MapBrowserPointerEvent)|undefined)} - * @api - */ -olx.interaction.PointerOptions.prototype.handleDragEvent; - - -/** - * Method called by the map to notify the interaction that a browser event was - * dispatched to the map. The function may return `false` to prevent the - * propagation of the event to other interactions in the map's interactions - * chain. - * @type {(function(module:ol/MapBrowserEvent~MapBrowserEvent):boolean|undefined)} - * @api - */ -olx.interaction.PointerOptions.prototype.handleEvent; - - -/** - * Function handling "move" events. This function is called on "move" events, - * also during a drag sequence (so during a drag sequence both the - * `handleDragEvent` function and this function are called). - * @type {(function(ol.MapBrowserPointerEvent)|undefined)} - * @api - */ -olx.interaction.PointerOptions.prototype.handleMoveEvent; - - -/** - * Function handling "up" events. If the function returns `false` then the - * current drag sequence is stopped. - * @type {(function(ol.MapBrowserPointerEvent):boolean|undefined)} - * @api - */ -olx.interaction.PointerOptions.prototype.handleUpEvent; - - /** * @typedef {{addCondition: (ol.EventsConditionType|undefined), * condition: (ol.EventsConditionType|undefined), diff --git a/externs/xol.js b/externs/xol.js index 9efaac4e4c..9f8681b3a7 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -14,24 +14,6 @@ */ -/** - * @typedef {Object} interaction_PointerOptions - * @property {(function(ol.MapBrowserPointerEvent):boolean|undefined)} handleDownEvent Function handling "down" events. If the function returns `true` then a drag - * sequence is started. - * @property {(function(ol.MapBrowserPointerEvent)|undefined)} handleDragEvent Function handling "drag" events. This function is called on "move" events - * during a drag sequence. - * @property {(function(module:ol/MapBrowserEvent~MapBrowserEvent):boolean|undefined)} handleEvent Method called by the map to notify the interaction that a browser event was - * dispatched to the map. The function may return `false` to prevent the - * propagation of the event to other interactions in the map's interactions - * chain. - * @property {(function(ol.MapBrowserPointerEvent)|undefined)} handleMoveEvent Function handling "move" events. This function is called on "move" events, - * also during a drag sequence (so during a drag sequence both the - * `handleDragEvent` function and this function are called). - * @property {(function(ol.MapBrowserPointerEvent):boolean|undefined)} handleUpEvent Function handling "up" events. If the function returns `false` then the - * current drag sequence is stopped. - */ - - /** * @typedef {Object} interaction_SelectOptions * @property {ol.EventsConditionType|undefined} addCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean diff --git a/src/ol/interaction/Pointer.js b/src/ol/interaction/Pointer.js index 1f0cb0b515..ab0c161bb1 100644 --- a/src/ol/interaction/Pointer.js +++ b/src/ol/interaction/Pointer.js @@ -10,35 +10,58 @@ import {getValues} from '../obj.js'; /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. - * @this {ol.interaction.Pointer} + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. + * @this {module:ol/interaction/Pointer~Pointer} */ const handleDragEvent = UNDEFINED; /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Capture dragging. - * @this {ol.interaction.Pointer} + * @this {module:ol/interaction/Pointer~Pointer} */ const handleUpEvent = FALSE; /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Capture dragging. - * @this {ol.interaction.Pointer} + * @this {module:ol/interaction/Pointer~Pointer} */ const handleDownEvent = FALSE; /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. - * @this {ol.interaction.Pointer} + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. + * @this {module:ol/interaction/Pointer~Pointer} */ const handleMoveEvent = UNDEFINED; +/** + * @typedef {Object} Options + * @property {(function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent):boolean)} [handleDownEvent] + * Function handling "down" events. If the function returns `true` then a drag + * sequence is started. + * @property {(function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent))} [handleDragEvent] + * Function handling "drag" events. This function is called on "move" events + * during a drag sequence. + * @property {(function(module:ol/MapBrowserEvent~MapBrowserEvent):boolean)} [handleEvent] + * Method called by the map to notify the interaction that a browser event was + * dispatched to the map. The function may return `false` to prevent the + * propagation of the event to other interactions in the map's interactions + * chain. + * @property {(function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent))} [handleMoveEvent] + * Function handling "move" events. This function is called on "move" events, + * also during a drag sequence (so during a drag sequence both the + * `handleDragEvent` function and this function are called). + * @property {(function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent):boolean)} [handleUpEvent] + Function handling "up" events. If the function returns `false` then the + * current drag sequence is stopped. + */ + + /** * @classdesc * Base class that calls user-defined functions on `down`, `move` and `up` @@ -50,8 +73,8 @@ const handleMoveEvent = UNDEFINED; * user function is called and returns `false`. * * @constructor - * @param {olx.interaction.PointerOptions=} opt_options Options. - * @extends {ol.interaction.Interaction} + * @param {module:ol/interaction/Pointer~Options=} opt_options Options. + * @extends {module:ol/interaction/Interaction~Interaction} * @api */ const PointerInteraction = function(opt_options) { @@ -63,28 +86,28 @@ const PointerInteraction = function(opt_options) { }); /** - * @type {function(ol.MapBrowserPointerEvent):boolean} + * @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent):boolean} * @private */ this.handleDownEvent_ = options.handleDownEvent ? options.handleDownEvent : handleDownEvent; /** - * @type {function(ol.MapBrowserPointerEvent)} + * @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent)} * @private */ this.handleDragEvent_ = options.handleDragEvent ? options.handleDragEvent : handleDragEvent; /** - * @type {function(ol.MapBrowserPointerEvent)} + * @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent)} * @private */ this.handleMoveEvent_ = options.handleMoveEvent ? options.handleMoveEvent : handleMoveEvent; /** - * @type {function(ol.MapBrowserPointerEvent):boolean} + * @type {function(module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent):boolean} * @private */ this.handleUpEvent_ = options.handleUpEvent ? @@ -97,13 +120,13 @@ const PointerInteraction = function(opt_options) { this.handlingDownUpSequence = false; /** - * @type {!Object.} + * @type {!Object.} * @private */ this.trackedPointers_ = {}; /** - * @type {Array.} + * @type {Array.} * @protected */ this.targetPointers = []; @@ -114,7 +137,7 @@ inherits(PointerInteraction, Interaction); /** - * @param {Array.} pointerEvents List of events. + * @param {Array.} pointerEvents List of events. * @return {module:ol~Pixel} Centroid pixel. */ export function centroid(pointerEvents) { @@ -130,7 +153,7 @@ export function centroid(pointerEvents) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Whether the event is a pointerdown, pointerdrag * or pointerup event. */ @@ -143,7 +166,7 @@ function isPointerDraggingEvent(mapBrowserEvent) { /** - * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @private */ PointerInteraction.prototype.updateTrackedPointers_ = function(mapBrowserEvent) { @@ -171,7 +194,7 @@ PointerInteraction.prototype.updateTrackedPointers_ = function(mapBrowserEvent) * detected. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @return {boolean} `false` to stop event propagation. - * @this {ol.interaction.Pointer} + * @this {module:ol/interaction/Pointer~Pointer} * @api */ export function handleEvent(mapBrowserEvent) { From 9754334570650438fac4f97e25dad2985ade7839 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 17:04:58 +0100 Subject: [PATCH 18/24] No olx and ol types for ol/interaction/Select --- externs/olx.js | 135 ----------------------------------- externs/xol.js | 49 ------------- src/ol/interaction/Select.js | 120 ++++++++++++++++++++++++------- src/ol/typedefs.js | 10 --- 4 files changed, 94 insertions(+), 220 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 07e49b02c8..cb4304b13b 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -46,141 +46,6 @@ olx.interaction.TranslateOptions.prototype.layers; olx.interaction.TranslateOptions.prototype.hitTolerance; -/** - * @typedef {{addCondition: (ol.EventsConditionType|undefined), - * condition: (ol.EventsConditionType|undefined), - * layers: (undefined|Array.|function(ol.layer.Layer): boolean), - * style: (ol.style.Style|Array.|ol.StyleFunction|undefined), - * removeCondition: (ol.EventsConditionType|undefined), - * toggleCondition: (ol.EventsConditionType|undefined), - * multi: (boolean|undefined), - * features: (ol.Collection.|undefined), - * filter: (ol.SelectFilterFunction|undefined), - * wrapX: (boolean|undefined), - * hitTolerance: (number|undefined)}} - */ -olx.interaction.SelectOptions; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * By default, this is {@link ol.events.condition.never}. Use this if you want - * to use different events for add and remove instead of `toggle`. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.SelectOptions.prototype.addCondition; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * This is the event for the selected features as a whole. By default, this is - * {@link ol.events.condition.singleClick}. Clicking on a feature selects that - * feature and removes any that were in the selection. Clicking outside any - * feature removes all from the selection. - * See `toggle`, `add`, `remove` options for adding/removing extra features to/ - * from the selection. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.SelectOptions.prototype.condition; - - -/** - * A list of layers from which features should be - * selected. Alternatively, a filter function can be provided. The - * function will be called for each layer in the map and should return - * `true` for layers that you want to be selectable. If the option is - * absent, all visible layers will be considered selectable. - * @type {undefined|Array.|function(ol.layer.Layer): boolean} - * @api - */ -olx.interaction.SelectOptions.prototype.layers; - - -/** - * Style for the selected features. By default the default edit style is used - * (see {@link ol.style}). - * @type {ol.style.Style|Array.|ol.StyleFunction|undefined} - * @api - */ -olx.interaction.SelectOptions.prototype.style; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * By default, this is {@link ol.events.condition.never}. Use this if you want - * to use different events for add and remove instead of `toggle`. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.SelectOptions.prototype.removeCondition; - - -/** - * A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * This is in addition to the `condition` event. By default, - * {@link ol.events.condition.shiftKeyOnly}, i.e. pressing `shift` as well as - * the `condition` event, adds that feature to the current selection if it is - * not currently selected, and removes it if it is. - * See `add` and `remove` if you want to use different events instead of a - * toggle. - * @type {ol.EventsConditionType|undefined} - * @api - */ -olx.interaction.SelectOptions.prototype.toggleCondition; - - -/** - * A boolean that determines if the default behaviour should select only - * single features or all (overlapping) features at the clicked map - * position. Default is false i.e single select - * @type {boolean|undefined} - * @api - */ -olx.interaction.SelectOptions.prototype.multi; - -/** - * Collection where the interaction will place selected features. Optional. If - * not set the interaction will create a collection. In any case the collection - * used by the interaction is returned by - * {@link ol.interaction.Select#getFeatures}. - * @type {ol.Collection.|undefined} - * @api - */ -olx.interaction.SelectOptions.prototype.features; - -/** - * A function that takes an {@link module:ol/Feature~Feature} and an {@link ol.layer.Layer} and - * returns `true` if the feature may be selected or `false` otherwise. - * @type {ol.SelectFilterFunction|undefined} - * @api - */ -olx.interaction.SelectOptions.prototype.filter; - - -/** - * Wrap the world horizontally on the selection overlay. Default is `true`. - * @type {boolean|undefined} - * @api - */ -olx.interaction.SelectOptions.prototype.wrapX; - - -/** - * Hit-detection tolerance. Pixels inside the radius around the given position - * will be checked for features. This only works for the canvas renderer and - * not for WebGL. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.interaction.SelectOptions.prototype.hitTolerance; - - /** * Options for snap * @typedef {{ diff --git a/externs/xol.js b/externs/xol.js index 9f8681b3a7..0cf900cfc3 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -14,55 +14,6 @@ */ -/** - * @typedef {Object} interaction_SelectOptions - * @property {ol.EventsConditionType|undefined} addCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * By default, this is {@link ol.events.condition.never}. Use this if you want - * to use different events for add and remove instead of `toggle`. - * @property {ol.EventsConditionType|undefined} condition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * This is the event for the selected features as a whole. By default, this is - * {@link ol.events.condition.singleClick}. Clicking on a feature selects that - * feature and removes any that were in the selection. Clicking outside any - * feature removes all from the selection. - * See `toggle`, `add`, `remove` options for adding/removing extra features to/ - * from the selection. - * @property {undefined|Array.|function(ol.layer.Layer): boolean} layers A list of layers from which features should be - * selected. Alternatively, a filter function can be provided. The - * function will be called for each layer in the map and should return - * `true` for layers that you want to be selectable. If the option is - * absent, all visible layers will be considered selectable. - * @property {ol.style.Style|Array.|ol.StyleFunction|undefined} style Style for the selected features. By default the default edit style is used - * (see {@link ol.style}). - * @property {ol.EventsConditionType|undefined} removeCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * By default, this is {@link ol.events.condition.never}. Use this if you want - * to use different events for add and remove instead of `toggle`. - * @property {ol.EventsConditionType|undefined} toggleCondition A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean - * to indicate whether that event should be handled. - * This is in addition to the `condition` event. By default, - * {@link ol.events.condition.shiftKeyOnly}, i.e. pressing `shift` as well as - * the `condition` event, adds that feature to the current selection if it is - * not currently selected, and removes it if it is. - * See `add` and `remove` if you want to use different events instead of a - * toggle. - * @property {boolean|undefined} multi A boolean that determines if the default behaviour should select only - * single features or all (overlapping) features at the clicked map - * position. Default is false i.e single select - * @property {ol.Collection.|undefined} features Collection where the interaction will place selected features. Optional. If - * not set the interaction will create a collection. In any case the collection - * used by the interaction is returned by - * {@link ol.interaction.Select#getFeatures}. - * @property {ol.SelectFilterFunction|undefined} filter A function that takes an {@link module:ol/Feature~Feature} and an {@link ol.layer.Layer} and - * returns `true` if the feature may be selected or `false` otherwise. - * @property {boolean|undefined} wrapX Wrap the world horizontally on the selection overlay. Default is `true`. - * @property {number|undefined} hitTolerance Hit-detection tolerance. Pixels inside the radius around the given position - * will be checked for features. This only works for the canvas renderer and - * not for WebGL. Default is `0`. - */ - - /** * @typedef {Object} interaction_SnapOptions * @property {ol.Collection.|undefined} features Snap to these features. Either this option or source should be provided. diff --git a/src/ol/interaction/Select.js b/src/ol/interaction/Select.js index 22010432ec..848bb8a175 100644 --- a/src/ol/interaction/Select.js +++ b/src/ol/interaction/Select.js @@ -29,9 +29,77 @@ const SelectEventType = { }; +/** + * A function that takes an {@link module:ol/Feature~Feature} or + * {@link module:ol/render/Feature~Feature} and an + * {@link module:ol/layer/Layer~Layer} and returns `true` if the feature may be + * selected or `false` otherwise. + * @typedef {function((module:ol/Feature~Feature|module:ol/render/Feature~Feature), module:ol/layer/Layer~Layer): + * boolean} FilterFunction + */ + + +/** + * @typedef {Object} Options + * @property {module:ol/events/condition~Condition} [addCondition] A function + * that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. + * By default, this is {@link module:ol/events/condition~never}. Use this if you + * want to use different events for add and remove instead of `toggle`. + * @property {module:ol/events/condition~Condition} [condition] A function that + * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. This is the event + * for the selected features as a whole. By default, this is + * {@link module:ol/events/condition~singleClick}. Clicking on a feature selects that + * feature and removes any that were in the selection. Clicking outside any + * feature removes all from the selection. + * See `toggle`, `add`, `remove` options for adding/removing extra features to/ + * from the selection. + * @property {Array.|function(module:ol/layer/Layer~Layer): boolean} [layers] + * A list of layers from which features should be selected. Alternatively, a + * filter function can be provided. The function will be called for each layer + * in the map and should return `true` for layers that you want to be + * selectable. If the option is absent, all visible layers will be considered + * selectable. + * @property {module:ol/style/Style~Style|Array.|module:ol/style~StyleFunction} [style] + * Style for the selected features. By default the default edit style is used + * (see {@link module:ol/style}). + * @property {module:ol/events/condition~Condition} [removeCondition] A function + * that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. + * By default, this is {@link module:ol/events/condition~never}. Use this if you + * want to use different events for add and remove instead of `toggle`. + * @property {module:ol/events/condition~Condition} [toggleCondition] A function + * that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a + * boolean to indicate whether that event should be handled. This is in addition + * to the `condition` event. By default, + * {@link module:ol/events/condition~shiftKeyOnly}, i.e. pressing `shift` as + * well as the `condition` event, adds that feature to the current selection if + * it is not currently selected, and removes it if it is. See `add` and `remove` + * if you want to use different events instead of a toggle. + * @property {boolean} [multi=false] A boolean that determines if the default + * behaviour should select only single features or all (overlapping) features at + * the clicked map position. The default of `false` means single select. + * @property {module:ol/collection/Collection~Collection.} [features] + * Collection where the interaction will place selected features. Optional. If + * not set the interaction will create a collection. In any case the collection + * used by the interaction is returned by + * {@link module:ol/interaction/Select~Select#getFeatures}. + * @property {module:ol/interaction/Select~FilterFunction} [filter] A function + * that takes an {@link module:ol/Feature~Feature} and an + * {@link module:ol/layer/Layer~Layer} and returns `true` if the feature may be + * selected or `false` otherwise. + * @property {boolean} [wrapX=true] Wrap the world horizontally on the selection + * overlay. + * @property {number} [hitTolerance=0] Hit-detection tolerance. Pixels inside + * the radius around the given position will be checked for features. This only + * works for the canvas renderer and not for WebGL. + */ + + /** * @classdesc - * Events emitted by {@link ol.interaction.Select} instances are instances of + * Events emitted by {@link module:ol/interaction/Select~Select} instances are instances of * this type. * * @param {SelectEventType} type The event type. @@ -40,7 +108,7 @@ const SelectEventType = { * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Associated * {@link module:ol/MapBrowserEvent~MapBrowserEvent}. * @implements {oli.SelectEvent} - * @extends {ol.events.Event} + * @extends {module:ol/events/Event~Event} * @constructor */ const SelectEvent = function(type, selected, deselected, mapBrowserEvent) { @@ -84,8 +152,8 @@ inherits(SelectEvent, Event); * Selected features are added to an internal unmanaged layer. * * @constructor - * @extends {ol.interaction.Interaction} - * @param {olx.interaction.SelectOptions=} opt_options Options. + * @extends {module:ol/interaction/Interaction~Interaction} + * @param {module:ol/interaction/Select~Options=} opt_options Options. * @fires SelectEvent * @api */ @@ -129,7 +197,7 @@ const Select = function(opt_options) { /** * @private - * @type {ol.SelectFilterFunction} + * @type {module:ol/interaction/Select~FilterFunction} */ this.filter_ = options.filter ? options.filter : TRUE; @@ -153,11 +221,11 @@ const Select = function(opt_options) { /** * @private - * @type {ol.layer.Vector} + * @type {module:ol/layer/Vector~Vector} */ this.featureOverlay_ = featureOverlay; - /** @type {function(ol.layer.Layer): boolean} */ + /** @type {function(module:ol/layer/Layer~Layer): boolean} */ let layerFilter; if (options.layers) { if (typeof options.layers === 'function') { @@ -174,7 +242,7 @@ const Select = function(opt_options) { /** * @private - * @type {function(ol.layer.Layer): boolean} + * @type {function(module:ol/layer/Layer~Layer): boolean} */ this.layerFilter_ = layerFilter; @@ -182,7 +250,7 @@ const Select = function(opt_options) { * An association between selected feature (key) * and layer (value) * @private - * @type {Object.} + * @type {Object.} */ this.featureLayerAssociation_ = {}; @@ -198,8 +266,8 @@ inherits(Select, Interaction); /** - * @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature. - * @param {ol.layer.Layer} layer Layer. + * @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature. + * @param {module:ol/layer/Layer~Layer} layer Layer. * @private */ Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) { @@ -210,7 +278,7 @@ Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) { /** * Get the selected features. - * @return {ol.Collection.} Features collection. + * @return {module:ol/collection/Collection~Collection.} Features collection. * @api */ Select.prototype.getFeatures = function() { @@ -229,17 +297,17 @@ Select.prototype.getHitTolerance = function() { /** - * Returns the associated {@link ol.layer.Vector vectorlayer} of + * Returns the associated {@link module:ol/layer/Vector~Vector vectorlayer} of * the (last) selected feature. Note that this will not work with any * programmatic method like pushing features to - * {@link ol.interaction.Select#getFeatures collection}. - * @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature - * @return {ol.layer.Vector} Layer. + * {@link module:ol/interaction/Select~Select#getFeatures collection}. + * @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature + * @return {module:ol/layer/Vector~Vector} Layer. * @api */ Select.prototype.getLayer = function(feature) { const key = getUid(feature); - return /** @type {ol.layer.Vector} */ (this.featureLayerAssociation_[key]); + return /** @type {module:ol/layer/Vector~Vector} */ (this.featureLayerAssociation_[key]); }; @@ -248,7 +316,7 @@ Select.prototype.getLayer = function(feature) { * selected state of features. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} mapBrowserEvent Map browser event. * @return {boolean} `false` to stop event propagation. - * @this {ol.interaction.Select} + * @this {module:ol/interaction/Select~Select} */ function handleEvent(mapBrowserEvent) { if (!this.condition_(mapBrowserEvent)) { @@ -270,8 +338,8 @@ function handleEvent(mapBrowserEvent) { map.forEachFeatureAtPixel(mapBrowserEvent.pixel, ( /** - * @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature. - * @param {ol.layer.Layer} layer Layer. + * @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature. + * @param {module:ol/layer/Layer~Layer} layer Layer. * @return {boolean|undefined} Continue to iterate over the features. */ function(feature, layer) { @@ -303,8 +371,8 @@ function handleEvent(mapBrowserEvent) { map.forEachFeatureAtPixel(mapBrowserEvent.pixel, ( /** - * @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature. - * @param {ol.layer.Layer} layer Layer. + * @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature. + * @param {module:ol/layer/Layer~Layer} layer Layer. * @return {boolean|undefined} Continue to iterate over the features. */ function(feature, layer) { @@ -351,7 +419,7 @@ Select.prototype.setHitTolerance = function(hitTolerance) { /** * Remove the interaction from its current map, if any, and attach it to a new * map, if any. Pass `null` to just remove the interaction from the current map. - * @param {ol.PluggableMap} map Map. + * @param {module:ol/PluggableMap~PluggableMap} map Map. * @override * @api */ @@ -388,7 +456,7 @@ function getDefaultStyleFunction() { /** - * @param {ol.CollectionEvent} evt Event. + * @param {module:ol/collection/Collection~CollectionEvent} evt Event. * @private */ Select.prototype.addFeature_ = function(evt) { @@ -400,7 +468,7 @@ Select.prototype.addFeature_ = function(evt) { /** - * @param {ol.CollectionEvent} evt Event. + * @param {module:ol/collection/Collection~CollectionEvent} evt Event. * @private */ Select.prototype.removeFeature_ = function(evt) { @@ -412,7 +480,7 @@ Select.prototype.removeFeature_ = function(evt) { /** - * @param {module:ol/Feature~Feature|ol.render.Feature} feature Feature. + * @param {module:ol/Feature~Feature|module:ol/render/Feature~Feature} feature Feature. * @private */ Select.prototype.removeFeatureLayerAssociation_ = function(feature) { diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 960dd8711d..154b6f8b90 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -256,16 +256,6 @@ ol.ReprojTileFunctionType; ol.ReprojTriangle; -/** - * A function that takes an {@link module:ol/Feature~Feature} or {@link ol.render.Feature} and - * an {@link ol.layer.Layer} and returns `true` if the feature may be selected - * or `false` otherwise. - * @typedef {function((module:ol/Feature~Feature|ol.render.Feature), ol.layer.Layer): - * boolean} - */ -ol.SelectFilterFunction; - - /** * @typedef {{ * snapped: {boolean}, From bc33d871e133abd47fe4c72d8a97b76fcbdadc67 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 17:12:14 +0100 Subject: [PATCH 19/24] No olx and ol types for ol/interaction/Snap --- externs/olx.js | 53 ----------------------- externs/xol.js | 11 ----- src/ol/interaction/Snap.js | 87 +++++++++++++++++++++++++------------- src/ol/typedefs.js | 19 --------- 4 files changed, 58 insertions(+), 112 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index cb4304b13b..cb21feed58 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -46,59 +46,6 @@ olx.interaction.TranslateOptions.prototype.layers; olx.interaction.TranslateOptions.prototype.hitTolerance; -/** - * Options for snap - * @typedef {{ - * features: (ol.Collection.|undefined), - * pixelTolerance: (number|undefined), - * source: (ol.source.Vector|undefined), - * edge: (boolean|undefined), - * vertex: (boolean|undefined) - * }} - */ -olx.interaction.SnapOptions; - - -/** - * Snap to these features. Either this option or source should be provided. - * @type {ol.Collection.|undefined} - * @api - */ -olx.interaction.SnapOptions.prototype.features; - -/** - * Snap to edges. Default is `true`. - * @type {boolean|undefined} - * @api - */ -olx.interaction.SnapOptions.prototype.edge; - - -/** - * Snap to vertices. Default is `true`. - * @type {boolean|undefined} - * @api - */ -olx.interaction.SnapOptions.prototype.vertex; - - -/** - * Pixel tolerance for considering the pointer close enough to a segment or - * vertex for snapping. Default is `10` pixels. - * @type {number|undefined} - * @api - */ -olx.interaction.SnapOptions.prototype.pixelTolerance; - - -/** - * Snap to features from this source. Either this option or features should be provided - * @type {ol.source.Vector|undefined} - * @api - */ -olx.interaction.SnapOptions.prototype.source; - - /** * @typedef {{opacity: (number|undefined), * visible: (boolean|undefined), diff --git a/externs/xol.js b/externs/xol.js index 0cf900cfc3..d916db36e8 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -14,17 +14,6 @@ */ -/** - * @typedef {Object} interaction_SnapOptions - * @property {ol.Collection.|undefined} features Snap to these features. Either this option or source should be provided. - * @property {boolean|undefined} edge Snap to edges. Default is `true`. - * @property {boolean|undefined} vertex Snap to vertices. Default is `true`. - * @property {number|undefined} pixelTolerance Pixel tolerance for considering the pointer close enough to a segment or - * vertex for snapping. Default is `10` pixels. - * @property {ol.source.Vector|undefined} source Snap to features from this source. Either this option or features should be provided - */ - - /** * @typedef {Object} layer_BaseOptions * @property {number|undefined} opacity Opacity (0, 1). Default is `1`. diff --git a/src/ol/interaction/Snap.js b/src/ol/interaction/Snap.js index 0177ebc109..7cca4dede5 100644 --- a/src/ol/interaction/Snap.js +++ b/src/ol/interaction/Snap.js @@ -17,10 +17,37 @@ import {VectorSourceEvent} from '../source/Vector.js'; import VectorEventType from '../source/VectorEventType.js'; import RBush from '../structs/RBush.js'; + +/** + * @typedef {Object} Result + * @property {boolean} snapped + * @property {module:ol/coordinate~Coordinate|null} vertex + * @property {module:ol~Pixel|null} vertexPixel + */ + + +/** + * @typedef {Object} SegmentData + * @property {module:ol/Feature~Feature} feature + * @property {Array.} segment + */ + + +/** + * @typedef {Object} Options + * @property {module:ol/collection/Collection~Collection.|undefined} features Snap to these features. Either this option or source should be provided. + * @property {boolean|undefined} edge Snap to edges. Default is `true`. + * @property {boolean|undefined} vertex Snap to vertices. Default is `true`. + * @property {number|undefined} pixelTolerance Pixel tolerance for considering the pointer close enough to a segment or + * vertex for snapping. Default is `10` pixels. + * @property {module:ol/source/Vector~Vector|undefined} source Snap to features from this source. Either this option or features should be provided + */ + + /** * @classdesc * Handles snapping of vector features while modifying or drawing them. The - * features can come from a {@link ol.source.Vector} or {@link ol.Collection} + * features can come from a {@link module:ol/source/Vector~Vector} or {@link module:ol/collection/Collection~Collection} * Any interaction object that allows the user to interact * with the features using the mouse can benefit from the snapping, as long * as it is added before. @@ -30,13 +57,15 @@ import RBush from '../structs/RBush.js'; * * Example: * - * var snap = new ol.interaction.Snap({ + * import Snap from 'ol/interaction/Snap'; + * + * var snap = new Snap({ * source: source * }); * * @constructor - * @extends {ol.interaction.Pointer} - * @param {olx.interaction.SnapOptions=} opt_options Options. + * @extends {module:ol/interaction/Pointer~Pointer} + * @param {module:ol/interaction/Snap~Options=} opt_options Options. * @api */ const Snap = function(opt_options) { @@ -50,7 +79,7 @@ const Snap = function(opt_options) { const options = opt_options ? opt_options : {}; /** - * @type {ol.source.Vector} + * @type {module:ol/source/Vector~Vector} * @private */ this.source_ = options.source ? options.source : null; @@ -68,7 +97,7 @@ const Snap = function(opt_options) { this.edge_ = options.edge !== undefined ? options.edge : true; /** - * @type {ol.Collection.} + * @type {module:ol/collection/Collection~Collection.} * @private */ this.features_ = options.features ? options.features : null; @@ -117,7 +146,7 @@ const Snap = function(opt_options) { options.pixelTolerance : 10; /** - * @type {function(ol.SnapSegmentDataType, ol.SnapSegmentDataType): number} + * @type {function(module:ol/interaction/Snap~SegmentData, module:ol/interaction/Snap~SegmentData): number} * @private */ this.sortByDistance_ = sortByDistance.bind(this); @@ -125,7 +154,7 @@ const Snap = function(opt_options) { /** * Segment RTree for each layer - * @type {ol.structs.RBush.} + * @type {module:ol/structs/RBush~RBush.} * @private */ this.rBush_ = new RBush(); @@ -199,7 +228,7 @@ Snap.prototype.forEachFeatureRemove_ = function(feature) { /** - * @return {ol.Collection.|Array.} Features. + * @return {module:ol/collection/Collection~Collection.|Array.} Features. * @private */ Snap.prototype.getFeatures_ = function() { @@ -209,12 +238,12 @@ Snap.prototype.getFeatures_ = function() { } else if (this.source_) { features = this.source_.getFeatures(); } - return /** @type {!Array.|!ol.Collection.} */ (features); + return /** @type {!Array.|!module:ol/collection/Collection~Collection.} */ (features); }; /** - * @param {ol.source.Vector.Event|ol.CollectionEvent} evt Event. + * @param {module:ol/source/Vector~Vector.Event|module:ol/collection/Collection~CollectionEvent} evt Event. * @private */ Snap.prototype.handleFeatureAdd_ = function(evt) { @@ -229,7 +258,7 @@ Snap.prototype.handleFeatureAdd_ = function(evt) { /** - * @param {ol.source.Vector.Event|ol.CollectionEvent} evt Event. + * @param {module:ol/source/Vector~Vector.Event|module:ol/collection/Collection~CollectionEvent} evt Event. * @private */ Snap.prototype.handleFeatureRemove_ = function(evt) { @@ -244,7 +273,7 @@ Snap.prototype.handleFeatureRemove_ = function(evt) { /** - * @param {ol.events.Event} evt Event. + * @param {module:ol/events/Event~Event} evt Event. * @private */ Snap.prototype.handleFeatureChange_ = function(evt) { @@ -336,8 +365,8 @@ Snap.prototype.shouldStopEvent = FALSE; /** * @param {module:ol~Pixel} pixel Pixel * @param {module:ol/coordinate~Coordinate} pixelCoordinate Coordinate - * @param {ol.PluggableMap} map Map. - * @return {ol.SnapResultType} Snap result + * @param {module:ol/PluggableMap~PluggableMap} map Map. + * @return {module:ol/interaction/Snap~Result} Snap result */ Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { @@ -408,7 +437,7 @@ Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { vertexPixel = [Math.round(vertexPixel[0]), Math.round(vertexPixel[1])]; } } - return /** @type {ol.SnapResultType} */ ({ + return /** @type {module:ol/interaction/Snap~Result} */ ({ snapped: snapped, vertex: vertex, vertexPixel: vertexPixel @@ -436,7 +465,7 @@ Snap.prototype.writeCircleGeometry_ = function(feature, geometry) { const coordinates = polygon.getCoordinates()[0]; for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { const segment = coordinates.slice(i, i + 2); - const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({ feature: feature, segment: segment }); @@ -470,7 +499,7 @@ Snap.prototype.writeLineStringGeometry_ = function(feature, geometry) { const coordinates = geometry.getCoordinates(); for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { const segment = coordinates.slice(i, i + 2); - const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({ feature: feature, segment: segment }); @@ -490,7 +519,7 @@ Snap.prototype.writeMultiLineStringGeometry_ = function(feature, geometry) { const coordinates = lines[j]; for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { const segment = coordinates.slice(i, i + 2); - const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({ feature: feature, segment: segment }); @@ -509,7 +538,7 @@ Snap.prototype.writeMultiPointGeometry_ = function(feature, geometry) { const points = geometry.getCoordinates(); for (let i = 0, ii = points.length; i < ii; ++i) { const coordinates = points[i]; - const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({ feature: feature, segment: [coordinates, coordinates] }); @@ -531,7 +560,7 @@ Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) { const coordinates = rings[j]; for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { const segment = coordinates.slice(i, i + 2); - const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({ feature: feature, segment: segment }); @@ -549,7 +578,7 @@ Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geometry) { */ Snap.prototype.writePointGeometry_ = function(feature, geometry) { const coordinates = geometry.getCoordinates(); - const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({ feature: feature, segment: [coordinates, coordinates] }); @@ -568,7 +597,7 @@ Snap.prototype.writePolygonGeometry_ = function(feature, geometry) { const coordinates = rings[j]; for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) { const segment = coordinates.slice(i, i + 2); - const segmentData = /** @type {ol.SnapSegmentDataType} */ ({ + const segmentData = /** @type {module:ol/interaction/Snap~SegmentData} */ ({ feature: feature, segment: segment }); @@ -582,7 +611,7 @@ Snap.prototype.writePolygonGeometry_ = function(feature, geometry) { * Handle all pointer events events. * @param {module:ol/MapBrowserEvent~MapBrowserEvent} evt A move event. * @return {boolean} Pass the event to other interactions. - * @this {ol.interaction.Snap} + * @this {module:ol/interaction/Snap~Snap} */ export function handleEvent(evt) { const result = this.snapTo(evt.pixel, evt.coordinate, evt.map); @@ -595,9 +624,9 @@ export function handleEvent(evt) { /** - * @param {ol.MapBrowserPointerEvent} evt Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} evt Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.Snap} + * @this {module:ol/interaction/Snap~Snap} */ function handleUpEvent(evt) { const featuresToUpdate = getValues(this.pendingFeatures_); @@ -611,10 +640,10 @@ function handleUpEvent(evt) { /** * Sort segments by distance, helper function - * @param {ol.SnapSegmentDataType} a The first segment data. - * @param {ol.SnapSegmentDataType} b The second segment data. + * @param {module:ol/interaction/Snap~SegmentData} a The first segment data. + * @param {module:ol/interaction/Snap~SegmentData} b The second segment data. * @return {number} The difference in distance. - * @this {ol.interaction.Snap} + * @this {module:ol/interaction/Snap~Snap} */ function sortByDistance(a, b) { const deltaA = squaredDistanceToSegment(this.pixelCoordinate_, a.segment); diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 154b6f8b90..c4eb415122 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -256,25 +256,6 @@ ol.ReprojTileFunctionType; ol.ReprojTriangle; -/** - * @typedef {{ - * snapped: {boolean}, - * vertex: (module:ol/coordinate~Coordinate|null), - * vertexPixel: (module:ol~Pixel|null) - * }} - */ -ol.SnapResultType; - - -/** - * @typedef {{ - * feature: module:ol/Feature~Feature, - * segment: Array. - * }} - */ -ol.SnapSegmentDataType; - - /** * @typedef {{attributions: (ol.AttributionLike|undefined), * extent: (null|module:ol/extent~Extent|undefined), From 00d65ccddc32ccc8a56969c8bcd7e3b31be4f5f1 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 17:15:41 +0100 Subject: [PATCH 20/24] No olx and ol types for ol/interaction/Translate --- externs/olx.js | 41 ------------------------ externs/xol.js | 15 --------- src/ol/interaction/Translate.js | 55 +++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 76 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index cb21feed58..f3345b4eed 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5,47 +5,6 @@ let olx; -/** - * @typedef {{ - * features: (ol.Collection.|undefined), - * layers: (undefined|Array.|function(ol.layer.Layer): boolean), - * hitTolerance: (number|undefined) - * }} - */ -olx.interaction.TranslateOptions; - - -/** - * Only features contained in this collection will be able to be translated. If - * not specified, all features on the map will be able to be translated. - * @type {ol.Collection.|undefined} - * @api - */ -olx.interaction.TranslateOptions.prototype.features; - - -/** - * A list of layers from which features should be - * translated. Alternatively, a filter function can be provided. The - * function will be called for each layer in the map and should return - * `true` for layers that you want to be translatable. If the option is - * absent, all visible layers will be considered translatable. - * @type {undefined|Array.|function(ol.layer.Layer): boolean} - * @api - */ -olx.interaction.TranslateOptions.prototype.layers; - - -/** - * Hit-detection tolerance. Pixels inside the radius around the given position - * will be checked for features. This only works for the canvas renderer and - * not for WebGL. Default is `0`. - * @type {number|undefined} - * @api - */ -olx.interaction.TranslateOptions.prototype.hitTolerance; - - /** * @typedef {{opacity: (number|undefined), * visible: (boolean|undefined), diff --git a/externs/xol.js b/externs/xol.js index d916db36e8..47cfc14ec6 100644 --- a/externs/xol.js +++ b/externs/xol.js @@ -1,19 +1,4 @@ -/** - * @typedef {Object} interaction_TranslateOptions - * @property {ol.Collection.|undefined} features Only features contained in this collection will be able to be translated. If - * not specified, all features on the map will be able to be translated. - * @property {undefined|Array.|function(ol.layer.Layer): boolean} layers A list of layers from which features should be - * translated. Alternatively, a filter function can be provided. The - * function will be called for each layer in the map and should return - * `true` for layers that you want to be translatable. If the option is - * absent, all visible layers will be considered translatable. - * @property {number|undefined} hitTolerance Hit-detection tolerance. Pixels inside the radius around the given position - * will be checked for features. This only works for the canvas renderer and - * not for WebGL. Default is `0`. - */ - - /** * @typedef {Object} layer_BaseOptions * @property {number|undefined} opacity Opacity (0, 1). Default is `1`. diff --git a/src/ol/interaction/Translate.js b/src/ol/interaction/Translate.js index e0dc81f9c4..69996082b9 100644 --- a/src/ol/interaction/Translate.js +++ b/src/ol/interaction/Translate.js @@ -37,16 +37,31 @@ const TranslateEventType = { }; +/** + * @typedef {Object} interaction_TranslateOptions + * @property {module:ol/collection/Collection~Collection.|undefined} features Only features contained in this collection will be able to be translated. If + * not specified, all features on the map will be able to be translated. + * @property {undefined|Array.|function(module:ol/layer/Layer~Layer): boolean} layers A list of layers from which features should be + * translated. Alternatively, a filter function can be provided. The + * function will be called for each layer in the map and should return + * `true` for layers that you want to be translatable. If the option is + * absent, all visible layers will be considered translatable. + * @property {number|undefined} hitTolerance Hit-detection tolerance. Pixels inside the radius around the given position + * will be checked for features. This only works for the canvas renderer and + * not for WebGL. Default is `0`. + */ + + /** * @classdesc - * Events emitted by {@link ol.interaction.Translate} instances are instances of - * this type. + * Events emitted by {@link module:ol/interaction/Translate~Translate} instances + * are instances of this type. * * @constructor - * @extends {ol.events.Event} + * @extends {module:ol/events/Event~Event} * @implements {oli.interaction.TranslateEvent} - * @param {ol.interaction.TranslateEventType} type Type. - * @param {ol.Collection.} features The features translated. + * @param {module:ol/interaction/Translate~TranslateEventType} type Type. + * @param {module:ol/collection/Collection~Collection.} features The features translated. * @param {module:ol/coordinate~Coordinate} coordinate The event coordinate. */ export const TranslateEvent = function(type, features, coordinate) { @@ -55,7 +70,7 @@ export const TranslateEvent = function(type, features, coordinate) { /** * The features being translated. - * @type {ol.Collection.} + * @type {module:ol/collection/Collection~Collection.} * @api */ this.features = features; @@ -77,8 +92,8 @@ inherits(TranslateEvent, Event); * Interaction for translating (moving) features. * * @constructor - * @extends {ol.interaction.Pointer} - * @fires ol.interaction.TranslateEvent + * @extends {module:ol/interaction/Pointer~Pointer} + * @fires module:ol/interaction/Translate~TranslateEvent * @param {olx.interaction.TranslateOptions=} opt_options Options. * @api */ @@ -101,12 +116,12 @@ const Translate = function(opt_options) { /** - * @type {ol.Collection.} + * @type {module:ol/collection/Collection~Collection.} * @private */ this.features_ = options.features !== undefined ? options.features : null; - /** @type {function(ol.layer.Layer): boolean} */ + /** @type {function(module:ol/layer/Layer~Layer): boolean} */ let layerFilter; if (options.layers) { if (typeof options.layers === 'function') { @@ -123,7 +138,7 @@ const Translate = function(opt_options) { /** * @private - * @type {function(ol.layer.Layer): boolean} + * @type {function(module:ol/layer/Layer~Layer): boolean} */ this.layerFilter_ = layerFilter; @@ -149,9 +164,9 @@ inherits(Translate, PointerInteraction); /** - * @param {ol.MapBrowserPointerEvent} event Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event. * @return {boolean} Start drag sequence? - * @this {ol.interaction.Translate} + * @this {module:ol/interaction/Translate~Translate} */ function handleDownEvent(event) { this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map); @@ -172,9 +187,9 @@ function handleDownEvent(event) { /** - * @param {ol.MapBrowserPointerEvent} event Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event. * @return {boolean} Stop drag sequence? - * @this {ol.interaction.Translate} + * @this {module:ol/interaction/Translate~Translate} */ function handleUpEvent(event) { if (this.lastCoordinate_) { @@ -194,8 +209,8 @@ function handleUpEvent(event) { /** - * @param {ol.MapBrowserPointerEvent} event Event. - * @this {ol.interaction.Translate} + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} event Event. + * @this {module:ol/interaction/Translate~Translate} */ function handleDragEvent(event) { if (this.lastCoordinate_) { @@ -222,7 +237,7 @@ function handleDragEvent(event) { /** * @param {module:ol/MapBrowserEvent~MapBrowserEvent} event Event. - * @this {ol.interaction.Translate} + * @this {module:ol/interaction/Translate~Translate} */ function handleMoveEvent(event) { const elem = event.map.getViewport(); @@ -242,7 +257,7 @@ function handleMoveEvent(event) { * Tests to see if the given coordinates intersects any of our selected * features. * @param {module:ol~Pixel} pixel Pixel coordinate to test for intersection. - * @param {ol.PluggableMap} map Map to test the intersection on. + * @param {module:ol/PluggableMap~PluggableMap} map Map to test the intersection on. * @return {module:ol/Feature~Feature} Returns the feature found at the specified pixel * coordinates. * @private @@ -301,7 +316,7 @@ Translate.prototype.handleActiveChanged_ = function() { /** - * @param {ol.PluggableMap} oldMap Old map. + * @param {module:ol/PluggableMap~PluggableMap} oldMap Old map. * @private */ Translate.prototype.updateState_ = function(oldMap) { From 8728c8723f2b4e201b2665c1c5ab803bdfe89885 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 17:17:06 +0100 Subject: [PATCH 21/24] Use path types when referencing interactions --- src/ol/layer/Layer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/layer/Layer.js b/src/ol/layer/Layer.js index 01759d2a20..5ff9445865 100644 --- a/src/ol/layer/Layer.js +++ b/src/ol/layer/Layer.js @@ -35,8 +35,8 @@ import SourceState from '../source/State.js'; * displayed, irrespective of the source of that data. * * Layers are usually added to a map with {@link ol.Map#addLayer}. Components - * like {@link ol.interaction.Select} use unmanaged layers internally. These - * unmanaged layers are associated with the map using + * like {@link module:ol/interaction/Select~Select} use unmanaged layers + * internally. These unmanaged layers are associated with the map using * {@link ol.layer.Layer#setMap} instead. * * A generic `change` event is fired when the state of the source changes. From c496b4edca6472d880685e2aefffbff2eb19aa91 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 17:22:45 +0100 Subject: [PATCH 22/24] Fix type typos --- src/ol/interaction/DragRotate.js | 2 +- src/ol/interaction/DragZoom.js | 2 +- src/ol/interaction/Extent.js | 4 ++-- src/ol/interaction/MouseWheelZoom.js | 2 +- src/ol/interaction/PinchZoom.js | 2 +- src/ol/interaction/Select.js | 8 ++++---- src/ol/interaction/Snap.js | 14 +++++++------- src/ol/interaction/Translate.js | 8 ++++---- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/ol/interaction/DragRotate.js b/src/ol/interaction/DragRotate.js index d3c25bd362..6918b0a882 100644 --- a/src/ol/interaction/DragRotate.js +++ b/src/ol/interaction/DragRotate.js @@ -30,7 +30,7 @@ import PointerInteraction from '../interaction/Pointer.js'; * * @constructor * @extends {module:ol/interaction/Pointer~Pointer} - * @param {ol/interaction/DragRotate~Options=} opt_options Options. + * @param {module:ol/interaction/DragRotate~Options=} opt_options Options. * @api */ const DragRotate = function(opt_options) { diff --git a/src/ol/interaction/DragZoom.js b/src/ol/interaction/DragZoom.js index ffaa340c8b..8e37fb0960 100644 --- a/src/ol/interaction/DragZoom.js +++ b/src/ol/interaction/DragZoom.js @@ -32,7 +32,7 @@ import DragBox from '../interaction/DragBox.js'; * * @constructor * @extends {module:ol/interaction/DragBox~DragBox} - * @param {ol/interaction/DragZoom~Options=} opt_options Options. + * @param {module:ol/interaction/DragZoom~Options=} opt_options Options. * @api */ const DragZoom = function(opt_options) { diff --git a/src/ol/interaction/Extent.js b/src/ol/interaction/Extent.js index 02eaa0bedd..ac7a2834f8 100644 --- a/src/ol/interaction/Extent.js +++ b/src/ol/interaction/Extent.js @@ -46,7 +46,7 @@ import {createEditingStyle} from '../style/Style.js'; EXTENTCHANGED: 'extentchanged' }; - + /** * @classdesc * Events emitted by {@link module:ol/interaction/Extent~Extent} instances are @@ -80,7 +80,7 @@ inherits(ExtentInteractionEvent, Event); * @constructor * @extends {module:ol/interaction/Pointer~Pointer} * @fires module:ol/interaction/Extent~Event - * @param {ol/interaction/Extent~Options=} opt_options Options. + * @param {module:ol/interaction/Extent~Options=} opt_options Options. * @api */ const ExtentInteraction = function(opt_options) { diff --git a/src/ol/interaction/MouseWheelZoom.js b/src/ol/interaction/MouseWheelZoom.js index 28d49211e0..6583397326 100644 --- a/src/ol/interaction/MouseWheelZoom.js +++ b/src/ol/interaction/MouseWheelZoom.js @@ -50,7 +50,7 @@ export const Mode = { * * @constructor * @extends {module:ol/interaction/Interaction~Interaction} - * @param {module:olx/interaction/MouseWheelZoom~Options=} opt_options Options. + * @param {module:ol/interaction/MouseWheelZoom~Options=} opt_options Options. * @api */ const MouseWheelZoom = function(opt_options) { diff --git a/src/ol/interaction/PinchZoom.js b/src/ol/interaction/PinchZoom.js index bc0856b183..6ef98bf231 100644 --- a/src/ol/interaction/PinchZoom.js +++ b/src/ol/interaction/PinchZoom.js @@ -151,7 +151,7 @@ function handleUpEvent(mapBrowserEvent) { /** - * @param {module:ol/MapBrowserPointerEvent/MapBrowserPointerEvent} mapBrowserEvent Event. + * @param {module:ol/MapBrowserPointerEvent~MapBrowserPointerEvent} mapBrowserEvent Event. * @return {boolean} Start drag sequence? * @this {module:ol/interaction/PinchZoom~PinchZoom} */ diff --git a/src/ol/interaction/Select.js b/src/ol/interaction/Select.js index 848bb8a175..cab903b1cc 100644 --- a/src/ol/interaction/Select.js +++ b/src/ol/interaction/Select.js @@ -80,7 +80,7 @@ const SelectEventType = { * @property {boolean} [multi=false] A boolean that determines if the default * behaviour should select only single features or all (overlapping) features at * the clicked map position. The default of `false` means single select. - * @property {module:ol/collection/Collection~Collection.} [features] + * @property {module:ol/Collection~Collection.} [features] * Collection where the interaction will place selected features. Optional. If * not set the interaction will create a collection. In any case the collection * used by the interaction is returned by @@ -278,7 +278,7 @@ Select.prototype.addFeatureLayerAssociation_ = function(feature, layer) { /** * Get the selected features. - * @return {module:ol/collection/Collection~Collection.} Features collection. + * @return {module:ol/Collection~Collection.} Features collection. * @api */ Select.prototype.getFeatures = function() { @@ -456,7 +456,7 @@ function getDefaultStyleFunction() { /** - * @param {module:ol/collection/Collection~CollectionEvent} evt Event. + * @param {module:ol/Collection~CollectionEvent} evt Event. * @private */ Select.prototype.addFeature_ = function(evt) { @@ -468,7 +468,7 @@ Select.prototype.addFeature_ = function(evt) { /** - * @param {module:ol/collection/Collection~CollectionEvent} evt Event. + * @param {module:ol/Collection~CollectionEvent} evt Event. * @private */ Select.prototype.removeFeature_ = function(evt) { diff --git a/src/ol/interaction/Snap.js b/src/ol/interaction/Snap.js index 7cca4dede5..6d3c1de186 100644 --- a/src/ol/interaction/Snap.js +++ b/src/ol/interaction/Snap.js @@ -35,7 +35,7 @@ import RBush from '../structs/RBush.js'; /** * @typedef {Object} Options - * @property {module:ol/collection/Collection~Collection.|undefined} features Snap to these features. Either this option or source should be provided. + * @property {module:ol/Collection~Collection.|undefined} features Snap to these features. Either this option or source should be provided. * @property {boolean|undefined} edge Snap to edges. Default is `true`. * @property {boolean|undefined} vertex Snap to vertices. Default is `true`. * @property {number|undefined} pixelTolerance Pixel tolerance for considering the pointer close enough to a segment or @@ -47,7 +47,7 @@ import RBush from '../structs/RBush.js'; /** * @classdesc * Handles snapping of vector features while modifying or drawing them. The - * features can come from a {@link module:ol/source/Vector~Vector} or {@link module:ol/collection/Collection~Collection} + * features can come from a {@link module:ol/source/Vector~Vector} or {@link module:ol/Collection~Collection} * Any interaction object that allows the user to interact * with the features using the mouse can benefit from the snapping, as long * as it is added before. @@ -97,7 +97,7 @@ const Snap = function(opt_options) { this.edge_ = options.edge !== undefined ? options.edge : true; /** - * @type {module:ol/collection/Collection~Collection.} + * @type {module:ol/Collection~Collection.} * @private */ this.features_ = options.features ? options.features : null; @@ -228,7 +228,7 @@ Snap.prototype.forEachFeatureRemove_ = function(feature) { /** - * @return {module:ol/collection/Collection~Collection.|Array.} Features. + * @return {module:ol/Collection~Collection.|Array.} Features. * @private */ Snap.prototype.getFeatures_ = function() { @@ -238,12 +238,12 @@ Snap.prototype.getFeatures_ = function() { } else if (this.source_) { features = this.source_.getFeatures(); } - return /** @type {!Array.|!module:ol/collection/Collection~Collection.} */ (features); + return /** @type {!Array.|!module:ol/Collection~Collection.} */ (features); }; /** - * @param {module:ol/source/Vector~Vector.Event|module:ol/collection/Collection~CollectionEvent} evt Event. + * @param {module:ol/source/Vector~Vector.Event|module:ol/Collection~CollectionEvent} evt Event. * @private */ Snap.prototype.handleFeatureAdd_ = function(evt) { @@ -258,7 +258,7 @@ Snap.prototype.handleFeatureAdd_ = function(evt) { /** - * @param {module:ol/source/Vector~Vector.Event|module:ol/collection/Collection~CollectionEvent} evt Event. + * @param {module:ol/source/Vector~Vector.Event|module:ol/Collection~CollectionEvent} evt Event. * @private */ Snap.prototype.handleFeatureRemove_ = function(evt) { diff --git a/src/ol/interaction/Translate.js b/src/ol/interaction/Translate.js index 69996082b9..8064f47802 100644 --- a/src/ol/interaction/Translate.js +++ b/src/ol/interaction/Translate.js @@ -39,7 +39,7 @@ const TranslateEventType = { /** * @typedef {Object} interaction_TranslateOptions - * @property {module:ol/collection/Collection~Collection.|undefined} features Only features contained in this collection will be able to be translated. If + * @property {module:ol/Collection~Collection.|undefined} features Only features contained in this collection will be able to be translated. If * not specified, all features on the map will be able to be translated. * @property {undefined|Array.|function(module:ol/layer/Layer~Layer): boolean} layers A list of layers from which features should be * translated. Alternatively, a filter function can be provided. The @@ -61,7 +61,7 @@ const TranslateEventType = { * @extends {module:ol/events/Event~Event} * @implements {oli.interaction.TranslateEvent} * @param {module:ol/interaction/Translate~TranslateEventType} type Type. - * @param {module:ol/collection/Collection~Collection.} features The features translated. + * @param {module:ol/Collection~Collection.} features The features translated. * @param {module:ol/coordinate~Coordinate} coordinate The event coordinate. */ export const TranslateEvent = function(type, features, coordinate) { @@ -70,7 +70,7 @@ export const TranslateEvent = function(type, features, coordinate) { /** * The features being translated. - * @type {module:ol/collection/Collection~Collection.} + * @type {module:ol/Collection~Collection.} * @api */ this.features = features; @@ -116,7 +116,7 @@ const Translate = function(opt_options) { /** - * @type {module:ol/collection/Collection~Collection.} + * @type {module:ol/Collection~Collection.} * @private */ this.features_ = options.features !== undefined ? options.features : null; From 4e89e5ed734519942a387b0c4b7cba1237c02d83 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 16 Mar 2018 17:30:23 +0100 Subject: [PATCH 23/24] Fix indentation --- src/ol/interaction/Extent.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ol/interaction/Extent.js b/src/ol/interaction/Extent.js index ac7a2834f8..2eb17c3397 100644 --- a/src/ol/interaction/Extent.js +++ b/src/ol/interaction/Extent.js @@ -34,17 +34,17 @@ import {createEditingStyle} from '../style/Style.js'; */ - /** - * @enum {string} - */ - const ExtentEventType = { - /** - * Triggered after the extent is changed - * @event module:ol/interaction/Extent~ExtentEventType#extentchanged - * @api - */ - EXTENTCHANGED: 'extentchanged' - }; +/** + * @enum {string} + */ +const ExtentEventType = { + /** + * Triggered after the extent is changed + * @event module:ol/interaction/Extent~ExtentEventType#extentchanged + * @api + */ + EXTENTCHANGED: 'extentchanged' +}; /** From b9999dfb357782486280391385828af748f1a4b1 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sun, 18 Mar 2018 15:08:40 +0100 Subject: [PATCH 24/24] Fix type typos --- src/ol/interaction/DragBox.js | 2 +- src/ol/interaction/DragRotateAndZoom.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/interaction/DragBox.js b/src/ol/interaction/DragBox.js index 55f20514ee..e1588ceb37 100644 --- a/src/ol/interaction/DragBox.js +++ b/src/ol/interaction/DragBox.js @@ -106,7 +106,7 @@ inherits(DragBoxEvent, Event); * This interaction is only supported for mouse devices. * * @constructor - * @extends {module:ol/interaction/Pointer} + * @extends {module:ol/interaction/Pointer~Pointer} * @fires module:ol/interaction/DragBox~DragBoxEvent * @param {module:ol/interaction/DragBox~Options=} opt_options Options. * @api diff --git a/src/ol/interaction/DragRotateAndZoom.js b/src/ol/interaction/DragRotateAndZoom.js index 0e30540b69..6bce4eda34 100644 --- a/src/ol/interaction/DragRotateAndZoom.js +++ b/src/ol/interaction/DragRotateAndZoom.js @@ -15,7 +15,7 @@ import PointerInteraction from '../interaction/Pointer.js'; * takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a * boolean to indicate whether that event should be handled. * Default is {@link module:ol/events/condition~shiftKeyOnly}. - * @property {number} [dura00tion=4] Animation duration in milliseconds. + * @property {number} [duration=400] Animation duration in milliseconds. */