Skip to content

Real-time dashboard for monitoring global news, markets, and geopolitical events

TypeScript

Disable scroll wheel zoom on map, keep pinch and buttons

Sean Thielen-Esparza932cb3e86281
diff --git a/src/lib/components/panels/MapPanel.svelte b/src/lib/components/panels/MapPanel.svelte
index 0bdb6cf..1342044 100644
--- a/src/lib/components/panels/MapPanel.svelte
+++ b/src/lib/components/panels/MapPanel.svelte
@@ -223,10 +223,22 @@
mapGroup = svg.append('g').attr('id', 'mapGroup');
- // Setup zoom
+ // Setup zoom - disable scroll wheel, allow touch pinch and buttons
zoom = d3
.zoom<SVGSVGElement, unknown>()
.scaleExtent([1, 6])
+ .filter((event) => {
+ // Block scroll wheel zoom (wheel events)
+ if (event.type === 'wheel') return false;
+ // Allow touch events (pinch zoom on mobile)
+ if (event.type.startsWith('touch')) return true;
+ // Allow mouse drag for panning
+ if (event.type === 'mousedown' || event.type === 'mousemove') return true;
+ // Block double-click zoom
+ if (event.type === 'dblclick') return false;
+ // Allow other events (programmatic zoom from buttons)
+ return true;
+ })
.on('zoom', (event) => {
mapGroup.attr('transform', event.transform.toString());
});