I want to use switch to toggle a fullscreen request, and the code shows below:
onChange() {
const ExitFullScreen = document.exitFullscreen ||
document.webkitExitFullscreen || document.mozCancelFullScreen ||
document.msExitFullscreen;
if (ExitFullScreen) {
ExitFullScreen.call(document);
}
}
But I got an error throwed be react in development mode like this:
Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user gesture.
and I find that toggle method is called with onClick event. Is it because that onChange is not called directly in toggle?
I think calling other Web API may face the same problem.
I want to use switch to toggle a fullscreen request, and the code shows below:
But I got an error throwed be react in development mode like this:
and I find that
togglemethod is called withonClickevent. Is it because thatonChangeis not called directly intoggle?I think calling other Web API may face the same problem.