add autoHeight option

This commit is contained in:
Harvey committed 2021-12-31 13:30:59 +08:00
1 parent f890f83a61
commit 6cb75858bb
16 files changed
+85 -3

No files matched your search

@@ -0,0 +1,25 @@
import { setStyle, hasClass, addClass, removeClass, def } from '../utils';
export default function autoHeightMix(art, player) {
const { $container, $video } = art.template;
def(player, 'autoHeight', {
get() {
return hasClass($container, 'art-auto-height');
},
set(value) {
if (value) {
const { clientWidth } = $container;
const { videoHeight, videoWidth } = $video;
const height = videoHeight * (clientWidth / videoWidth) + 'px';
setStyle($container, 'height', height);
addClass($container, 'art-auto-height');
art.emit('autoHeight', height);
} else {
setStyle($container, 'height', null);
removeClass($container, 'art-auto-size');
art.emit('autoHeight');
}
},
});
}