mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-15 17:16:16 -08:00
update
This commit is contained in:
1 parent
47438ed73f
commit
db06e9a8c5
3 files changed
+8
-5
No files matched your search
+4
-2
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user