Skip to content

Commit e98c298

Browse files
committed
fix hover gblinking
- remove `update()` in watch to avoid it called twice. - flip to cross axis. - add radius for floating-content to avoid cracked border on corner. - show shadow on bottom, not following arrow.
1 parent 2e47317 commit e98c298

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/components/Floating.vue

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const {
9797
placement: placementProp,
9898
middleware: [
9999
floating.offset(6),
100-
floating.flip(),
100+
floating.flip({ fallbackAxisSideDirection: "end", crossAxis: false }),
101101
floating.shift({ padding: 5 }),
102102
floating.arrow({ element: arrowRef }),
103103
],
@@ -122,16 +122,12 @@ const isTooltipHovered = useElementHover(floatingRef, {
122122
});
123123
const isTriggered = computed((): boolean => {
124124
const triggered = triggerRef.value ?? isTargetHovered.value;
125-
if (interactive.value) {
126-
return triggered || isTooltipHovered.value;
127-
} else {
128-
return triggered;
129-
}
125+
const t = triggered || (interactive.value && isTooltipHovered.value);
126+
return t;
130127
});
131128
132129
watch(isTriggered, (show) => {
133130
if (show) {
134-
update();
135131
props.onShow?.();
136132
} else {
137133
props.onHide?.();
@@ -199,6 +195,7 @@ const arrowStyles = computed(() => {
199195
.floating-content {
200196
display: grid;
201197
background-color: white;
198+
border-radius: 3px;
202199
z-index: 10002;
203200
}
204201
@@ -217,6 +214,7 @@ const arrowStyles = computed(() => {
217214
.floating-wrapper[data-theme~="light"] {
218215
background-color: white;
219216
border: 1px solid black;
217+
box-shadow: 0 4px 4px rgb(0 0 0 / .2);
220218
221219
.floating-content {
222220
background-color: white;
@@ -229,28 +227,24 @@ const arrowStyles = computed(() => {
229227
}
230228
231229
.floating-wrapper[data-placement~="top"] {
232-
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.2);
233230
.floating-arrow {
234231
border-width: 0 1px 1px 0;
235232
bottom: -5px !important;
236233
}
237234
}
238235
.floating-wrapper[data-placement~="right"] {
239-
box-shadow: -4px 0 4px rgba(0, 0, 0, 0.2);
240236
.floating-arrow {
241237
border-width: 0 0 1px 1px;
242238
left: -5px !important;
243239
}
244240
}
245241
.floating-wrapper[data-placement~="bottom"] {
246-
box-shadow: 0 -4px 4px rgba(0, 0, 0, 0.2);
247242
.floating-arrow {
248243
border-width: 1px 0 0 1px;
249244
top: -5px !important;
250245
}
251246
}
252247
.floating-wrapper[data-placement~="left"] {
253-
box-shadow: 4px 0 4px rgba(0, 0, 0, 0.2);
254248
.floating-arrow {
255249
border-width: 1px 1px 0 0;
256250
right: -5px !important;

0 commit comments

Comments
 (0)