mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-20 20:21:20 -08:00
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
import { setStyle, hasClass, addClass, removeClass, def } from '../utils';
|
|
|
|
export default function autoHeightMix(art) {
|
|
const {
|
|
option,
|
|
template: { $container, $video },
|
|
} = art;
|
|
|
|
const heightCache = $container.style.height;
|
|
|
|
def(art, 'autoHeight', {
|
|
get() {
|
|
return hasClass($container, 'art-auto-height');
|
|
},
|
|
set(value) {
|
|
if (value) {
|
|
const { clientWidth } = $container;
|
|
const { videoHeight, videoWidth } = $video;
|
|
const height = videoHeight * (clientWidth / videoWidth);
|
|
setStyle($container, 'height', height + 'px');
|
|
addClass($container, 'art-auto-height');
|
|
art.autoSize = option.autoSize;
|
|
art.emit('autoHeight', height);
|
|
} else {
|
|
setStyle($container, 'height', heightCache);
|
|
removeClass($container, 'art-auto-height');
|
|
art.autoSize = option.autoSize;
|
|
art.emit('autoHeight');
|
|
}
|
|
},
|
|
});
|
|
}
|