Skip to content

Commit f3d4c5c

Browse files
Allow GeojsonMap to resize smaller (#1383)
1 parent 9143d8e commit f3d4c5c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/components/geojson-map.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,24 +223,34 @@ const removeFeatures = () => {
223223
// RESIZE MAP
224224
225225
const resize = () => {
226+
log('resizing map');
227+
226228
const { sizer } = props;
227229
const result = sizer();
228230
if (result != null) {
231+
log('return value from sizer prop:', result);
229232
// Here, we set the element's min-height, not its full height.
230233
// .map-container also has a min-height, and if that's greater than the
231234
// min-height here, the element will be taller than its min-height.
232235
el.value.style.minHeight = typeof result === 'number'
233236
? (result > 0 ? px(result) : '')
234237
: result;
235238
}
239+
log('min-height of .geojson-map:', el.value.style.minHeight);
236240
237241
// .map-container seems to need a concrete height to be set on it (e.g.,
238-
// setting `height: 100%;` in CSS didn't work).
239-
mapContainer.value.style.height = px(el.value.getBoundingClientRect().height);
242+
// setting `height: 100%;` in CSS didn't work). Before setting it, we first
243+
// unset it: we need to undo any previous resize() call before recalculating
244+
// the height.
245+
mapContainer.value.style.height = '';
246+
const newHeight = px(el.value.getBoundingClientRect().height);
247+
mapContainer.value.style.height = newHeight;
248+
log('height of .map-container:', newHeight);
240249
241-
const oldSize = mapInstance.getSize();
242250
mapInstance.updateSize();
243-
if (!equals(mapInstance.getSize(), oldSize)) log('resized');
251+
log('size of mapInstance:', mapInstance.getSize());
252+
253+
log('done resizing');
244254
};
245255
246256

0 commit comments

Comments
 (0)