@rogieking/figui3 6.6.6 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components.css +27 -1
- package/dist/components.css +1 -1
- package/dist/fig.css +1 -1
- package/dist/fig.js +14 -14
- package/fig.js +21 -8
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -747,8 +747,8 @@ customElements.define("fig-dropdown", FigDropdown);
|
|
|
747
747
|
*/
|
|
748
748
|
class FigTooltip extends HTMLElement {
|
|
749
749
|
static #lastShownAt = 0;
|
|
750
|
-
static #
|
|
751
|
-
static #warmupWindow =
|
|
750
|
+
static #lastHiddenAt = 0;
|
|
751
|
+
static #warmupWindow = 1000;
|
|
752
752
|
static #hoverOpen = null;
|
|
753
753
|
|
|
754
754
|
#boundHideOnChromeOpen;
|
|
@@ -989,17 +989,29 @@ class FigTooltip extends HTMLElement {
|
|
|
989
989
|
return this.hasAttribute("show") && this.getAttribute("show") !== "false";
|
|
990
990
|
}
|
|
991
991
|
|
|
992
|
+
#isWarmSession() {
|
|
993
|
+
const now = Date.now();
|
|
994
|
+
const windowMs = FigTooltip.#warmupWindow;
|
|
995
|
+
if (this.action === "hover" && FigTooltip.#hoverOpen) return true;
|
|
996
|
+
if (FigTooltip.#lastShownAt && now - FigTooltip.#lastShownAt < windowMs)
|
|
997
|
+
return true;
|
|
998
|
+
if (FigTooltip.#lastHiddenAt && now - FigTooltip.#lastHiddenAt < windowMs)
|
|
999
|
+
return true;
|
|
1000
|
+
return false;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
992
1003
|
showDelayedPopup() {
|
|
993
1004
|
if (this.#showPersisted) return;
|
|
994
1005
|
clearTimeout(this.timeout);
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1006
|
+
if (this.#isWarmSession()) {
|
|
1007
|
+
this.render();
|
|
1008
|
+
this.showPopup();
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
999
1011
|
this.timeout = setTimeout(() => {
|
|
1000
1012
|
this.render();
|
|
1001
1013
|
this.showPopup();
|
|
1002
|
-
},
|
|
1014
|
+
}, this.delay);
|
|
1003
1015
|
}
|
|
1004
1016
|
|
|
1005
1017
|
showPopup() {
|
|
@@ -1021,19 +1033,20 @@ class FigTooltip extends HTMLElement {
|
|
|
1021
1033
|
this.isOpen = true;
|
|
1022
1034
|
if (this.action === "hover") FigTooltip.#hoverOpen = this;
|
|
1023
1035
|
FigTooltip.#lastShownAt = Date.now();
|
|
1024
|
-
FigTooltip.#lastShownInstance = this;
|
|
1025
1036
|
}
|
|
1026
1037
|
|
|
1027
1038
|
hidePopup() {
|
|
1028
1039
|
if (this.#showPersisted) return;
|
|
1029
1040
|
clearTimeout(this.timeout);
|
|
1030
1041
|
clearTimeout(this.#touchTimeout);
|
|
1042
|
+
const wasShowing = this.isOpen;
|
|
1031
1043
|
if (this.popup) {
|
|
1032
1044
|
this.destroy();
|
|
1033
1045
|
}
|
|
1034
1046
|
|
|
1035
1047
|
this.isOpen = false;
|
|
1036
1048
|
if (FigTooltip.#hoverOpen === this) FigTooltip.#hoverOpen = null;
|
|
1049
|
+
if (wasShowing) FigTooltip.#lastHiddenAt = Date.now();
|
|
1037
1050
|
}
|
|
1038
1051
|
|
|
1039
1052
|
hidePopupOutsideClick(event) {
|
package/package.json
CHANGED