mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-23 05:26:15 -04:00
starting perk, settings icons
This commit is contained in:
parent
991e7a1d85
commit
1cf82d6641
12 changed files with 467 additions and 185 deletions
|
@ -7,12 +7,18 @@ export function setupTooltips() {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
function updateTooltipPosition(e: MouseEvent) {
|
||||
tooltip.style.transform =
|
||||
`translate(${e.clientX}px,${e.clientY + 20}px) ` +
|
||||
(e.clientX > window.innerWidth / 2 ? " translate(-100%,0)" : "");
|
||||
}
|
||||
|
||||
function closeToolTip(){
|
||||
tooltip.style.display = "none";
|
||||
hovering=null
|
||||
}
|
||||
let hovering:HTMLElement|null=null
|
||||
document.body.addEventListener(
|
||||
"mouseenter",
|
||||
(e: MouseEvent) => {
|
||||
|
@ -21,15 +27,24 @@ export function setupTooltips() {
|
|||
parent = parent.parentElement;
|
||||
}
|
||||
if (parent?.hasAttribute("data-tooltip")) {
|
||||
tooltip.innerHTML = parent?.getAttribute("data-tooltip");
|
||||
hovering=parent as HTMLElement
|
||||
tooltip.innerHTML = hovering.getAttribute("data-tooltip") || '';
|
||||
tooltip.style.display = "";
|
||||
updateTooltipPosition(e);
|
||||
} else {
|
||||
tooltip.style.display = "none";
|
||||
closeToolTip()
|
||||
}
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
setInterval(()=>{
|
||||
if(hovering){
|
||||
if(!document.body.contains(hovering)){
|
||||
closeToolTip()
|
||||
}
|
||||
}
|
||||
},200)
|
||||
document.body.addEventListener(
|
||||
"mousemove",
|
||||
(e) => {
|
||||
|
@ -42,8 +57,7 @@ export function setupTooltips() {
|
|||
document.body.addEventListener(
|
||||
"mouseleave",
|
||||
(e) => {
|
||||
// tooltip.style.display = 'none';
|
||||
},
|
||||
true,
|
||||
closeToolTip()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue