WIP: Leaflet Map: disable zoom while scrolling

Hi there,

usually i build leaflet maps by code, so i gave the map element in bricks a try.
I am currently missing the option to disable scroll zoom while scrolling – which is imho is essential (escpeccially on mobile devices).
Where is that option?

Thanks in advance.

Any thoughts on this?

I solved with javascript:

<script>
document.addEventListener('wheel', function(event) {
  if (event.target.closest('.brxe-map-leaflet')) {
    if (!event.ctrlKey) {
      event.stopPropagation(); 
    }
  }
}, true); 
</script>

Thanks for the reply, but imho that’s no clean solution.

Hi @larsactionhero,

I think this is a good suggestion. I’ll add it to the internal feature request tracker :slight_smile:

As far as I see, this is the control that we would need to implement, right?

Best regards,
Matej

2 Likes

yes exactly. It will be usefull.

Hi @Matej,

thanks for the reply…exactly.

At least a boolean is required in the settings which toggles the config setting.
I usually implemented leaflet maps by code and went this way to detect if a device is mobile/touch and set scrollWheelZoom option along this value.

Btw i wrote an hoversizedetect js lib for that case which executes a kind-of mobile/touch-device detection and returns a boolean.

(any other detection for a Boolean to be passed as param is also fine :blush:).

const isMobile = BOOLEAN_VALUE_HERE
const map = L.map(mapElement, {
  scrollWheelZoom: !isMobile, // false if isMobile=true – so scrollWheelZoom is disabled on mobile/touch devices
});