修改switcher逻辑

This commit is contained in:
Harvey committed 2020-08-25 10:38:29 +08:00
1 parent dd1ae0f499
commit 20afbab916
6 files changed
+75 -64

No files matched your search

+3 -18
View File
@@ -160,12 +160,8 @@ export default class Control extends Component {
});
}
add(getOption, callback) {
add(getOption) {
const option = typeof getOption === 'function' ? getOption(this.art) : getOption;
errorHandle(
['top', 'left', 'right'].includes(option.position),
`Control option.position must one of 'top', 'left', 'right'`,
);
const { $progress, $controlsLeft, $controlsRight } = this.art.template;
switch (option.position) {
@@ -179,21 +175,10 @@ export default class Control extends Component {
this.$parent = $controlsRight;
break;
default:
errorHandle(false, `Control option.position must one of 'top', 'left', 'right'`);
break;
}
super.add(option, ($ref) => {
if (
!option.disable &&
option.position !== 'top' &&
!($ref.firstElementChild && $ref.firstElementChild.tagName === 'I')
) {
addClass($ref, 'art-control-onlyText');
}
if (callback) {
callback($ref, this, this.art);
}
});
super.add(option);
}
}