basic tooltip fix by KitCat #62

This commit is contained in:
Vlyan
2025-09-05 10:20:55 +02:00
parent 30455759e8
commit dbba39373b
2 changed files with 22 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ Date format : day/month/year
- Fix for fade configuration (!66)
- Added basic token conditions (Thanks to Putty)
- Added ability to remove condition from actor sheet and core journal on click.
- Added some Tooltips loading optimizations (!62 Thanks to KitCat).
- Added some Properties loading optimizations (!63 Thanks to KitCat).
## 1.13.0 - 24/08/2025 - Foundry v13 Compatibility (Thx to Litasa)

View File

@@ -19,6 +19,12 @@ export class L5r5ePopupManager {
/** @type {HTMLElement} */
#container = null;
/**
* Increment number to ignore old tooltips if template is too long to load (#62)
* @type {number}
*/
#displayId = 0;
/**
* @param {string|jQuery} selector - Selector or jQuery object for tooltip-bound elements.
* @param {(event: MouseEvent) => Promise<string>} callback - Async function returning tooltip HTML content.
@@ -45,10 +51,24 @@ export class L5r5ePopupManager {
.on("mouseenter.popup", async (event) => {
$(this.#container).find("#l5r5e-tooltip-ct").remove();
// Memory save
if (this.#displayId >= 200) {
this.#displayId = 0;
}
const currentDisplayId = ++this.#displayId;
// Load the template, can take a while
const tpl = await this.#callback(event);
// Abort if no content or the target element is no longer in the DOM
if (!tpl || !document.body.contains(event.currentTarget)) return;
if (!tpl || !document.body.contains(event.currentTarget)) {
return;
}
// If mismatched, that tpl is too old, the user already display another tooltip
if (this.#displayId !== currentDisplayId) {
return;
}
$(this.#container).append(
`<div id="l5r5e-tooltip-ct" class="l5r5e-tooltip l5r5e-tooltip-ct">${tpl}</div>`