Skip to content

Commit

Permalink
more Vue 3 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
limenet committed Mar 14, 2021
1 parent 2e81dbe commit d927afd
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 30 deletions.
22 changes: 10 additions & 12 deletions src/components/UI/Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,15 @@ export default {

this.marker = new marker(markerOptions);

if (this.$attrs["onUpdate:coordinates"]) {
this.marker.on("dragend", event => {
let newCoordinates;
if (this.coordinates instanceof Array) {
newCoordinates = [event.target._lngLat.lng, event.target._lngLat.lat];
} else {
newCoordinates = event.target._lngLat;
}
this.$emit("update:coordinates", newCoordinates);
});
}
this.marker.on("dragend", event => {
let newCoordinates;
if (this.coordinates instanceof Array) {
newCoordinates = [event.target._lngLat.lng, event.target._lngLat.lat];
} else {
newCoordinates = event.target._lngLat;
}
this.$emit("update:coordinates", newCoordinates);
});

this.$_bindSelfEvents(markerEvents, this.marker);

Expand Down Expand Up @@ -151,5 +149,5 @@ export default {
[this.$slots.marker, this.marker ? this.$slots.default : null]
);
},
emits: ["removed", "added"]
emits: ["removed", "added", "dragend", "update:coordinates"]
};
2 changes: 1 addition & 1 deletion src/components/layer/GeojsonLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default {
created() {
if (this.source) {
this.$watch(
"source.data",
() => this.source.data,
function(next) {
if (this.initial) return;
this.mapSource.setData(next);
Expand Down
4 changes: 2 additions & 2 deletions src/components/layer/ImageLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
if (this.source) {
if (this.source.coordinates) {
this.$watch(
"source.coordinates",
() => this.source.coordinates,
function(next) {
if (this.initial) return;
if (next) {
Expand All @@ -22,7 +22,7 @@ export default {

if (this.source.url) {
this.$watch(
"source.url",
() => this.source.url,
function(next) {
if (this.initial) return;
if (next) {
Expand Down
11 changes: 7 additions & 4 deletions src/components/layer/VideoLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ export default {

created() {
if (this.source && this.source.coordinates) {
this.$watch("source.coordinates", function(next) {
if (this.initial) return;
this.mapSource.setCoordinates(next);
});
this.$watch(
() => this.source.coordinates,
function(next) {
if (this.initial) return;
this.mapSource.setCoordinates(next);
}
);
}
this.$_deferredMount();
},
Expand Down
28 changes: 17 additions & 11 deletions src/components/layer/layerMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,28 @@ export default {

created() {
if (this.layer.minzoom) {
this.$watch("layer.minzoom", function(next) {
if (this.initial) return;
this.map().setLayerZoomRange(this.layerId, next, this.layer.maxzoom);
});
this.$watch(
() => this.layer.minzoom,
function(next) {
if (this.initial) return;
this.map().setLayerZoomRange(this.layerId, next, this.layer.maxzoom);
}
);
}

if (this.layer.maxzoom) {
this.$watch("layer.maxzoom", function(next) {
if (this.initial) return;
this.map().setLayerZoomRange(this.layerId, this.layer.minzoom, next);
});
this.$watch(
() => this.layer.maxzoom,
function(next) {
if (this.initial) return;
this.map().setLayerZoomRange(this.layerId, this.layer.minzoom, next);
}
);
}

if (this.layer.paint) {
this.$watch(
"layer.paint",
() => this.layer.paint,
function(next) {
if (this.initial) return;
if (next) {
Expand All @@ -102,7 +108,7 @@ export default {

if (this.layer.layout) {
this.$watch(
"layer.layout",
() => this.layer.layout,
function(next) {
if (this.initial) return;
if (next) {
Expand All @@ -117,7 +123,7 @@ export default {

if (this.layer.filter) {
this.$watch(
"layer.filter",
() => this.layer.filter,
function(next) {
if (this.initial) return;
this.map().setFilter(this.layerId, next);
Expand Down

0 comments on commit d927afd

Please sign in to comment.