Skip to content

Commit de7a7af

Browse files
committed
Disable map interactions when collapsed. Closes #21
1 parent 98f4a45 commit de7a7af

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/css/styles.scss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
@import
1+
@import
22
'abstracts/_variables.scss',
33
'abstracts/_mixins.scss';
4-
@import
4+
@import
55
'vendors/_leaflet.scss';
6-
@import
6+
@import
77
'components/_map.scss';
88

99

@@ -102,7 +102,7 @@
102102
width: 50%;
103103
padding: 0.75rem 0;
104104
border-bottom: 1px solid lighten($color-border-light, 2%);
105-
105+
106106
// no border on the nth-last(2) only if it's an odd number,
107107
// in case there's only one block in the last row
108108
&:nth-last-child(2):nth-child(odd),
@@ -210,10 +210,14 @@
210210
width: 200px;
211211
padding-top: 0;
212212
margin-top: 0;
213+
pointer-events: none;
213214
.leaflet-bottom.leaflet-right,
214215
.leaflet-top.leaflet-left {
215216
display: none;
216217
}
218+
.leaflet-marker-icon {
219+
cursor: default;
220+
}
217221
}
218222
}
219223
}
@@ -270,7 +274,7 @@
270274
}
271275
}
272276
}
273-
.leaflet-control-zoom-in, .leaflet-control-zoom-out {
277+
.leaflet-control-zoom-in, .leaflet-control-zoom-out {
274278
@include small-controls;
275279
}
276-
}
280+
}

src/field/Locator.vue

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ export default {
220220
this.$nextTick(() => {
221221
this.map.invalidateSize()
222222
this.map.setView(this.coords, this.defaultZoom)
223+
if(arg == 'closed' && this.marker) this.disableMapEvents()
224+
else if(arg == 'open' && this.marker) this.enableMapEvents()
223225
})
224226
},
225227
initMap() {
@@ -289,6 +291,7 @@ export default {
289291
autoPan: this.draggable,
290292
})
291293
this.map.addLayer(this.marker)
294+
if(this.filledStatus == 'closed') this.disableMapEvents()
292295
293296
this.marker.on('dragend', e => {
294297
let position = this.marker.getLatLng()
@@ -392,6 +395,30 @@ export default {
392395
},
393396
capitalize(str) {
394397
return str.charAt(0).toUpperCase() + str.slice(1);
398+
},
399+
disableMapEvents() {
400+
if(this.map) {
401+
this.map.scrollWheelZoom.disable()
402+
this.map.dragging.disable()
403+
this.map.touchZoom.disable()
404+
this.map.doubleClickZoom.disable()
405+
this.map.boxZoom.disable()
406+
this.map.keyboard.disable()
407+
if (this.map.tap) this.map.tap.disable()
408+
}
409+
if(this.marker) this.marker.dragging.disable()
410+
},
411+
enableMapEvents() {
412+
if(this.map) {
413+
this.map.scrollWheelZoom.enable()
414+
this.map.dragging.enable()
415+
this.map.touchZoom.enable()
416+
this.map.doubleClickZoom.enable()
417+
this.map.boxZoom.enable()
418+
this.map.keyboard.enable()
419+
if (this.map.tap) this.map.tap.enable()
420+
}
421+
if(this.marker) this.marker.dragging.enable()
395422
}
396423
},
397424
};

0 commit comments

Comments
 (0)