diff options
| author | Fuwn <[email protected]> | 2026-04-19 11:08:52 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-04-19 11:08:52 +0000 |
| commit | 271b8f6cbb0b7415495054c2d3129f09b0ea8e37 (patch) | |
| tree | 35f1312317d3662ffe371b10db56003e624b563d /src/lib/Tooltip/LinkedTooltip.svelte | |
| parent | Revert "fix(tooltip): use fixed positioning and snappy cursor tracking" (diff) | |
| download | due.moe-271b8f6cbb0b7415495054c2d3129f09b0ea8e37.tar.xz due.moe-271b8f6cbb0b7415495054c2d3129f09b0ea8e37.zip | |
fix(tooltip): park off-screen on create, enable glide after first placement
The tooltip was appended to body with no top/left, so its static-flow position
extended body.scrollWidth/scrollHeight during measurement. Fix by setting
initial top/left to -9999px so the node never lands in the flow.
Previously this slid the tooltip in from off-screen because the top/left 0.3s
transition was already live. Now the transition starts as opacity-only at
creation time; after the first updateTooltipPosition snaps into place, a
requestAnimationFrame re-enables the top/left easing so subsequent mousemove
updates keep the original smooth glide and 100ms debounce behavior.
LinkedTooltip's measurement div is parked the same way plus visibility:hidden,
since it exists only to read offsetWidth for the Svelte-rendered tooltip.
Diffstat (limited to 'src/lib/Tooltip/LinkedTooltip.svelte')
| -rw-r--r-- | src/lib/Tooltip/LinkedTooltip.svelte | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib/Tooltip/LinkedTooltip.svelte b/src/lib/Tooltip/LinkedTooltip.svelte index b3fc6ae2..bbf0ffe5 100644 --- a/src/lib/Tooltip/LinkedTooltip.svelte +++ b/src/lib/Tooltip/LinkedTooltip.svelte @@ -36,6 +36,9 @@ const createTooltip = () => { if (!tooltipDiv) { tooltipDiv = document.createElement("div"); tooltipDiv.style.position = "absolute"; + tooltipDiv.style.top = "-9999px"; + tooltipDiv.style.left = "-9999px"; + tooltipDiv.style.visibility = "hidden"; tooltipDiv.style.zIndex = "1000"; opacity = 0; tooltipDiv.style.pointerEvents = "none"; |