mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-23 05:41:20 -08:00
优化回调参数
This commit is contained in:
1 parent
2385128abb
commit
62c05ef659
5 files changed
+44
-31
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { append, insertByIndex, setStyles, setStyle } from './index';
|
||||
import { append, insertByIndex, setStyles, setStyle, remove } from './index';
|
||||
|
||||
export default function component(art, parent, target, component, callback, title) {
|
||||
const option = typeof component === 'function' ? component(art) : component;
|
||||
@@ -19,7 +19,7 @@ export default function component(art, parent, target, component, callback, titl
|
||||
if (option.click) {
|
||||
art.events.proxy($element, 'click', event => {
|
||||
event.preventDefault();
|
||||
option.click.call(parent, event);
|
||||
option.click.call(parent, event, art);
|
||||
art.emit(`${title}:click`, $element);
|
||||
});
|
||||
}
|
||||
@@ -36,20 +36,27 @@ export default function component(art, parent, target, component, callback, titl
|
||||
});
|
||||
|
||||
Object.defineProperty(option, 'show', {
|
||||
value: () => {
|
||||
setStyle($element, 'display', 'block');
|
||||
value: (type = 'block') => {
|
||||
setStyle($element, 'display', type);
|
||||
art.emit(`${title}:show`, $element);
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(option, 'remove', {
|
||||
value: () => {
|
||||
remove($element);
|
||||
art.emit(`${title}:remove`, $element);
|
||||
},
|
||||
});
|
||||
|
||||
insertByIndex(target, $element, option.index || parent.id);
|
||||
|
||||
if (option.mounted) {
|
||||
option.mounted($element);
|
||||
option.mounted($element, parent, art);
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback($element);
|
||||
callback($element, parent, art);
|
||||
}
|
||||
|
||||
parent[name] = option;
|
||||
|
||||
Reference in new issue
Block a user