Implement automatic rotation
This change should lead to the screen automatically getting set to landscape mode when activating fullscreen on a mobile device. Seems to only work in chrome, which is not great, but it seems to be the only option.
This commit is contained in:
parent
db68e2b86b
commit
8323ea61dd
@ -1333,6 +1333,22 @@ input[type="range"]::-ms-track {
|
||||
}
|
||||
this.toggleButtonState(fullscreenButton);
|
||||
});
|
||||
// This doesn't work in firefox for some reason
|
||||
document.addEventListener('fullscreenchange', (event) => {
|
||||
if(!matchMedia("(any-pointer:fine)").matches) {
|
||||
// only activate in browsers with only a coarse pointer,
|
||||
// which hopefully means a mobile device
|
||||
if(document.fullscreenElement) {
|
||||
screen.orientation.lock('landscape')
|
||||
.catch((error) => {
|
||||
console.error('Failed to lock orientation:',
|
||||
error);
|
||||
});
|
||||
} else {
|
||||
screen.orientation.unlock();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user