[improvement] SwipeCell: jsx (#2632)

This commit is contained in:
neverland
2019-01-27 08:50:20 +08:00
committed by GitHub
parent 874d2f79ca
commit ccdfc7124a
3 changed files with 76 additions and 103 deletions
-44
View File
@@ -1,44 +0,0 @@
/**
* v-clickoutside
*
* ```vue
* <div v-clickoutside="onClose">
* ```
*/
import { on, off } from './event';
const context = '@@clickoutsideContext';
export default {
bind(el, binding) {
const handler = event => {
if (!el.contains(event.target)) {
el[context].callback();
}
};
el[context] = {
handler,
callback: binding.value,
arg: binding.arg || 'click'
};
on(document, el[context].arg, handler);
},
update(el, binding) {
el[context].callback = binding.value;
},
unbind(el) {
off(document, el[context].arg, el[context].handler);
},
install(Vue) {
Vue.directive('clickoutside', {
bind: this.bind,
unbind: this.unbind
});
}
};