I'm following the documentation for ScreenOrientation.lock() but I can't get it to work as I want.
https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation/lock
When calling window.screen.orientation.lock("portrait"); on Chrome desktop I get the error screen.orientation.lock() is not available on this device. as a Uncaught Error. Is there anyway to check if a device supports locking?
I have already put "orientation":"portrait" into manifest.json but this is only default orientation and not a lock.
https://www.w3.org/TR/appmanifest/#orientation-member
Side notes:
I had some trouble understanding how to call the method. Example errors if anyone finds this thread:
ScreenOrientation.prototype.lock("portrait");
window.ScreenOrientation.prototype.lock("portrait");
Leads to this exception:
Unhandled Rejection (TypeError): Failed to execute 'lock' on 'ScreenOrientation': Illegal invocation
(ScreenOrientation as any).lock("portrait");
Leads to this exception:
TypeError: ScreenOrientation.lock is not a function