mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 23:13:18 -08:00
调整组件嵌入规则
This commit is contained in:
1 parent
88533c1023
commit
8619fa1b8b
22 files changed
+553
-392
No files matched your search
@@ -1,32 +1,32 @@
|
||||
import { inverseClass } from '../utils';
|
||||
|
||||
export default function aspectRatio(art) {
|
||||
const { option, i18n, player } = art;
|
||||
return {
|
||||
disable: !option.aspectRatio,
|
||||
name: 'aspectRatio',
|
||||
index: 20,
|
||||
html: `
|
||||
${i18n.get('Aspect ratio')}:
|
||||
<span data-ratio="default" class="default current">${i18n.get('Default')}</span>
|
||||
<span data-ratio="4:3">4:3</span>
|
||||
<span data-ratio="16:9">16:9</span>
|
||||
`,
|
||||
click: event => {
|
||||
const { target } = event;
|
||||
const { ratio } = target.dataset;
|
||||
if (ratio) {
|
||||
player.aspectRatio(ratio.split(':'));
|
||||
art.contextmenu.hide();
|
||||
}
|
||||
},
|
||||
callback: $menu => {
|
||||
art.on('aspectRatioChange', ratio => {
|
||||
const $current = Array.from($menu.querySelectorAll('span')).find(
|
||||
item => item.dataset.ratio === ratio.join(':'),
|
||||
);
|
||||
inverseClass($current, 'current');
|
||||
});
|
||||
},
|
||||
export default function aspectRatio(menuOption) {
|
||||
return art => {
|
||||
const { i18n, player } = art;
|
||||
return {
|
||||
...menuOption,
|
||||
html: `
|
||||
${i18n.get('Aspect ratio')}:
|
||||
<span data-ratio="default" class="default current">${i18n.get('Default')}</span>
|
||||
<span data-ratio="4:3">4:3</span>
|
||||
<span data-ratio="16:9">16:9</span>
|
||||
`,
|
||||
click: event => {
|
||||
const { target } = event;
|
||||
const { ratio } = target.dataset;
|
||||
if (ratio) {
|
||||
player.aspectRatio(ratio.split(':'));
|
||||
art.contextmenu.hide();
|
||||
}
|
||||
},
|
||||
mounted: $menu => {
|
||||
art.on('aspectRatioChange', ratio => {
|
||||
const $current = Array.from($menu.querySelectorAll('span')).find(
|
||||
item => item.dataset.ratio === ratio.join(':'),
|
||||
);
|
||||
inverseClass($current, 'current');
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user