mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-22 21:31:20 -08:00
优化组件id
This commit is contained in:
1 parent
39ea75450c
commit
8ee7488bb1
7 files changed
+17
-9
No files matched your search
@@ -71,7 +71,8 @@ export default class Contextmenu {
|
||||
|
||||
add(item, callback) {
|
||||
const { $contextmenu } = this.art.template;
|
||||
component(this.art, this, $contextmenu, item, callback, 'contextmenu');
|
||||
this.id += 1;
|
||||
return component(this.art, this, $contextmenu, item, callback, 'contextmenu');
|
||||
}
|
||||
|
||||
setPos(event) {
|
||||
|
||||
@@ -157,6 +157,7 @@ export default class Controls {
|
||||
}
|
||||
|
||||
errorHandle(parent, 'Controls option.position can not be empty');
|
||||
this.id += 1;
|
||||
return component(this.art, this, parent, option, callback, 'control');
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ export default class Layers {
|
||||
|
||||
add(item, callback) {
|
||||
const { $layers } = this.art.template;
|
||||
this.id += 1;
|
||||
return component(this.art, this, $layers, item, callback, 'layer');
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ export default class Setting {
|
||||
|
||||
add(item, callback) {
|
||||
const { $settingBody } = this.art.template;
|
||||
this.id += 1;
|
||||
return component(this.art, this, $settingBody, item, callback, 'setting');
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import { append, insertByIndex, setStyles, setStyle, remove } from './index';
|
||||
export default function component(art, parent, target, getOption, callback, title) {
|
||||
const option = typeof getOption === 'function' ? getOption(art) : getOption;
|
||||
if (!option.disable) {
|
||||
parent.id += 1;
|
||||
const name = option.name || `${title}${parent.id}`;
|
||||
const $element = document.createElement('div');
|
||||
$element.classList.value = `art-${title} art-${title}-${name}`;
|
||||
@@ -35,6 +34,7 @@ export default function component(art, parent, target, getOption, callback, titl
|
||||
}
|
||||
|
||||
parent[name] = {
|
||||
id: parent.id,
|
||||
$ref: $element,
|
||||
hide() {
|
||||
setStyle($element, 'display', 'none');
|
||||
|
||||
Reference in new issue
Block a user