tooltips now fully styled, appearing above applet container to avoid clipping issues; new methods added to apps.lyric.models.Token
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
function initGameKitTooltips() {
|
||||
const portal = document.getElementById('id_tooltip_portal');
|
||||
if (!portal) return;
|
||||
|
||||
document.querySelectorAll('#id_game_kit .token').forEach(token => {
|
||||
const tooltip = token.querySelector('.token-tooltip');
|
||||
if (!tooltip) return;
|
||||
|
||||
token.addEventListener('mouseenter', () => {
|
||||
const rect = token.getBoundingClientRect();
|
||||
portal.innerHTML = tooltip.innerHTML;
|
||||
portal.style.left = Math.round(rect.left + rect.width / 2) + 'px';
|
||||
portal.style.top = Math.round(rect.top) + 'px';
|
||||
portal.style.transform = 'translate(-50%, calc(-100% - 0.5rem))';
|
||||
portal.classList.add('active');
|
||||
});
|
||||
|
||||
token.addEventListener('mouseleave', () => {
|
||||
portal.classList.remove('active');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initGameKitTooltips);
|
||||
|
||||
Reference in New Issue
Block a user