Files
ArtPlayer/packages/artplayer/src/events/resizeInit.js
T
2022-04-27 10:42:07 +08:00

25 lines
645 B
JavaScript

import { throttle } from '../utils';
export default function resizeInit(art, events) {
const { notice, option } = art;
const resizeFn = throttle(() => {
if (art.normalSize) {
art.autoSize = option.autoSize;
}
art.aspectRatioReset = true;
notice.show = '';
art.emit('resize');
}, art.constructor.RESIZE_TIME);
events.proxy(window, ['orientationchange', 'resize'], () => {
resizeFn();
});
if (screen && screen.orientation && screen.orientation.onchange) {
events.proxy(screen.orientation, 'change', () => {
resizeFn();
});
}
}