add autoOrientation

This commit is contained in:
Harvey authored and Harvey Zack committed 2022-04-26 17:23:42 +08:00
1 parent 4539a46a82
commit b292b769bd
5 files changed
+82 -5

No files matched your search

@@ -0,0 +1,35 @@
import { setStyle } from '../utils';
export default function autoOrientation(art) {
const {
option,
template: { $player, $video },
} = art;
art.on('fullscreenWeb', (state) => {
if (state) {
const { videoWidth, videoHeight } = $video;
const { clientWidth: viewWidth, clientHeight: viewHeight } = document.documentElement;
if (
(videoWidth > videoHeight && viewWidth < viewHeight) ||
(videoWidth < videoHeight && viewWidth > viewHeight)
) {
setStyle($player, 'width', `${viewHeight}px`);
setStyle($player, 'height', `${viewWidth}px`);
setStyle($player, 'transform', `rotate(90deg) translate(0,-${viewWidth}px)`);
setStyle($player, 'transform-origin', '0 0');
}
} else {
setStyle($player, 'width', null);
setStyle($player, 'height', null);
setStyle($player, 'transform', null);
setStyle($player, 'transform-origin', null);
art.autoSize = option.autoSize;
art.notice.show = '';
}
});
return {
name: 'autoOrientation',
};
}
+5
View File
@@ -1,5 +1,6 @@
import { errorHandle, isMobile, has, def } from '../utils';
import miniProgressBar from './miniProgressBar';
import autoOrientation from './autoOrientation';
import autoPlayback from './autoPlayback';
import lock from './lock';
@@ -22,6 +23,10 @@ export default class Plugins {
this.add(autoPlayback);
}
if (isMobile) {
this.add(autoOrientation);
}
for (let index = 0; index < option.plugins.length; index++) {
this.add(option.plugins[index]);
}