diff --git a/src/hooks/useSwipeControls.ts b/src/hooks/useSwipeControls.ts index 824afc4..a466315 100644 --- a/src/hooks/useSwipeControls.ts +++ b/src/hooks/useSwipeControls.ts @@ -41,6 +41,12 @@ export const useSwipeControls = ({ useEffect(() => { if (!enabled) return; + // Lock body scroll when swipe controls are enabled + const prevOverflow = document.body.style.overflow; + const prevTouchAction = document.body.style.touchAction; + document.body.style.overflow = 'hidden'; + document.body.style.touchAction = 'none'; + const handleTouchStart = (e: TouchEvent) => { const touch = e.touches[0]; swipeStateRef.current = { @@ -99,6 +105,9 @@ export const useSwipeControls = ({ document.removeEventListener('touchstart', handleTouchStart); document.removeEventListener('touchend', handleTouchEnd); document.removeEventListener('touchcancel', handleTouchCancel); + // Restore body scroll + document.body.style.overflow = prevOverflow; + document.body.style.touchAction = prevTouchAction; }; }, [enabled, minSwipeDistance, fastSwipeThreshold]); diff --git a/src/pages/Tetris.tsx b/src/pages/Tetris.tsx index 040c3cf..e3de5ef 100644 --- a/src/pages/Tetris.tsx +++ b/src/pages/Tetris.tsx @@ -132,8 +132,16 @@ const Tetris = () => { const maxHeight = window.innerHeight - 320; return Math.min(Math.floor(maxWidth / BOARD_WIDTH), Math.floor(maxHeight / BOARD_HEIGHT), 20); } - if (gameMode === '2p') return isFullscreen ? 26 : 22; - return isFullscreen ? 34 : 28; + if (isFullscreen) { + // Dynamic sizing based on viewport - same as other games + const availableWidth = window.innerWidth - (gameMode === '2p' ? 400 : 280); + const availableHeight = window.innerHeight - 120; + const cellFromWidth = Math.floor(availableWidth / (gameMode === '2p' ? BOARD_WIDTH * 2 + 4 : BOARD_WIDTH)); + const cellFromHeight = Math.floor(availableHeight / BOARD_HEIGHT); + return Math.min(cellFromWidth, cellFromHeight, gameMode === '2p' ? 32 : 40); + } + if (gameMode === '2p') return 22; + return 28; }, [isFullscreen, gameMode]); const [cellSize, setCellSize] = useState(getCellSize); @@ -550,7 +558,7 @@ const Tetris = () => {

- Tetris {gameMode === '2p' && 2P} + Tetris {gameMode === '2p' && 2P}