mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-11 05:26:15 -08:00
添加样式小工具
This commit is contained in:
1 parent
96a6e1eb0e
commit
47438ed73f
10 files changed
+56
-54
No files matched your search
+7
-7
@@ -1,4 +1,4 @@
|
||||
import { clamp, secondToTime, setStorage, sleep } from './utils';
|
||||
import { clamp, secondToTime, setStorage, sleep, setStyle } from './utils';
|
||||
import config from './config';
|
||||
|
||||
export default class Player {
|
||||
@@ -178,13 +178,13 @@ export default class Player {
|
||||
const { refs: { $video, $player }, i18n, notice } = this.art;
|
||||
if (ratio.length === 2) {
|
||||
const rate = Number(ratio[0]) / Number(ratio[1]);
|
||||
$video.style.width = `${100 / rate}%`;
|
||||
$video.style.height = '100%';
|
||||
$video.style.padding = `0 ${($player.clientWidth - $player.clientWidth / rate) / 2}px`;
|
||||
setStyle($video, 'width', `${100 / rate}%`);
|
||||
setStyle($video, 'height', '100%');
|
||||
setStyle($video, 'padding', `0 ${($player.clientWidth - $player.clientWidth / rate) / 2}px`);
|
||||
} else {
|
||||
$video.style.width = null;
|
||||
$video.style.height = null;
|
||||
$video.style.padding = null;
|
||||
setStyle($video, 'width', null);
|
||||
setStyle($video, 'height', null);
|
||||
setStyle($video, 'padding', null);
|
||||
}
|
||||
|
||||
const ratioName = ratio.length === 2 ? `${ratio[0]}:${ratio[1]}` : ratio[0];
|
||||
|
||||
Reference in new issue
Block a user