From bb0148d51f68a0d84fe8b130c1d9d0409eddc37e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Maria=20Mezzopera?= Date: Sat, 20 Apr 2019 21:48:15 +0200 Subject: [PATCH 1/3] feat: add ready event to all components --- src/components/LCircle.vue | 1 + src/components/LCircleMarker.vue | 1 + src/components/LControl.vue | 1 + src/components/LControlAttribution.vue | 1 + src/components/LControlLayers.vue | 1 + src/components/LControlScale.vue | 1 + src/components/LControlZoom.vue | 1 + src/components/LFeatureGroup.vue | 1 + src/components/LGeoJson.vue | 1 + src/components/LGridLayer.vue | 1 + src/components/LIcon.vue | 1 + src/components/LIconDefault.vue | 1 + src/components/LImageOverlay.vue | 1 + src/components/LLayerGroup.vue | 1 + src/components/LMap.vue | 2 ++ src/components/LMarker.vue | 1 + src/components/LPolygon.vue | 1 + src/components/LPolyline.vue | 1 + src/components/LPopup.vue | 1 + src/components/LRectangle.vue | 1 + src/components/LTileLayer.vue | 1 + src/components/LTooltip.vue | 1 + src/components/LWMSTileLayer.vue | 1 + 23 files changed, 24 insertions(+) diff --git a/src/components/LCircle.vue b/src/components/LCircle.vue index 7839c950..5e29379b 100644 --- a/src/components/LCircle.vue +++ b/src/components/LCircle.vue @@ -31,6 +31,7 @@ export default { this.ready = true; this.parentContainer = findRealParent(this.$parent); this.parentContainer.addLayer(this, !this.visible); + this.$emit('ready', this.mapObject); }, methods: {} }; diff --git a/src/components/LCircleMarker.vue b/src/components/LCircleMarker.vue index 17bc0020..c9fe993e 100644 --- a/src/components/LCircleMarker.vue +++ b/src/components/LCircleMarker.vue @@ -35,6 +35,7 @@ export default { this.ready = true; this.parentContainer = findRealParent(this.$parent); this.parentContainer.addLayer(this, !this.visible); + this.$emit('ready', this.mapObject); } }; diff --git a/src/components/LControl.vue b/src/components/LControl.vue index 403cf53d..f635f5f7 100644 --- a/src/components/LControl.vue +++ b/src/components/LControl.vue @@ -29,6 +29,7 @@ export default { this.parentContainer = findRealParent(this.$parent); this.mapObject.setElement(this.$el); this.mapObject.addTo(this.parentContainer.mapObject); + this.$emit('ready', this.mapObject); } }; diff --git a/src/components/LControlAttribution.vue b/src/components/LControlAttribution.vue index a3f9088a..92ab272a 100644 --- a/src/components/LControlAttribution.vue +++ b/src/components/LControlAttribution.vue @@ -21,6 +21,7 @@ export default { this.mapObject = control.attribution(options); propsBinder(this, this.mapObject, this.$options.props); this.mapObject.addTo(this.$parent.mapObject); + this.$emit('ready', this.mapObject); }, render () { return null; diff --git a/src/components/LControlLayers.vue b/src/components/LControlLayers.vue index 523b5748..9e6cea93 100644 --- a/src/components/LControlLayers.vue +++ b/src/components/LControlLayers.vue @@ -41,6 +41,7 @@ export default { this.mapObject = control.layers(null, null, options); propsBinder(this, this.mapObject, this.$options.props); this.$parent.registerLayerControl(this); + this.$emit('ready', this.mapObject); }, methods: { addLayer (layer) { diff --git a/src/components/LControlScale.vue b/src/components/LControlScale.vue index b72e7b05..2c747a76 100644 --- a/src/components/LControlScale.vue +++ b/src/components/LControlScale.vue @@ -36,6 +36,7 @@ export default { this.mapObject = control.scale(options); propsBinder(this, this.mapObject, this.$options.props); this.mapObject.addTo(this.$parent.mapObject); + this.$emit('ready', this.mapObject); }, render () { return null; diff --git a/src/components/LControlZoom.vue b/src/components/LControlZoom.vue index 4980ac69..e64b0583 100644 --- a/src/components/LControlZoom.vue +++ b/src/components/LControlZoom.vue @@ -36,6 +36,7 @@ export default { this.mapObject = control.zoom(options); propsBinder(this, this.mapObject, this.$options.props); this.mapObject.addTo(this.$parent.mapObject); + this.$emit('ready', this.mapObject); }, render () { return null; diff --git a/src/components/LFeatureGroup.vue b/src/components/LFeatureGroup.vue index 8042d7ed..8ee199cb 100644 --- a/src/components/LFeatureGroup.vue +++ b/src/components/LFeatureGroup.vue @@ -26,6 +26,7 @@ export default { if (this.visible) { this.parentContainer.addLayer(this); } + this.$emit('ready', this.mapObject); } }; diff --git a/src/components/LGeoJson.vue b/src/components/LGeoJson.vue index 18a4834e..edc1b455 100644 --- a/src/components/LGeoJson.vue +++ b/src/components/LGeoJson.vue @@ -37,6 +37,7 @@ export default { propsBinder(this, this.mapObject, this.$options.props); this.parentContainer = findRealParent(this.$parent, true); this.parentContainer.addLayer(this, !this.visible); + this.$emit('ready', this.mapObject); }, beforeDestroy () { this.parentContainer.mapObject.removeLayer(this.mapObject); diff --git a/src/components/LGridLayer.vue b/src/components/LGridLayer.vue index bb3377d3..2b7ba77f 100644 --- a/src/components/LGridLayer.vue +++ b/src/components/LGridLayer.vue @@ -43,6 +43,7 @@ export default { this.mapObject.createTile = this.createTile; this.parentContainer = findRealParent(this.$parent); this.parentContainer.addLayer(this, !this.visible); + this.$emit('ready', this.mapObject); }, beforeDestroy () { this.parentContainer.removeLayer(this.mapObject); diff --git a/src/components/LIcon.vue b/src/components/LIcon.vue index 67091757..eeab698d 100644 --- a/src/components/LIcon.vue +++ b/src/components/LIcon.vue @@ -101,6 +101,7 @@ export default { ); this.scheduleCreateIcon(); + this.$emit('ready', this.mapObject); }, beforeDestroy () { diff --git a/src/components/LIconDefault.vue b/src/components/LIconDefault.vue index d9a4b398..ab0e1c77 100644 --- a/src/components/LIconDefault.vue +++ b/src/components/LIconDefault.vue @@ -14,6 +14,7 @@ export default { mounted () { Icon.Default.imagePath = this.imagePath; propsBinder(this, this.mapObject, this.$options.props); + this.$emit('ready', this.mapObject); }, methods: { setImagePath (newVal, oldVal) { diff --git a/src/components/LImageOverlay.vue b/src/components/LImageOverlay.vue index 3dba5d38..12f29246 100644 --- a/src/components/LImageOverlay.vue +++ b/src/components/LImageOverlay.vue @@ -13,6 +13,7 @@ export default { propsBinder(this, this.mapObject, this.$options.props); this.parentContainer = findRealParent(this.$parent); this.parentContainer.addLayer(this, !this.visible); + this.$emit('ready', this.mapObject); }, render () { return null; diff --git a/src/components/LLayerGroup.vue b/src/components/LLayerGroup.vue index 84359024..3f1eb7a7 100644 --- a/src/components/LLayerGroup.vue +++ b/src/components/LLayerGroup.vue @@ -26,6 +26,7 @@ export default { if (this.visible) { this.parentContainer.addLayer(this); } + this.$emit('ready', this.mapObject); } }; diff --git a/src/components/LMap.vue b/src/components/LMap.vue index 9492c8d8..38a0ebc6 100644 --- a/src/components/LMap.vue +++ b/src/components/LMap.vue @@ -156,7 +156,9 @@ export default { DomEvent.on(this.mapObject, this.$listeners); propsBinder(this, this.mapObject, this.$options.props); this.ready = true; + // DEPRECATED leaflet:load this.$emit('leaflet:load'); + this.$emit('ready', this.mapObject); }, methods: { registerLayerControl (lControlLayers) { diff --git a/src/components/LMarker.vue b/src/components/LMarker.vue index 34c3dbde..7b966164 100644 --- a/src/components/LMarker.vue +++ b/src/components/LMarker.vue @@ -52,6 +52,7 @@ export default { this.parentContainer = findRealParent(this.$parent); this.parentContainer.addLayer(this, !this.visible); this.ready = true; + this.$emit('ready', this.mapObject); }, methods: { setDraggable (newVal, oldVal) { diff --git a/src/components/LPolygon.vue b/src/components/LPolygon.vue index 17049425..1a21abd9 100644 --- a/src/components/LPolygon.vue +++ b/src/components/LPolygon.vue @@ -31,6 +31,7 @@ export default { this.ready = true; this.parentContainer = findRealParent(this.$parent); this.parentContainer.addLayer(this, !this.visible); + this.$emit('ready', this.mapObject); } }; diff --git a/src/components/LPolyline.vue b/src/components/LPolyline.vue index 6957838f..c14990e1 100644 --- a/src/components/LPolyline.vue +++ b/src/components/LPolyline.vue @@ -31,6 +31,7 @@ export default { this.ready = true; this.parentContainer = findRealParent(this.$parent); this.parentContainer.addLayer(this, !this.visible); + this.$emit('ready', this.mapObject); } }; diff --git a/src/components/LPopup.vue b/src/components/LPopup.vue index a608aa16..f95f1521 100644 --- a/src/components/LPopup.vue +++ b/src/components/LPopup.vue @@ -24,6 +24,7 @@ export default { this.mapObject.setContent(this.content || this.$el); this.parentContainer = findRealParent(this.$parent); this.parentContainer.mapObject.bindPopup(this.mapObject); + this.$emit('ready', this.mapObject); }, beforeDestroy () { if (this.parentContainer) { diff --git a/src/components/LRectangle.vue b/src/components/LRectangle.vue index c664013e..2ed27279 100644 --- a/src/components/LRectangle.vue +++ b/src/components/LRectangle.vue @@ -31,6 +31,7 @@ export default { this.ready = true; this.parentContainer = findRealParent(this.$parent); this.parentContainer.addLayer(this, !this.visible); + this.$emit('ready', this.mapObject); } }; diff --git a/src/components/LTileLayer.vue b/src/components/LTileLayer.vue index 08f25d70..b876e4bc 100644 --- a/src/components/LTileLayer.vue +++ b/src/components/LTileLayer.vue @@ -28,6 +28,7 @@ export default { propsBinder(this, this.mapObject, this.$options.props); this.parentContainer = findRealParent(this.$parent); this.parentContainer.addLayer(this, !this.visible); + this.$emit('ready', this.mapObject); } }; diff --git a/src/components/LTooltip.vue b/src/components/LTooltip.vue index 5fdcb657..89e0203c 100644 --- a/src/components/LTooltip.vue +++ b/src/components/LTooltip.vue @@ -15,6 +15,7 @@ export default { this.mapObject.setContent(this.content || this.$el); this.parentContainer = findRealParent(this.$parent); this.parentContainer.mapObject.bindTooltip(this.mapObject); + this.$emit('ready', this.mapObject); }, beforeDestroy () { if (this.parentContainer) { diff --git a/src/components/LWMSTileLayer.vue b/src/components/LWMSTileLayer.vue index 3a4004d6..9481153b 100644 --- a/src/components/LWMSTileLayer.vue +++ b/src/components/LWMSTileLayer.vue @@ -20,6 +20,7 @@ export default { propsBinder(this, this.mapObject, this.$options.props); this.parentContainer = findRealParent(this.$parent); this.parentContainer.addLayer(this, !this.visible); + this.$emit('ready', this.mapObject); } }; From 772d9bf16affece9c54725bef0b86f8552ec8765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Maria=20Mezzopera?= Date: Sat, 20 Apr 2019 21:49:19 +0200 Subject: [PATCH 2/3] lint: self closing tag on img --- examples/src/components/LoadTest.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/components/LoadTest.vue b/examples/src/components/LoadTest.vue index 13b70a31..b9dbea85 100644 --- a/examples/src/components/LoadTest.vue +++ b/examples/src/components/LoadTest.vue @@ -23,7 +23,7 @@ + > From 20177ff3c28f90feb3883411aa1f10a3ffbc4fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Maria=20Mezzopera?= Date: Sat, 20 Apr 2019 21:49:36 +0200 Subject: [PATCH 3/3] feat: add ready events to the docs --- docs/components/events-notice.md | 1 - docs/components/l-circle-marker/README.md | 4 +--- docs/components/l-circle/README.md | 4 +--- docs/components/l-control-attribution/README.md | 4 +--- docs/components/l-control-layers/README.md | 4 +--- docs/components/l-control-scale/README.md | 4 +--- docs/components/l-control-zoom/README.md | 4 +--- docs/components/l-control/README.md | 4 +--- docs/components/l-feature-group/README.md | 4 +--- docs/components/l-geo-json/README.md | 4 +--- docs/components/l-grid-layer/README.md | 3 +-- docs/components/l-icon/README.md | 4 +--- docs/components/l-image-overlay/README.md | 4 +--- docs/components/l-map/README.md | 4 ++-- docs/components/l-marker/README.md | 2 +- docs/components/l-polygon/README.md | 4 +--- docs/components/l-polyline/README.md | 4 +--- docs/components/l-popup/README.md | 4 +--- docs/components/l-rectangle/README.md | 4 +--- docs/components/l-tile-layer/README.md | 4 +--- docs/components/l-tooltip/README.md | 4 +--- docs/components/l-wms-tile-layer/README.md | 4 +--- docs/components/shared-events.md | 3 +++ 23 files changed, 25 insertions(+), 60 deletions(-) delete mode 100644 docs/components/events-notice.md create mode 100644 docs/components/shared-events.md diff --git a/docs/components/events-notice.md b/docs/components/events-notice.md deleted file mode 100644 index ff0f9bc1..00000000 --- a/docs/components/events-notice.md +++ /dev/null @@ -1 +0,0 @@ -All native leaflet events are passed through, e.g. `@leafletevent="..."`. diff --git a/docs/components/l-circle-marker/README.md b/docs/components/l-circle-marker/README.md index 2fe22011..2cb5fb36 100644 --- a/docs/components/l-circle-marker/README.md +++ b/docs/components/l-circle-marker/README.md @@ -69,9 +69,7 @@ export default { ## Events -`l-circle-marker` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-circle/README.md b/docs/components/l-circle/README.md index 0531001d..deba8c84 100644 --- a/docs/components/l-circle/README.md +++ b/docs/components/l-circle/README.md @@ -65,9 +65,7 @@ export default { ## Events -`l-circle` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-control-attribution/README.md b/docs/components/l-control-attribution/README.md index 696a6629..c3151e39 100644 --- a/docs/components/l-control-attribution/README.md +++ b/docs/components/l-control-attribution/README.md @@ -57,9 +57,7 @@ export default { ## Events -`l-control-attribution` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-control-layers/README.md b/docs/components/l-control-layers/README.md index 1ed50089..15b105b7 100644 --- a/docs/components/l-control-layers/README.md +++ b/docs/components/l-control-layers/README.md @@ -93,9 +93,7 @@ export default { ## Events -`l-control-layers` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-control-scale/README.md b/docs/components/l-control-scale/README.md index 8769675f..274781b6 100644 --- a/docs/components/l-control-scale/README.md +++ b/docs/components/l-control-scale/README.md @@ -67,9 +67,7 @@ export default { ## Events -`l-control-scale` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-control-zoom/README.md b/docs/components/l-control-zoom/README.md index a29ad006..e1a39d6e 100644 --- a/docs/components/l-control-zoom/README.md +++ b/docs/components/l-control-zoom/README.md @@ -69,9 +69,7 @@ export default { ## Events -`l-control-zoom` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-control/README.md b/docs/components/l-control/README.md index 0ad8530f..43b43020 100644 --- a/docs/components/l-control/README.md +++ b/docs/components/l-control/README.md @@ -58,9 +58,7 @@ export default { ## Events -`l-control` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-feature-group/README.md b/docs/components/l-feature-group/README.md index 38952fac..a8dd3939 100644 --- a/docs/components/l-feature-group/README.md +++ b/docs/components/l-feature-group/README.md @@ -75,9 +75,7 @@ export default { ## Events -`l-feature-group` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-geo-json/README.md b/docs/components/l-geo-json/README.md index 911f784e..b35a0040 100644 --- a/docs/components/l-geo-json/README.md +++ b/docs/components/l-geo-json/README.md @@ -77,9 +77,7 @@ export default { ## Events -`l-geo-json` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-grid-layer/README.md b/docs/components/l-grid-layer/README.md index 32e260d2..ee64c276 100644 --- a/docs/components/l-grid-layer/README.md +++ b/docs/components/l-grid-layer/README.md @@ -70,11 +70,10 @@ export default { ## Events -`l-grid-layer` does emit any event on his own. Leaflet's `tileunload` event is internally used to trigger the destruction of the tile components when a tile leaves the visible area. -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-icon/README.md b/docs/components/l-icon/README.md index 06850e70..e959d40c 100644 --- a/docs/components/l-icon/README.md +++ b/docs/components/l-icon/README.md @@ -152,6 +152,4 @@ export default { ## Events -`l-icon` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') diff --git a/docs/components/l-image-overlay/README.md b/docs/components/l-image-overlay/README.md index 98264654..ba61bbe9 100644 --- a/docs/components/l-image-overlay/README.md +++ b/docs/components/l-image-overlay/README.md @@ -64,9 +64,7 @@ export default { ## Events -`l-image-overlay` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-map/README.md b/docs/components/l-map/README.md index 98331f12..22a2395b 100644 --- a/docs/components/l-map/README.md +++ b/docs/components/l-map/README.md @@ -169,14 +169,14 @@ export default { ## Events -* **leaflet:load** - emitted when the leaflet map instance is ready +* **leaflet:load** - emitted when the leaflet map instance is ready **This Event is deprecated in favour of `ready`** * **update:zoom** - emitted when the zoom of the map changes - `update:zoom` is emitted together with a `Number` value representing the current `zoom` * **update:center** - emitted when the center of the map changes - `update:center` is emitted together with an instance of `L.LatLng` value representing the current `center` [L.latLng](https://leafletjs.com/reference-1.3.0.html#latlng) * **update:bounds** - emitted when the bounds of the map changes - `update:bounds` is emitted together with an instance of `L.latLngBounds` value representing the current `bound` [L.latLngBounds](https://leafletjs.com/reference-1.3.0.html#latlngbounds) !> **update:zoom**, **update:center**, **update:bounds** are all debounced events based on `leaflet` `moveend` event and support `sync` modifier -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-marker/README.md b/docs/components/l-marker/README.md index 974c8b3d..ea58eaaa 100644 --- a/docs/components/l-marker/README.md +++ b/docs/components/l-marker/README.md @@ -79,7 +79,7 @@ export default { !> **update:latlng** support `sync` modifier -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-polygon/README.md b/docs/components/l-polygon/README.md index 55ae5f5a..34174f12 100644 --- a/docs/components/l-polygon/README.md +++ b/docs/components/l-polygon/README.md @@ -63,9 +63,7 @@ export default { ## Events -`l-polygon` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-polyline/README.md b/docs/components/l-polyline/README.md index 1e56c1f4..854ac4ab 100644 --- a/docs/components/l-polyline/README.md +++ b/docs/components/l-polyline/README.md @@ -63,9 +63,7 @@ export default { ## Events -`l-polyline` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-popup/README.md b/docs/components/l-popup/README.md index 0b2ffefd..b254dec1 100644 --- a/docs/components/l-popup/README.md +++ b/docs/components/l-popup/README.md @@ -60,9 +60,7 @@ export default { ## Events -`l-popup` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-rectangle/README.md b/docs/components/l-rectangle/README.md index 03c4b597..e11ba454 100644 --- a/docs/components/l-rectangle/README.md +++ b/docs/components/l-rectangle/README.md @@ -63,9 +63,7 @@ export default { ## Events -`l-rectangle` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-tile-layer/README.md b/docs/components/l-tile-layer/README.md index 9beac5bf..59dfe43b 100644 --- a/docs/components/l-tile-layer/README.md +++ b/docs/components/l-tile-layer/README.md @@ -57,9 +57,7 @@ export default { ## Events -`l-tile-layer` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-tooltip/README.md b/docs/components/l-tooltip/README.md index 685dd406..aa4fcfd4 100644 --- a/docs/components/l-tooltip/README.md +++ b/docs/components/l-tooltip/README.md @@ -53,9 +53,7 @@ export default { ## Events -`l-tooltip` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/l-wms-tile-layer/README.md b/docs/components/l-wms-tile-layer/README.md index ca480adc..0d087f6a 100644 --- a/docs/components/l-wms-tile-layer/README.md +++ b/docs/components/l-wms-tile-layer/README.md @@ -81,9 +81,7 @@ export default { ## Events -`l-wms-tile-layer` does not emit any event on his own. - -[filename](../events-notice.md ':include') +[filename](../shared-events.md ':include') ## Extends diff --git a/docs/components/shared-events.md b/docs/components/shared-events.md new file mode 100644 index 00000000..764bb2e2 --- /dev/null +++ b/docs/components/shared-events.md @@ -0,0 +1,3 @@ +* **ready** - emitted when the component is ready, - `ready` is emitted togheter with the `mapObject` dictionary that contains the underlying `leaflet` instance + +All native leaflet events are passed through, e.g. `@leafletevent="..."`.