This commit is contained in:
Harvey Zack committed 2018-10-30 17:27:56 +08:00
1 parent 47438ed73f
commit db06e9a8c5
3 files changed
+8 -5

No files matched your search

+4 -2
View File
@@ -176,19 +176,21 @@ export default class Player {
aspectRatio(ratio) {
const { refs: { $video, $player }, i18n, notice } = this.art;
const ratioName = ratio.length === 2 ? `${ratio[0]}:${ratio[1]}` : ratio[0];
if (ratio.length === 2) {
const rate = Number(ratio[0]) / Number(ratio[1]);
setStyle($video, 'width', `${100 / rate}%`);
setStyle($video, 'height', '100%');
setStyle($video, 'padding', `0 ${($player.clientWidth - $player.clientWidth / rate) / 2}px`);
$player.dataset.aspectRatio = ratioName;
} else {
setStyle($video, 'width', null);
setStyle($video, 'height', null);
setStyle($video, 'padding', null);
delete $player.dataset.aspectRatio;
}
const ratioName = ratio.length === 2 ? `${ratio[0]}:${ratio[1]}` : ratio[0];
$player.dataset.aspectRatio = ratioName;
notice.show(`${i18n.get('Aspect ratio')}: ${ratioName}`);
this.art.emit('aspectRatio', ratio);
}