Skip to content

requestFullScreen API is invalid if I pass it to onChange props #35

@hijiangtao

Description

@hijiangtao

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions