Fixed useTooltip for elements that already exist at setup
ci/woodpecker/push/ociImagePush Pipeline is running
Details
ci/woodpecker/push/ociImagePush Pipeline is running
Details
This commit is contained in:
parent
812d4ee6b2
commit
d12b65fff7
|
@ -66,33 +66,39 @@ export function useTooltip(
|
||||||
close();
|
close();
|
||||||
};
|
};
|
||||||
|
|
||||||
const stop = watch(
|
const addListeners = () => {
|
||||||
elRef,
|
const el =
|
||||||
() => {
|
elRef.value instanceof Element ? elRef.value : elRef.value!.$el;
|
||||||
if (elRef.value) {
|
el.addEventListener("mouseover", onMouseover, {
|
||||||
stop();
|
passive: true,
|
||||||
const el =
|
});
|
||||||
elRef.value instanceof Element
|
el.addEventListener("mouseleave", onMouseleave, {
|
||||||
? elRef.value
|
passive: true,
|
||||||
: elRef.value.$el;
|
});
|
||||||
el.addEventListener("mouseover", onMouseover, {
|
el.addEventListener("touchstart", onTouchstart, {
|
||||||
passive: true,
|
passive: true,
|
||||||
});
|
});
|
||||||
el.addEventListener("mouseleave", onMouseleave, {
|
el.addEventListener("touchend", onTouchend, { passive: true });
|
||||||
passive: true,
|
el.addEventListener("click", close, { passive: true });
|
||||||
});
|
};
|
||||||
el.addEventListener("touchstart", onTouchstart, {
|
|
||||||
passive: true,
|
// Can't use immediate, because of the self-reference of the watch stop handle
|
||||||
});
|
if (elRef.value) {
|
||||||
el.addEventListener("touchend", onTouchend, { passive: true });
|
addListeners();
|
||||||
el.addEventListener("click", close, { passive: true });
|
} else {
|
||||||
|
const stop = watch(
|
||||||
|
elRef,
|
||||||
|
() => {
|
||||||
|
if (elRef.value) {
|
||||||
|
stop();
|
||||||
|
addListeners();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
flush: "post",
|
||||||
}
|
}
|
||||||
},
|
);
|
||||||
{
|
}
|
||||||
immediate: true,
|
|
||||||
flush: "post",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
close();
|
close();
|
||||||
|
|
Loading…
Reference in New Issue