Skip to content

Promise for unlock()? #104

@jjmax75

Description

@jjmax75

I understand that this might not be possible from the note -

unlock() does not return a Promise because it is equivalent to locking to the default orientation which might or might not be known by the user agent. Hence, the user agent can not predict what the new orientation is going to be and even if it is going to change at all.

I am working on building an app that uses WebVR. Entering VR mode requires going fullscreen and then locking orientation to landscape. This works perfectly.

However exiting this mode when phone is in portrait orientation, on tested Android devices, results in the browser bar and menu disappearing and a large white space appearing under the app. Dragging down on the screen reveals the browser bar and covers the white space, you can not then drag back up.

orientation unlock issue

I've overcome this issue using the following code

screen.orientation.unlock();
setTimeout( () => {
    fullscreen.exit();
}, 0 );

A cleaner solution would be something like -

screen.orientation.unlock().then( () => {
    fullscreen.exit();
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions