use async/await

This commit is contained in:
Harvey committed 2022-04-29 18:04:50 +08:00
1 parent facf8876b5
commit e34d09a99c
9 files changed
+86 -102

No files matched your search

@@ -40,7 +40,7 @@ export default function autoOrientation(art) {
}
});
art.on('fullscreen', (state) => {
art.on('fullscreen', async (state) => {
const lastOrientation = screen.orientation.type;
if (state) {
const { videoWidth, videoHeight } = $video;
@@ -50,15 +50,13 @@ export default function autoOrientation(art) {
(videoWidth < videoHeight && viewWidth > viewHeight)
) {
const oppositeOrientation = lastOrientation.startsWith('portrait') ? 'landscape' : 'portrait';
screen.orientation.lock(oppositeOrientation).then(() => {
addClass($player, 'art-auto-orientation-fullscreen');
});
await screen.orientation.lock(oppositeOrientation);
addClass($player, 'art-auto-orientation-fullscreen');
}
} else {
if (hasClass($player, 'art-auto-orientation-fullscreen')) {
screen.orientation.lock(lastOrientation).then(() => {
removeClass($player, 'art-auto-orientation-fullscreen');
});
await screen.orientation.lock(lastOrientation);
removeClass($player, 'art-auto-orientation-fullscreen');
}
}
});