Skip to content

Modern Docker Management, Designed for Everyone

fix: velocity to open nav sheet in mobile view

Kyle Mendell3d436a13ff78
diff --git a/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte b/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte
index dfc79ce00..0f1ca44ee 100644
--- a/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte
+++ b/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte
@@ -403,11 +403,11 @@
menuElement.style.overflowY = 'auto';
menuElement.style.touchAction = 'pan-y';
(menuElement.style as any).webkitOverflowScrolling = 'touch';
-
+
// Multiple layout recalculations to ensure content renders
// First recalculation
void menuElement.offsetHeight;
-
+
// Second recalculation after a frame
requestAnimationFrame(() => {
if (menuElement && open) {
@@ -467,7 +467,7 @@
interaction.isDragging && !isClosing ? 'transition-none' : 'transition-opacity duration-200'
)}
style={`
- ${interaction.isDragging && !isClosing ? `opacity: ${Math.max(0.1, 1 - interaction.dragDistance / 400)};` : ''}
+ opacity: ${interaction.isDragging && !isClosing ? Math.max(0.1, 1 - interaction.dragDistance / 400) : '1'};
touch-action: none;
-webkit-user-select: none;
user-select: none;
@@ -495,17 +495,18 @@
class={cn(
'bg-background/60 border-border/30 fixed inset-x-0 bottom-0 z-50 rounded-t-3xl border-t shadow-sm backdrop-blur-xl',
'max-h-[85vh] overflow-y-auto',
- interaction.isDragging && !isClosing ? 'transition-none' : ''
+ interaction.isDragging && !isClosing ? 'transition-none' : 'transition-transform duration-200 ease-out'
)}
style={`
touch-action: pan-y;
-webkit-overflow-scrolling: touch;
overscroll-behavior: contain;
scroll-behavior: smooth;
+ transform-origin: bottom center;
${
interaction.isDragging && !isClosing
? `transform: translateY(${interaction.dragDistance}px); opacity: ${Math.max(0.3, 1 - interaction.dragDistance / 300)};`
- : ''
+ : 'transform: translateY(0); opacity: 1;'
}
`}
data-testid="mobile-nav-sheet"
diff --git a/frontend/src/lib/components/mobile-nav/mobile-nav.svelte b/frontend/src/lib/components/mobile-nav/mobile-nav.svelte
index 3f44fe6b8..65801ab85 100644
--- a/frontend/src/lib/components/mobile-nav/mobile-nav.svelte
+++ b/frontend/src/lib/components/mobile-nav/mobile-nav.svelte
@@ -98,7 +98,7 @@
};
});
- // Swipe gesture detector for opening menu
+ // Swipe gesture detector for opening menu (touch devices swipe UP on nav bar)
const swipeDetector = new SwipeGestureDetector(
(direction: SwipeDirection) => {
if (direction === 'up') {
@@ -112,9 +112,11 @@
}
);
- // Trackpad scroll wheel handling to open menu
- let wheelScrollAccumulator = $state(0);
- let wheelScrollTimeout: ReturnType<typeof setTimeout> | null = null;
+ // Trackpad flick detection - ONLY super fast velocity flicks trigger the menu
+ let lastWheelTime = $state(0);
+ let lastWheelDelta = $state(0);
+ let flickDetectTimeout: ReturnType<typeof setTimeout> | null = null;
+ let wheelVelocityHistory: number[] = $state([]);
// Improved scroll-to-hide using native scroll events with passive listeners
$effect(() => {
@@ -160,50 +162,62 @@
}
};
- // Global wheel handler for trackpad scrolling to open menu
- const handleGlobalWheel = (e: WheelEvent) => {
+ // Wheel handler for detecting ONLY super fast trackpad flicks
+ const handleWheel = (e: WheelEvent) => {
if (menuOpen || !scrollToHideEnabled) return;
- // Only respond to upward scrolls (negative deltaY)
- if (e.deltaY < 0) {
- // Accumulate scroll distance
- wheelScrollAccumulator += Math.abs(e.deltaY);
+ // Only respond to downward scrolls (positive deltaY)
+ if (e.deltaY <= 0) return;
- // Clear previous timeout
- if (wheelScrollTimeout) {
- clearTimeout(wheelScrollTimeout);
- }
+ const now = Date.now();
+ const timeSinceLastWheel = now - lastWheelTime;
- // If accumulated scroll is enough, open menu
- if (wheelScrollAccumulator > 60) {
- menuOpen = true;
- wheelScrollAccumulator = 0;
- }
+ // Calculate velocity: deltaY per millisecond
+ const velocity = e.deltaY / Math.max(1, timeSinceLastWheel);
- // Reset accumulator after scroll ends
- wheelScrollTimeout = setTimeout(() => {
- wheelScrollAccumulator = 0;
- }, 300);
- } else {
- // Reset on downward scroll
- wheelScrollAccumulator = 0;
- if (wheelScrollTimeout) {
- clearTimeout(wheelScrollTimeout);
+ // Only trigger on EXTREME velocity (> 5 pixels per ms = very fast flick)
+ // Normal scrolling is typically 0.1-0.5 px/ms
+ // Fast flicks are 2+ px/ms
+ // Super fast flicks are 5+ px/ms
+ const isSuperFastFlick = velocity > 5;
+
+ if (isSuperFastFlick) {
+ menuOpen = true;
+ wheelVelocityHistory = [];
+
+ if (flickDetectTimeout) {
+ clearTimeout(flickDetectTimeout);
}
}
+
+ // Update tracking for next event
+ lastWheelTime = now;
+ lastWheelDelta = e.deltaY;
+ wheelVelocityHistory.push(velocity);
+ wheelVelocityHistory = wheelVelocityHistory.slice(-3); // Keep last 3 velocities
+
+ // Reset after 200ms of inactivity
+ if (flickDetectTimeout) {
+ clearTimeout(flickDetectTimeout);
+ }
+ flickDetectTimeout = setTimeout(() => {
+ lastWheelTime = 0;
+ lastWheelDelta = 0;
+ wheelVelocityHistory = [];
+ }, 200);
};
window.addEventListener('scroll', handleScroll, { passive: true });
- window.addEventListener('wheel', handleGlobalWheel, { passive: true });
+ window.addEventListener('wheel', handleWheel, { passive: true });
return () => {
window.removeEventListener('scroll', handleScroll);
- window.removeEventListener('wheel', handleGlobalWheel);
+ window.removeEventListener('wheel', handleWheel);
if (scrollTimeout) {
clearTimeout(scrollTimeout);
}
- if (wheelScrollTimeout) {
- clearTimeout(wheelScrollTimeout);
+ if (flickDetectTimeout) {
+ clearTimeout(flickDetectTimeout);
}
};
});
@@ -220,47 +234,8 @@
if (navElement) {
swipeDetector.setElement(navElement);
- // Handle trackpad/mouse wheel scrolling to open menu
- const handleWheel = (e: WheelEvent) => {
- if (menuOpen || !scrollToHideEnabled) return;
-
- // Only respond to upward scrolls
- if (e.deltaY < 0) {
- // Accumulate scroll distance
- wheelScrollAccumulator += Math.abs(e.deltaY);
-
- // Clear previous timeout
- if (wheelScrollTimeout) {
- clearTimeout(wheelScrollTimeout);
- }
-
- // If accumulated scroll is enough, open menu
- if (wheelScrollAccumulator > 60) {
- menuOpen = true;
- wheelScrollAccumulator = 0;
- }
-
- // Reset accumulator after scroll ends
- wheelScrollTimeout = setTimeout(() => {
- wheelScrollAccumulator = 0;
- }, 300);
- } else {
- // Reset on downward scroll
- wheelScrollAccumulator = 0;
- if (wheelScrollTimeout) {
- clearTimeout(wheelScrollTimeout);
- }
- }
- };
-
- navElement.addEventListener('wheel', handleWheel, { passive: true });
-
return () => {
swipeDetector.setElement(null);
- navElement.removeEventListener('wheel', handleWheel);
- if (wheelScrollTimeout) {
- clearTimeout(wheelScrollTimeout);
- }
};
}
});