feat: optimize scrolling performance and enhance control responsiveness in DesktopVideoPlayer

This commit is contained in:
kuekhaoyang
2025-11-18 13:10:42 +08:00
parent 0dbd02bef5
commit d92c2808c2
2 changed files with 37 additions and 4 deletions
+28 -3
View File
@@ -56,10 +56,13 @@ body {
background-color: var(--bg-color);
background-image: var(--bg-image);
background-attachment: fixed;
color: var(--text-color);
font-family: var(--font-family-system);
transition: background 0.3s ease;
/* Optimize scrolling performance */
will-change: scroll-position;
-webkit-overflow-scrolling: touch;
}
body.dark,
@@ -79,6 +82,14 @@ body.dark,
*, *::before, *::after {
box-sizing: border-box;
/* Optimize font rendering */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
html {
/* Enable smooth scrolling with performance optimization */
scroll-behavior: smooth;
}
@@ -270,14 +281,28 @@ body.dark,
border-radius: var(--radius-2xl);
box-shadow: var(--shadow-md);
border: 1px solid var(--glass-border);
transition: all var(--transition-fluid);
transition: transform var(--transition-fluid), box-shadow 0.2s ease;
/* Use GPU acceleration for smooth animations */
will-change: transform;
transform: translateZ(0);
}
.glass-card:hover {
transform: translateY(-5px) scale(1.02);
transform: translateY(-5px) scale(1.02) translateZ(0);
box-shadow: 0 8px 24px var(--shadow-color);
}
/* Optimize fixed/sticky elements for scrolling */
nav:where(.sticky, .fixed),
.sticky,
.fixed {
will-change: transform;
transform: translateZ(0);
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
}
.glass-input {
background: var(--glass-bg);
backdrop-filter: blur(10px) saturate(150%);
+9 -1
View File
@@ -50,6 +50,7 @@ export function DesktopVideoPlayer({
const volumeBarTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const isDraggingProgressRef = useRef(false);
const isDraggingVolumeRef = useRef(false);
const mouseMoveThrottleRef = useRef<NodeJS.Timeout | null>(null);
// Check for PiP and AirPlay support
useEffect(() => {
@@ -86,8 +87,15 @@ export function DesktopVideoPlayer({
};
}, [isPlaying, showSpeedMenu]);
// Handle mouse movement to show controls
// Handle mouse movement to show controls (throttled for performance)
const handleMouseMove = () => {
// Throttle mouse move events to improve performance
if (mouseMoveThrottleRef.current) return;
mouseMoveThrottleRef.current = setTimeout(() => {
mouseMoveThrottleRef.current = null;
}, 100); // Throttle to max 10 times per second
setShowControls(true);
if (controlsTimeoutRef.current) {
clearTimeout(controlsTimeoutRef.current);