fix: adjust bug logo carry start position for mobile viewport

- Detect mobile viewport using media query
- Use centered horizontal position for mobile (logo is in top header)
- Keep original sidebar position for desktop
- Fixes bug carrying animation not working on mobile devices
This commit is contained in:
xmanrui
2026-03-03 19:42:12 +08:00
parent 2411134a5a
commit 08e83b12fe
+17 -3
View File
@@ -49,9 +49,23 @@ export function GlobalBugsOverlay() {
const onConfigChanged = () => applyConfig();
const onLogoDragStart = () => {
if (!systemRef.current) return;
// Sidebar logo anchor (approximate screen space), target off-screen bottom-right.
const startX = 58 / BUGS_ZOOM;
const startY = 42 / BUGS_ZOOM;
// Detect mobile viewport
const isMobile = window.matchMedia("(max-width: 767px)").matches;
// Calculate logo position based on viewport
let startX: number;
let startY: number;
if (isMobile) {
// Mobile: logo is in top header, centered horizontally
startX = (window.innerWidth / 2) / BUGS_ZOOM;
startY = 28 / BUGS_ZOOM; // Half of header height (h-14 = 56px)
} else {
// Desktop: logo is in left sidebar
startX = 58 / BUGS_ZOOM;
startY = 42 / BUGS_ZOOM;
}
const targetX = (window.innerWidth + 180) / BUGS_ZOOM;
const targetY = (window.innerHeight + 160) / BUGS_ZOOM;
systemRef.current.startLogoCarry(startX, startY, targetX, targetY);