fix: skip pointer lock request on unsupported devices (iPad)
On devices where pointer lock isn't supported (like iPad), clicking the map would try to request pointer lock on every click and return early, preventing region clicks from being processed. Now we check if pointer lock is supported before trying to request it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
1333818bae
commit
d6eb997445
|
|
@ -875,11 +875,16 @@ export function MapRenderer({
|
||||||
largestPieceSizesRef.current = largestPieceSizes
|
largestPieceSizesRef.current = largestPieceSizes
|
||||||
}, [mapData])
|
}, [mapData])
|
||||||
|
|
||||||
|
// Check if pointer lock is supported (not available on touch devices like iPad)
|
||||||
|
const isPointerLockSupported =
|
||||||
|
typeof document !== 'undefined' && 'pointerLockElement' in document
|
||||||
|
|
||||||
// Request pointer lock on first click
|
// Request pointer lock on first click
|
||||||
const handleContainerClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
const handleContainerClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
// Silently request pointer lock if not already locked
|
// Silently request pointer lock if not already locked (and supported)
|
||||||
// This makes the first gameplay click also enable precision mode
|
// This makes the first gameplay click also enable precision mode
|
||||||
if (!pointerLocked) {
|
// On devices without pointer lock (iPad), skip this and process clicks normally
|
||||||
|
if (!pointerLocked && isPointerLockSupported) {
|
||||||
requestPointerLock()
|
requestPointerLock()
|
||||||
console.log('[Pointer Lock] 🔒 Silently requested (user clicked map)')
|
console.log('[Pointer Lock] 🔒 Silently requested (user clicked map)')
|
||||||
return // Don't process region click on the first click that requests lock
|
return // Don't process region click on the first click that requests lock
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue