Skip to content

Commit 1a9ebf6

Browse files
mvalancyclaude
andcommitted
Fix broken mouse wheel zoom functionality
- Replace problematic event filter approach with D3's wheelDelta method - Properly handle wheel events with deltaMode normalization - Restore mouse wheel zoom functionality while maintaining reversed direction - Scroll up = zoom in, scroll down = zoom out (intuitive behavior) - Applied to both empty canvas and main graph zoom behaviors 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c654c3d commit 1a9ebf6

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

packages/web/src/components/InteractiveGraphVisualization.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,13 +1166,9 @@ export function InteractiveGraphVisualization({ onResetLayout }: InteractiveGrap
11661166
// Create zoom behavior for empty canvas with reversed wheel direction
11671167
const zoom = d3.zoom<SVGSVGElement, unknown>()
11681168
.scaleExtent([0.1, 3])
1169-
.filter((event: any) => {
1170-
// Reverse mouse wheel direction for more intuitive zooming
1171-
// Scroll up = zoom in (deltaY negative), Scroll down = zoom out (deltaY positive)
1172-
if (event.type === 'wheel') {
1173-
event.deltaY = -event.deltaY;
1174-
}
1175-
return true;
1169+
.wheelDelta((event: WheelEvent) => {
1170+
// Reverse wheel direction: negative deltaY for zoom in, positive for zoom out
1171+
return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) * -1;
11761172
})
11771173
.on('zoom', (event) => {
11781174
const g = svg.select('g.main-graph-group');
@@ -1386,13 +1382,9 @@ export function InteractiveGraphVisualization({ onResetLayout }: InteractiveGrap
13861382
// Create or reuse zoom behavior with reversed wheel direction
13871383
const zoom = d3.zoom<SVGSVGElement, unknown>()
13881384
.scaleExtent([0.1, 4])
1389-
.filter((event: any) => {
1390-
// Reverse mouse wheel direction for more intuitive zooming
1391-
// Scroll up = zoom in (deltaY negative), Scroll down = zoom out (deltaY positive)
1392-
if (event.type === 'wheel') {
1393-
event.deltaY = -event.deltaY;
1394-
}
1395-
return true;
1385+
.wheelDelta((event: WheelEvent) => {
1386+
// Reverse wheel direction: negative deltaY for zoom in, positive for zoom out
1387+
return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) * -1;
13961388
});
13971389

13981390
const g = isFirstInit ? svg.append('g').attr('class', 'main-graph-group') : existingMainGroup;

0 commit comments

Comments
 (0)