From 8631b3ae75bb7eb094240e567759623b2b329b13 Mon Sep 17 00:00:00 2001 From: Gerard Burns Date: Tue, 2 Apr 2024 12:10:26 +0100 Subject: [PATCH] refactor some --- packages/bbui/src/Tooltip/Context.svelte | 25 +++--------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/packages/bbui/src/Tooltip/Context.svelte b/packages/bbui/src/Tooltip/Context.svelte index db5d5076e4..10549d7b3a 100644 --- a/packages/bbui/src/Tooltip/Context.svelte +++ b/packages/bbui/src/Tooltip/Context.svelte @@ -3,7 +3,6 @@ import { fade } from 'svelte/transition'; export let currentTooltip - export let previousTooltip export let anchor export let visible = false export let hovering = false @@ -16,21 +15,15 @@ let currentTooltipWidth = 0 let currentTooltipHeight = 0 - let previousTooltipWidth = 0 - let previousTooltipHeight = 0 - const updatePositionOnVisibilityChange = (visible, hovering) => { if (!visible && !hovering) { previousX = 0; previousY = 0; - - previousTooltipWidth = 0 - previousTooltipHeight = 0 } } - const updatePosition = (anchor, currentTooltip, previousTooltip) => { + const updatePosition = (anchor, currentTooltip) => { requestAnimationFrame(() => { - if (anchor == null || currentTooltip == null || previousTooltip == null) { + if (anchor == null || currentTooltip == null) { return; } @@ -39,17 +32,6 @@ currentTooltipWidth = currentTooltip.clientWidth currentTooltipHeight = currentTooltip.clientHeight - previousTooltipWidth = previousTooltip.clientWidth - previousTooltipHeight = previousTooltip.clientHeight - - if (previousTooltipWidth === 0) { - previousTooltipWidth = currentTooltipWidth; - } - - if (previousTooltipHeight === 0) { - previousTooltipHeight = currentTooltipHeight; - } - previousX = currentX previousY = currentY @@ -125,7 +107,7 @@ requestAnimationFrame((newFrameTime) => animate(invokedAnimationStartTime, newFrameTime)) }*/ - $: updatePosition(anchor, currentTooltip, previousTooltip) + $: updatePosition(anchor, currentTooltip) $: updatePositionOnVisibilityChange(visible, hovering) /*$: requestAnimationFrame((frameTime) => animate(animationStartTime, frameTime))*/ @@ -162,7 +144,6 @@