basic tooltip fix by KitCat #62
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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>`
|
||||
|
||||
Reference in New Issue
Block a user