From 06bab3397fed48dd03e78acb96b2428d8e98b90a Mon Sep 17 00:00:00 2001 From: Gerard Burns Date: Mon, 22 Apr 2024 08:15:08 +0100 Subject: [PATCH] remove previous option stuff and animations --- packages/bbui/src/Tooltip/Context.svelte | 159 +++--------------- .../Explanation/DetailsModal/index.svelte | 1 - .../controls/Explanation/Explanation.svelte | 3 +- .../settings/controls/FieldSelect.svelte | 11 -- .../settings/controls/MultiFieldSelect.svelte | 19 +-- 5 files changed, 28 insertions(+), 165 deletions(-) diff --git a/packages/bbui/src/Tooltip/Context.svelte b/packages/bbui/src/Tooltip/Context.svelte index e0abd882c8..624ec90da1 100644 --- a/packages/bbui/src/Tooltip/Context.svelte +++ b/packages/bbui/src/Tooltip/Context.svelte @@ -6,96 +6,30 @@ export let anchor export let visible = false export let offset = 0; - export let noAnimation = false $: target = getContext(Context.PopoverRoot) || "#app" let hovering = false - let wrapper - let currentTooltip - let previousTooltip + let tooltip + let x = 0 + let y = 0 - let initialShow = true; - let previousX = 0 - let previousY = 0 - let currentX = 0 - let currentY = 0 - - let currentTooltipWidth = 0 - let currentTooltipHeight = 0 - - const handleVisibilityChange = (visible, hovering) => { - if (!visible && !hovering) { - initialShow = true; + const updatePosition = (anchor, tooltip) => { + if (anchor == null || tooltip == null) { + return; } - } - const updatePosition = (anchor, currentTooltip, previousTooltip, wrapper) => { requestAnimationFrame(() => { - if (anchor == null || currentTooltip == null || previousTooltip == null || wrapper == null) { - return; - } - const rect = anchor.getBoundingClientRect(); + const windowOffset = (window.innerHeight - offset) - (tooltip.clientHeight + rect.y) + const tooltipWidth = tooltip.clientWidth - - const windowOffset = (window.innerHeight - offset) - (currentTooltip.clientHeight + rect.y) - - currentTooltipWidth = currentTooltip.clientWidth - currentTooltipHeight = currentTooltip.clientHeight - - previousX = currentX - previousY = currentY - - // - width to align to left side of anchor - currentX = rect.x - currentTooltipWidth - offset - currentY = windowOffset < 0 ? rect.y + windowOffset : rect.y - const fadeIn = [{ opacity: "0" }, { opacity: "1" }]; - const fadeOut = [{ opacity: "1" }, { opacity: "0" }]; - - const fadeInTiming = { - duration: 200, - delay: 100, - iterations: 1, - easing: "ease-in", - fill: "both" - }; - const fadeOutTiming = { - duration: 200, - iterations: 1, - easing: "ease-in", - fill: "forwards" - }; - - if (!noAnimation) { - currentTooltip.animate(fadeIn, fadeInTiming); - previousTooltip.animate(fadeOut, fadeOutTiming); - } - - // Bypass animations if the tooltip has only just been opened - if (initialShow) { - initialShow = false; - - previousTooltip.style.visibility = "hidden" - - wrapper.style.transition = "none"; - //wrapper.style.width = `${currentTooltipWidth}px` - //wrapper.style.height = `${currentTooltipHeight}px` - wrapper.style.top = `${currentY}px` - wrapper.style.left = `${currentX}px` - - - requestAnimationFrame(() => { - wrapper.style.removeProperty("transition"); - }) - } else { - previousTooltip.style.removeProperty("visibility"); - } + x = rect.x - tooltipWidth - offset + y = windowOffset < 0 ? rect.y + windowOffset : rect.y }) } - $: updatePosition(anchor, currentTooltip, previousTooltip, wrapper) - $: handleVisibilityChange(visible, hovering) + $: updatePosition(anchor, tooltip) const handleMouseenter = (e) => { hovering = true; @@ -108,85 +42,38 @@
- -
-
- -
-
- -
+
+
diff --git a/packages/builder/src/components/design/settings/controls/Explanation/DetailsModal/index.svelte b/packages/builder/src/components/design/settings/controls/Explanation/DetailsModal/index.svelte index f6310fdaba..2650124ea5 100644 --- a/packages/builder/src/components/design/settings/controls/Explanation/DetailsModal/index.svelte +++ b/packages/builder/src/components/design/settings/controls/Explanation/DetailsModal/index.svelte @@ -11,7 +11,6 @@ {} @@ -84,7 +83,7 @@ {/if}
-{#if showDetails} +{#if detailsModalSubject !== subjects.none} - {/if} diff --git a/packages/builder/src/components/design/settings/controls/MultiFieldSelect.svelte b/packages/builder/src/components/design/settings/controls/MultiFieldSelect.svelte index 721ac7bb88..eb46999cda 100644 --- a/packages/builder/src/components/design/settings/controls/MultiFieldSelect.svelte +++ b/packages/builder/src/components/design/settings/controls/MultiFieldSelect.svelte @@ -18,7 +18,6 @@ let contextTooltipAnchor = null let currentOption = null - let previousOption = null let contextTooltipVisible = false $: componentDefinition = componentStore.getDefinition( @@ -80,12 +79,11 @@ const updateTooltip = debounce((e, option) => { if (option == null) { - contextTooltipVisible = false; + contextTooltipVisible = false; } else { - contextTooltipAnchor = e?.target; - previousOption = currentOption; - currentOption = option; - contextTooltipVisible = true; + contextTooltipAnchor = e?.target; + currentOption = option; + contextTooltipVisible = true; } }, 200); @@ -116,7 +114,6 @@ offset={20} > - {/if}