优化回调

This commit is contained in:
Harvey Zack committed 2018-11-08 09:09:44 +08:00
1 parent 8148973d39
commit a0bc4d3a39
3 files changed
+13 -10

No files matched your search

+3 -2
View File
@@ -112,15 +112,16 @@ export default class Controls {
});
}
add(control) {
add(control, callback) {
const { option } = control;
if (option && !option.disable) {
id++;
const name = option.name || control.constructor.name.toLowerCase() || `control${id}`;
const name = option.name || `control${id}`;
const $control = document.createElement('div');
$control.setAttribute('class', `art-control art-control-${name}`);
this.mount(option.position, $control, option.index || id);
control.apply && control.apply(this.art, $control);
callback && callback($control);
this[name] = control;
}
}