diff --git a/packages/bbui/src/Tooltip/Context.svelte b/packages/bbui/src/Tooltip/Context.svelte index 4aa77a7fbb..db5d5076e4 100644 --- a/packages/bbui/src/Tooltip/Context.svelte +++ b/packages/bbui/src/Tooltip/Context.svelte @@ -8,10 +8,10 @@ export let visible = false export let hovering = false - let startX = 0 - let startY = 0 - let endX = 0 - let endY = 0 + let previousX = 0 + let previousY = 0 + let currentX = 0 + let currentY = 0 let currentTooltipWidth = 0 let currentTooltipHeight = 0 @@ -19,17 +19,10 @@ let previousTooltipWidth = 0 let previousTooltipHeight = 0 - let x = 0; - let y = 0; - let w = 0; - let h = 0; - - let animationStartTime = 0; - const updatePositionOnVisibilityChange = (visible, hovering) => { if (!visible && !hovering) { - x = 0; - y = 0; + previousX = 0; + previousY = 0; previousTooltipWidth = 0 previousTooltipHeight = 0 @@ -57,21 +50,24 @@ previousTooltipHeight = currentTooltipHeight; } - startX = x - startY = y + previousX = currentX + previousY = currentY - endX = rect.x - currentTooltipWidth - endY = rect.y + // - width to align to left side of anchor + currentX = rect.x - currentTooltipWidth + currentY = rect.y - animationStartTime = document.timeline.currentTime + if (previousX === 0) { + previousX = currentX + } - if (x === 0 && y === 0) { - startX = endX - startY = endY + if (previousY === 0) { + previousY = currentY } }) } + /* const getNormalizedTime = (startTime, endTime, currentTime) => { const distanceFromStart = currentTime - startTime; const timeDiff = endTime - startTime; @@ -125,17 +121,13 @@ x = linearInterpolation(startX, endX, easing.x) y = linearInterpolation(startY, endY, easing.y) w = linearInterpolation(previousTooltipWidth, currentTooltipWidth, easing.x) - console.log(currentTooltipWidth); - console.log(previousTooltipWidth); - console.log(w); - console.log("") requestAnimationFrame((newFrameTime) => animate(invokedAnimationStartTime, newFrameTime)) - } + }*/ $: updatePosition(anchor, currentTooltip, previousTooltip) $: updatePositionOnVisibilityChange(visible, hovering) - $: requestAnimationFrame((frameTime) => animate(animationStartTime, frameTime)) + /*$: requestAnimationFrame((frameTime) => animate(animationStartTime, frameTime))*/ const handleMouseenter = (e) => { hovering = true; @@ -150,29 +142,30 @@
-
+
-
-
@@ -181,10 +174,13 @@