mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui-default: init
将ui-default合并至主存储库便于维护
This commit is contained in:
1 parent
6317c9057f
commit
5faa54c7ca
564 files changed
+23083
-14
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import Drop from 'tether-drop';
|
||||
import _ from 'lodash';
|
||||
import DOMAttachedObject from 'vj/components/DOMAttachedObject';
|
||||
|
||||
export default class Tooltip extends DOMAttachedObject {
|
||||
static DOMAttachKey = 'vjTooltipInstance';
|
||||
|
||||
constructor($dom, options = {}) {
|
||||
super($dom, true);
|
||||
this.dropRemoved = false;
|
||||
this.drop = new Drop({
|
||||
target: $dom[0],
|
||||
classes: 'tooltip',
|
||||
position: options.position || 'top center',
|
||||
openOn: 'hover',
|
||||
constrainToWindow: true,
|
||||
constrainToScrollParent: false,
|
||||
content: $dom.attr('data-tooltip'),
|
||||
});
|
||||
this.isOpen = false;
|
||||
this.drop.on('open', this.onOpen, this);
|
||||
this.drop.on('close', this.onClose, this);
|
||||
this.delayDetach = _.debounce(this.detach.bind(this), 200);
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
this.delayDetach.cancel();
|
||||
}
|
||||
|
||||
onClose() {
|
||||
this.delayDetach();
|
||||
}
|
||||
|
||||
detach() {
|
||||
if (this.detached) {
|
||||
return;
|
||||
}
|
||||
super.detach();
|
||||
this.drop.destroy();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.drop.close();
|
||||
}
|
||||
|
||||
open() {
|
||||
this.drop.open();
|
||||
}
|
||||
}
|
||||
|
||||
_.assign(Tooltip, DOMAttachedObject);
|
||||
Reference in new issue
Block a user