Animate delayed search filter tooltips
This commit is contained in:
@@ -3717,7 +3717,7 @@ body.organization-view:not(.expanded) #content>#stability>.bankruptcy-timeline{
|
|||||||
.search-result-filters-tooltip{
|
.search-result-filters-tooltip{
|
||||||
position:fixed;
|
position:fixed;
|
||||||
z-index:1000;
|
z-index:1000;
|
||||||
display:none;
|
display:block;
|
||||||
width:max-content;
|
width:max-content;
|
||||||
max-width:min(30rem,70vw);
|
max-width:min(30rem,70vw);
|
||||||
padding:.625rem .75rem;
|
padding:.625rem .75rem;
|
||||||
@@ -3726,15 +3726,28 @@ body.organization-view:not(.expanded) #content>#stability>.bankruptcy-timeline{
|
|||||||
color:#e2e7e9;
|
color:#e2e7e9;
|
||||||
background:#262a2c;
|
background:#262a2c;
|
||||||
box-shadow:0 .5rem 1.25rem rgba(0,0,0,.45);
|
box-shadow:0 .5rem 1.25rem rgba(0,0,0,.45);
|
||||||
|
opacity:0;
|
||||||
pointer-events:none;
|
pointer-events:none;
|
||||||
|
transform:translateY(-.375rem) scale(.985);
|
||||||
|
transform-origin:top left;
|
||||||
|
transition:opacity .16s ease,transform .2s cubic-bezier(.2,.8,.2,1),visibility 0s linear .2s;
|
||||||
|
visibility:hidden;
|
||||||
white-space:normal;
|
white-space:normal;
|
||||||
|
will-change:opacity,transform;
|
||||||
}
|
}
|
||||||
.search-result-filters-tooltip span{
|
.search-result-filters-tooltip span{
|
||||||
display:block;
|
display:block;
|
||||||
padding:.1875rem 0;
|
padding:.1875rem 0;
|
||||||
}
|
}
|
||||||
.search-result-filters-tooltip.is-visible{
|
.search-result-filters-tooltip.is-visible{
|
||||||
display:block;
|
opacity:1;
|
||||||
|
transform:translateY(0) scale(1);
|
||||||
|
transition-delay:0s;
|
||||||
|
visibility:visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media(prefers-reduced-motion:reduce){
|
||||||
|
.search-result-filters-tooltip{transition:none;transform:none}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media(max-width:64rem){
|
@media(max-width:64rem){
|
||||||
|
|||||||
@@ -1323,20 +1323,27 @@ const renderSearchResults=()=>{
|
|||||||
const tooltipText=document.createElement('span');
|
const tooltipText=document.createElement('span');
|
||||||
tooltipText.textContent=fullText;
|
tooltipText.textContent=fullText;
|
||||||
tooltip.append(tooltipText);
|
tooltip.append(tooltipText);
|
||||||
|
let tooltipTimer=0;
|
||||||
const showTooltip=()=>{
|
const showTooltip=()=>{
|
||||||
if(item.scrollWidth<=item.clientWidth)return;
|
if(item.scrollWidth<=item.clientWidth)return;
|
||||||
tooltip.classList.add('is-visible');
|
clearTimeout(tooltipTimer);
|
||||||
const anchorRect=item.getBoundingClientRect();
|
tooltipTimer=setTimeout(()=>{
|
||||||
const tooltipRect=tooltip.getBoundingClientRect();
|
const anchorRect=item.getBoundingClientRect();
|
||||||
const left=Math.max(.5*16,Math.min(anchorRect.left,innerWidth-tooltipRect.width-.5*16));
|
const tooltipRect=tooltip.getBoundingClientRect();
|
||||||
const below=anchorRect.bottom+.5*16;
|
const left=Math.max(.5*16,Math.min(anchorRect.left,innerWidth-tooltipRect.width-.5*16));
|
||||||
const top=below+tooltipRect.height<=innerHeight-.5*16
|
const below=anchorRect.bottom+.5*16;
|
||||||
? below
|
const top=below+tooltipRect.height<=innerHeight-.5*16
|
||||||
: Math.max(.5*16,anchorRect.top-tooltipRect.height-.5*16);
|
? below
|
||||||
tooltip.style.left=`${left}px`;
|
: Math.max(.5*16,anchorRect.top-tooltipRect.height-.5*16);
|
||||||
tooltip.style.top=`${top}px`;
|
tooltip.style.left=`${left}px`;
|
||||||
|
tooltip.style.top=`${top}px`;
|
||||||
|
tooltip.classList.add('is-visible');
|
||||||
|
},420);
|
||||||
|
};
|
||||||
|
const hideTooltip=()=>{
|
||||||
|
clearTimeout(tooltipTimer);
|
||||||
|
tooltip.classList.remove('is-visible');
|
||||||
};
|
};
|
||||||
const hideTooltip=()=>tooltip.classList.remove('is-visible');
|
|
||||||
item.addEventListener('mouseenter',showTooltip);
|
item.addEventListener('mouseenter',showTooltip);
|
||||||
item.addEventListener('mouseleave',hideTooltip);
|
item.addEventListener('mouseleave',hideTooltip);
|
||||||
item.addEventListener('focus',showTooltip);
|
item.addEventListener('focus',showTooltip);
|
||||||
@@ -1374,19 +1381,26 @@ const renderSearchResults=()=>{
|
|||||||
tooltip.append(item);
|
tooltip.append(item);
|
||||||
});
|
});
|
||||||
more.setAttribute('aria-describedby',tooltipId);
|
more.setAttribute('aria-describedby',tooltipId);
|
||||||
|
let tooltipTimer=0;
|
||||||
const showTooltip=()=>{
|
const showTooltip=()=>{
|
||||||
tooltip.classList.add('is-visible');
|
clearTimeout(tooltipTimer);
|
||||||
const anchorRect=more.getBoundingClientRect();
|
tooltipTimer=setTimeout(()=>{
|
||||||
const tooltipRect=tooltip.getBoundingClientRect();
|
const anchorRect=more.getBoundingClientRect();
|
||||||
const left=Math.max(.5*16,Math.min(anchorRect.right-tooltipRect.width,innerWidth-tooltipRect.width-.5*16));
|
const tooltipRect=tooltip.getBoundingClientRect();
|
||||||
const below=anchorRect.bottom+.5*16;
|
const left=Math.max(.5*16,Math.min(anchorRect.right-tooltipRect.width,innerWidth-tooltipRect.width-.5*16));
|
||||||
const top=below+tooltipRect.height<=innerHeight-.5*16
|
const below=anchorRect.bottom+.5*16;
|
||||||
? below
|
const top=below+tooltipRect.height<=innerHeight-.5*16
|
||||||
: Math.max(.5*16,anchorRect.top-tooltipRect.height-.5*16);
|
? below
|
||||||
tooltip.style.left=`${left}px`;
|
: Math.max(.5*16,anchorRect.top-tooltipRect.height-.5*16);
|
||||||
tooltip.style.top=`${top}px`;
|
tooltip.style.left=`${left}px`;
|
||||||
|
tooltip.style.top=`${top}px`;
|
||||||
|
tooltip.classList.add('is-visible');
|
||||||
|
},420);
|
||||||
|
};
|
||||||
|
const hideTooltip=()=>{
|
||||||
|
clearTimeout(tooltipTimer);
|
||||||
|
tooltip.classList.remove('is-visible');
|
||||||
};
|
};
|
||||||
const hideTooltip=()=>tooltip.classList.remove('is-visible');
|
|
||||||
more.addEventListener('mouseenter',showTooltip);
|
more.addEventListener('mouseenter',showTooltip);
|
||||||
more.addEventListener('mouseleave',hideTooltip);
|
more.addEventListener('mouseleave',hideTooltip);
|
||||||
more.addEventListener('focus',showTooltip);
|
more.addEventListener('focus',showTooltip);
|
||||||
|
|||||||
Reference in New Issue
Block a user