Skip to content

Commit c654c3d

Browse files
mvalancyclaude
andcommitted
Fix reversed mouse wheel zoom direction in graph visualization
- Add wheel event filter to reverse deltaY for more intuitive zooming - Scroll up now zooms IN (expected behavior for most users) - Scroll down now zooms OUT (matches desktop app conventions) - Applied to both empty canvas and main graph zoom behaviors - Maintains all other zoom functionality (pan, pinch, etc.) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 25abdcf commit c654c3d

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

packages/web/src/components/InteractiveGraphVisualization.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,9 +1163,17 @@ export function InteractiveGraphVisualization({ onResetLayout }: InteractiveGrap
11631163

11641164
svg.attr('width', width).attr('height', height);
11651165

1166-
// Create zoom behavior for empty canvas
1166+
// 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;
1176+
})
11691177
.on('zoom', (event) => {
11701178
const g = svg.select('g.main-graph-group');
11711179
if (!g.empty()) {
@@ -1375,9 +1383,17 @@ export function InteractiveGraphVisualization({ onResetLayout }: InteractiveGrap
13751383

13761384
svg.attr('width', width).attr('height', height);
13771385

1378-
// Create or reuse zoom behavior
1386+
// Create or reuse zoom behavior with reversed wheel direction
13791387
const zoom = d3.zoom<SVGSVGElement, unknown>()
1380-
.scaleExtent([0.1, 4]);
1388+
.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;
1396+
});
13811397

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

0 commit comments

Comments
 (0)