fade in out
This commit is contained in:
parent
09485d6540
commit
1296f8c6b2
|
@ -303,21 +303,28 @@
|
||||||
<ContextTooltip
|
<ContextTooltip
|
||||||
visible={contextTooltipVisible}
|
visible={contextTooltipVisible}
|
||||||
anchor={contextTooltipAnchor}
|
anchor={contextTooltipAnchor}
|
||||||
|
offset={20}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="tooltipContents"
|
class="tooltipContents"
|
||||||
>
|
>
|
||||||
{#if contextTooltipOption}
|
{#if contextTooltipOption}
|
||||||
|
<div class="contextTooltipHeader">
|
||||||
<Icon name={getOptionIcon(contextTooltipOption)} />
|
<Icon name={getOptionIcon(contextTooltipOption)} />
|
||||||
<Heading>{contextTooltipOption}</Heading>
|
<Heading>{contextTooltipOption}</Heading>
|
||||||
|
</div>
|
||||||
|
<p>{getOptionTooltip(contextTooltipOption)}</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div slot="previous"
|
<div slot="previous"
|
||||||
class="tooltipContents"
|
class="tooltipContents"
|
||||||
>
|
>
|
||||||
{#if previousContextTooltipOption}
|
{#if previousContextTooltipOption}
|
||||||
|
<div class="contextTooltipHeader">
|
||||||
<Icon name={getOptionIcon(previousContextTooltipOption)} />
|
<Icon name={getOptionIcon(previousContextTooltipOption)} />
|
||||||
<Heading>{previousContextTooltipOption}</Heading>
|
<Heading>{previousContextTooltipOption}</Heading>
|
||||||
|
</div>
|
||||||
|
<p>{getOptionTooltip(previousContextTooltipOption)}</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</ContextTooltip>
|
</ContextTooltip>
|
||||||
|
@ -327,18 +334,29 @@
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
background-color: var(--spectrum-global-color-gray-200);
|
background-color: var(--spectrum-global-color-gray-200);
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltipContents :global(h1) {
|
.contextTooltipHeader {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextTooltipHeader :global(svg) {
|
||||||
|
color: var(--background);
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextTooltipHeader :global(h1) {
|
||||||
|
flex-grow: 1;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
text-wrap: wrap;
|
text-wrap: wrap;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltipContents :global(svg) {
|
|
||||||
color: var(--background);
|
|
||||||
fill: var(--background);
|
|
||||||
}
|
|
||||||
|
|
||||||
.spectrum-Menu {
|
.spectrum-Menu {
|
||||||
display: block;
|
display: block;
|
||||||
|
|
|
@ -2,12 +2,15 @@
|
||||||
import Portal from "svelte-portal"
|
import Portal from "svelte-portal"
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
|
|
||||||
export let wrapper
|
|
||||||
export let resetWrapper
|
|
||||||
export let currentTooltip
|
|
||||||
export let anchor
|
export let anchor
|
||||||
export let visible = false
|
export let visible = false
|
||||||
export let hovering = false
|
export let offset = 0;
|
||||||
|
|
||||||
|
let hovering = false
|
||||||
|
let wrapper
|
||||||
|
let resetWrapper
|
||||||
|
let currentTooltip
|
||||||
|
let previousTooltip
|
||||||
|
|
||||||
let initialShow = true;
|
let initialShow = true;
|
||||||
let previousX = 0
|
let previousX = 0
|
||||||
|
@ -24,9 +27,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatePosition = (anchor, currentTooltip, wrapper, resetWrapper) => {
|
const updatePosition = (anchor, currentTooltip, previousTooltip, wrapper, resetWrapper) => {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
if (anchor == null || currentTooltip == null || wrapper == null || resetWrapper == null) {
|
if (anchor == null || currentTooltip == null || previousTooltip == null || wrapper == null || resetWrapper == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +42,19 @@
|
||||||
previousY = currentY
|
previousY = currentY
|
||||||
|
|
||||||
// - width to align to left side of anchor
|
// - width to align to left side of anchor
|
||||||
currentX = rect.x - currentTooltipWidth
|
currentX = rect.x - currentTooltipWidth - offset
|
||||||
currentY = rect.y
|
currentY = rect.y
|
||||||
|
const fadeIn = [{ opacity: "0" }, { opacity: "1" }];
|
||||||
|
const fadeOut = [{ opacity: "1" }, { opacity: "0" }];
|
||||||
|
|
||||||
|
const fadeTiming = {
|
||||||
|
duration: 300,
|
||||||
|
iterations: 1,
|
||||||
|
easing: "ease-in"
|
||||||
|
};
|
||||||
|
|
||||||
|
currentTooltip.animate(fadeIn, fadeTiming);
|
||||||
|
previousTooltip.animate(fadeOut, fadeTiming);
|
||||||
|
|
||||||
// Bypass animations if the tooltip has only just been opened
|
// Bypass animations if the tooltip has only just been opened
|
||||||
if (initialShow) {
|
if (initialShow) {
|
||||||
|
@ -64,7 +78,7 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$: updatePosition(anchor, currentTooltip, wrapper, resetWrapper)
|
$: updatePosition(anchor, currentTooltip, previousTooltip, wrapper, resetWrapper)
|
||||||
$: handleVisibilityChange(visible, hovering)
|
$: handleVisibilityChange(visible, hovering)
|
||||||
|
|
||||||
const handleMouseenter = (e) => {
|
const handleMouseenter = (e) => {
|
||||||
|
@ -74,14 +88,6 @@
|
||||||
const handleMouseleave = (e) => {
|
const handleMouseleave = (e) => {
|
||||||
hovering = false;
|
hovering = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$: {
|
|
||||||
console.log(currentX)
|
|
||||||
console.log(currentY)
|
|
||||||
console.log(currentTooltipWidth)
|
|
||||||
console.log(currentTooltipHeight)
|
|
||||||
console.log();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Portal target=".spectrum">
|
<Portal target=".spectrum">
|
||||||
|
@ -116,6 +122,7 @@
|
||||||
class="previousContent"
|
class="previousContent"
|
||||||
style:left={`${previousX}px`}
|
style:left={`${previousX}px`}
|
||||||
style:top={`${previousY}px`}
|
style:top={`${previousY}px`}
|
||||||
|
bind:this={previousTooltip}
|
||||||
>
|
>
|
||||||
<slot name="previous"/>
|
<slot name="previous"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -129,6 +136,8 @@
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
background-color: var(--spectrum-global-color-gray-200);
|
background-color: var(--spectrum-global-color-gray-200);
|
||||||
|
border-radius: 5px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -149,7 +158,7 @@
|
||||||
|
|
||||||
.currentContent {
|
.currentContent {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 10000;
|
z-index: 10001;
|
||||||
}
|
}
|
||||||
|
|
||||||
.previousContent {
|
.previousContent {
|
||||||
|
|
|
@ -102,7 +102,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const getOptionTooltip = optionKey => {
|
const getOptionTooltip = optionKey => {
|
||||||
console.log(optionKey)
|
|
||||||
const support = fieldSupport[optionKey]?.support;
|
const support = fieldSupport[optionKey]?.support;
|
||||||
const message = fieldSupport[optionKey]?.message;
|
const message = fieldSupport[optionKey]?.message;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue