添加自动旋转全屏

This commit is contained in:
Harvey committed 2020-05-15 17:10:05 +08:00
1 parent b08e6a110a
commit cf22fb0535
13 files changed
+186 -108

No files matched your search

+13 -30
View File
@@ -1,41 +1,24 @@
import { throttle } from '../utils';
export default function resizeInit(art, events) {
const {
option,
player,
template: { $player },
} = art;
const { option, player } = art;
const object = document.createElement('object');
object.setAttribute('aria-hidden', 'true');
object.setAttribute('tabindex', -1);
object.type = 'text/html';
object.data = 'about:blank';
let playerWidth = player.width;
let playerHeight = player.height;
const resizeFn = throttle(() => {
if (player.width !== playerWidth || player.height !== playerHeight) {
playerWidth = player.width;
playerHeight = player.height;
if (option.autoSize) {
if (!player.fullscreen && !player.fullscreenWeb && !player.pip) {
player.autoSize = true;
} else {
player.autoSize = false;
}
if (option.autoSize) {
if (!player.fullscreen && !player.fullscreenWeb && !player.pip) {
player.autoSize = true;
} else {
player.autoSize = false;
}
player.aspectRatioReset = true;
art.emit('resize', {
width: player.width,
height: player.height,
});
}
player.aspectRatioReset = true;
art.emit('resize', {
width: player.width,
height: player.height,
});
}, 500);
events.proxy(object, 'load', () => {
events.proxy(object.contentDocument.defaultView, 'resize', resizeFn);
events.proxy(window, ['orientationchange', 'resize'], () => {
resizeFn();
});
$player.appendChild(object);
}