quasar-ui-danx 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@ import { RenderVnode } from '../Utility';
18
18
  defineProps({
19
19
  activePanel: {
20
20
  type: String,
21
- required: true
21
+ default: null
22
22
  },
23
23
  panels: {
24
24
  type: Array,
@@ -1,11 +1,12 @@
1
1
  <template>
2
2
  <QTooltip
3
+ class="interactive-tooltip"
3
4
  ref="tooltipBox"
4
5
  v-model="show"
5
6
  no-parent-event
6
- class="!pointer-events-auto"
7
7
  @mouseenter="onEnterTooltip"
8
8
  @mouseleave="onLeaveTooltip"
9
+ :transition-duration="200"
9
10
  >
10
11
  <slot>{{ tooltip }}</slot>
11
12
  </QTooltip>
@@ -18,6 +19,7 @@ const show = ref(false);
18
19
  const tooltipBox = ref(null);
19
20
  const isHovering = ref(false);
20
21
  const isHoveringParent = ref(false);
22
+ let timeout = null;
21
23
  onMounted(() => {
22
24
  tooltipBox.value.$el.parentNode.addEventListener('mouseover', onEnterParent);
23
25
  tooltipBox.value.$el.parentNode.addEventListener('mouseleave', onLeaveParent);
@@ -25,25 +27,40 @@ onMounted(() => {
25
27
  function onEnterParent() {
26
28
  show.value = true;
27
29
  isHoveringParent.value = true;
30
+ if (timeout) clearTimeout(timeout);
28
31
  }
29
32
  function onLeaveParent() {
30
33
  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);
34
+ if (show.value) delayClose();
40
35
  }
41
36
  function onEnterTooltip() {
42
37
  isHovering.value = true;
43
38
  show.value = true;
39
+ if (timeout) clearTimeout(timeout);
44
40
  }
45
41
  function onLeaveTooltip() {
46
42
  isHovering.value = false;
47
- show.value = false;
43
+ if (show.value) delayClose();
44
+ }
45
+ function delayClose() {
46
+ if (timeout) clearTimeout(timeout);
47
+ timeout = setTimeout(() => {
48
+ if (isHovering.value || isHoveringParent.value) {
49
+ delayClose();
50
+ } else {
51
+ show.value = false;
52
+ }
53
+ }, 200);
48
54
  }
55
+
49
56
  </script>
57
+ <style lang="scss">
58
+ body .q-tooltip {
59
+ &.interactive-tooltip {
60
+ pointer-events: auto !important;
61
+ background: white;
62
+ color: inherit;
63
+ box-shadow: 0 0 10px 3px rgba(0, 0, 0, 0.2);
64
+ }
65
+ }
66
+ </style>