优化组件id

This commit is contained in:
Harvey Zack committed 2019-04-28 12:58:52 +08:00
1 parent 39ea75450c
commit 8ee7488bb1
7 files changed
+17 -9

No files matched your search

+2 -1
View File
@@ -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) {
+1
View File
@@ -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');
}
+1
View File
@@ -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');
}
+1
View File
@@ -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');
}
+1 -1
View File
@@ -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');