quasar-ui-danx 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
<template>
|
2
|
+
<QTooltip
|
3
|
+
ref="tooltipBox"
|
4
|
+
v-model="show"
|
5
|
+
no-parent-event
|
6
|
+
class="!pointer-events-auto"
|
7
|
+
@mouseenter="onEnterTooltip"
|
8
|
+
@mouseleave="onLeaveTooltip"
|
9
|
+
>
|
10
|
+
<slot>{{ tooltip }}</slot>
|
11
|
+
</QTooltip>
|
12
|
+
</template>
|
13
|
+
<script setup>
|
14
|
+
import { onMounted, ref } from 'vue';
|
15
|
+
|
16
|
+
defineProps({ tooltip: { type: String, default: '' } });
|
17
|
+
const show = ref(false);
|
18
|
+
const tooltipBox = ref(null);
|
19
|
+
const isHovering = ref(false);
|
20
|
+
const isHoveringParent = ref(false);
|
21
|
+
onMounted(() => {
|
22
|
+
tooltipBox.value.$el.parentNode.addEventListener('mouseover', onEnterParent);
|
23
|
+
tooltipBox.value.$el.parentNode.addEventListener('mouseleave', onLeaveParent);
|
24
|
+
});
|
25
|
+
function onEnterParent() {
|
26
|
+
show.value = true;
|
27
|
+
isHoveringParent.value = true;
|
28
|
+
}
|
29
|
+
function onLeaveParent() {
|
30
|
+
isHoveringParent.value = false;
|
31
|
+
if (!show.value) return;
|
32
|
+
|
33
|
+
setTimeout(() => {
|
34
|
+
if (isHovering.value || isHoveringParent.value) {
|
35
|
+
onLeaveParent();
|
36
|
+
} else {
|
37
|
+
show.value = false;
|
38
|
+
}
|
39
|
+
}, 200);
|
40
|
+
}
|
41
|
+
function onEnterTooltip() {
|
42
|
+
isHovering.value = true;
|
43
|
+
show.value = true;
|
44
|
+
}
|
45
|
+
function onLeaveTooltip() {
|
46
|
+
isHovering.value = false;
|
47
|
+
show.value = false;
|
48
|
+
}
|
49
|
+
</script>
|