Skip to content

Commit c3a1ced

Browse files
ozgesolidkeyclaude
andcommitted
Fix minimap viewport bounds and overscroll selection issues
- Clamp minimap viewport position to stay within minimap bounds - Add overscroll-behavior: none to html/body to prevent bounce - Add user-select: none to body and #app to prevent accidental selection - Prevent wheel scroll at boundaries to avoid triggering selection Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e328d0b commit c3a1ced

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/renderer/renderer.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ function createLogViewer(): void {
502502
logViewerElement.addEventListener('click', handleLogClick);
503503
logViewerElement.addEventListener('contextmenu', handleContextMenu);
504504

505-
// Mouse wheel zoom (Ctrl + scroll)
505+
// Mouse wheel zoom (Ctrl + scroll) and boundary scroll prevention
506506
logViewerElement.addEventListener('wheel', (e: WheelEvent) => {
507507
if (e.ctrlKey || e.metaKey) {
508508
e.preventDefault();
@@ -511,6 +511,16 @@ function createLogViewer(): void {
511511
} else {
512512
zoomOut();
513513
}
514+
return;
515+
}
516+
517+
// Prevent overscroll at boundaries to avoid selection issues
518+
const atTop = logViewerElement!.scrollTop <= 0;
519+
const atBottom = logViewerElement!.scrollTop >=
520+
logViewerElement!.scrollHeight - logViewerElement!.clientHeight;
521+
522+
if ((atTop && e.deltaY < 0) || (atBottom && e.deltaY > 0)) {
523+
e.preventDefault();
514524
}
515525
}, { passive: false });
516526
minimapElement.addEventListener('click', handleMinimapClick);
@@ -1095,11 +1105,14 @@ function updateMinimapViewport(): void {
10951105
const currentLine = scrollTopToLine(scrollTop);
10961106
const visibleLines = Math.ceil(clientHeight / getLineHeight());
10971107

1098-
const viewportTop = (currentLine / totalLines) * minimapHeight;
1099-
const viewportHeight = (visibleLines / totalLines) * minimapHeight;
1108+
const viewportHeight = Math.max(20, (visibleLines / totalLines) * minimapHeight);
1109+
let viewportTop = (currentLine / totalLines) * minimapHeight;
1110+
1111+
// Clamp viewport to stay within minimap bounds
1112+
viewportTop = Math.max(0, Math.min(viewportTop, minimapHeight - viewportHeight));
11001113

11011114
minimapViewportElement.style.top = `${viewportTop}px`;
1102-
minimapViewportElement.style.height = `${Math.max(20, viewportHeight)}px`;
1115+
minimapViewportElement.style.height = `${viewportHeight}px`;
11031116
}
11041117

11051118
function handleMinimapClick(event: MouseEvent): void {

src/renderer/styles.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
html, body {
3131
height: 100%;
3232
overflow: hidden;
33+
/* Prevent overscroll bounce and selection */
34+
overscroll-behavior: none;
3335
}
3436

3537
body {
@@ -38,6 +40,9 @@ body {
3840
background-color: var(--bg-primary);
3941
color: var(--text-primary);
4042
line-height: 1.4;
43+
/* Prevent accidental text selection during scroll */
44+
-webkit-user-select: none;
45+
user-select: none;
4146
}
4247

4348
/* Scrollbar */
@@ -64,6 +69,9 @@ body {
6469
display: flex;
6570
flex-direction: column;
6671
height: 100vh;
72+
/* Prevent selection during overscroll */
73+
-webkit-user-select: none;
74+
user-select: none;
6775
}
6876

6977
/* Toolbar */

0 commit comments

Comments
 (0)