mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 02:01:20 -08:00
add autoHeight option
This commit is contained in:
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');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user