@rogieking/figui3 4.10.2 → 4.11.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 +34 -41
- package/dist/components.css +1 -1
- package/dist/fig.css +1 -1
- package/dist/fig.js +21 -21
- package/fig.js +44 -8
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -14380,6 +14380,35 @@ class FigChooser extends HTMLElement {
|
|
|
14380
14380
|
requestAnimationFrame(() => {
|
|
14381
14381
|
this.#syncSelection();
|
|
14382
14382
|
this.#syncOverflow();
|
|
14383
|
+
this.#scheduleInitialScrollSettle();
|
|
14384
|
+
});
|
|
14385
|
+
}
|
|
14386
|
+
|
|
14387
|
+
#scheduleInitialScrollSettle() {
|
|
14388
|
+
const resettle = () => {
|
|
14389
|
+
if (!this.isConnected) return;
|
|
14390
|
+
if (this.#selectedChoice) {
|
|
14391
|
+
this.#scrollToChoice(this.#selectedChoice, "auto");
|
|
14392
|
+
}
|
|
14393
|
+
};
|
|
14394
|
+
const wireImages = () => {
|
|
14395
|
+
const imgs = this.querySelectorAll("img, video");
|
|
14396
|
+
for (const m of imgs) {
|
|
14397
|
+
if (m.tagName === "IMG" ? m.complete : m.readyState >= 1) continue;
|
|
14398
|
+
const done = () => {
|
|
14399
|
+
m.removeEventListener("load", done);
|
|
14400
|
+
m.removeEventListener("loadedmetadata", done);
|
|
14401
|
+
m.removeEventListener("error", done);
|
|
14402
|
+
resettle();
|
|
14403
|
+
};
|
|
14404
|
+
m.addEventListener("load", done);
|
|
14405
|
+
m.addEventListener("loadedmetadata", done);
|
|
14406
|
+
m.addEventListener("error", done);
|
|
14407
|
+
}
|
|
14408
|
+
};
|
|
14409
|
+
requestAnimationFrame(() => {
|
|
14410
|
+
wireImages();
|
|
14411
|
+
resettle();
|
|
14383
14412
|
});
|
|
14384
14413
|
}
|
|
14385
14414
|
|
|
@@ -14758,25 +14787,31 @@ class FigChooser extends HTMLElement {
|
|
|
14758
14787
|
});
|
|
14759
14788
|
}
|
|
14760
14789
|
|
|
14761
|
-
#scrollToChoice(el) {
|
|
14790
|
+
#scrollToChoice(el, behavior = "smooth") {
|
|
14762
14791
|
if (!el) return;
|
|
14763
14792
|
requestAnimationFrame(() => {
|
|
14793
|
+
if (!el.isConnected) return;
|
|
14764
14794
|
const overflowY = this.scrollHeight > this.clientHeight;
|
|
14765
14795
|
const overflowX = this.scrollWidth > this.clientWidth;
|
|
14766
14796
|
if (!overflowX && !overflowY) return;
|
|
14767
14797
|
|
|
14768
|
-
const
|
|
14798
|
+
const choiceRect = el.getBoundingClientRect();
|
|
14799
|
+
const hostRect = this.getBoundingClientRect();
|
|
14800
|
+
const options = { behavior };
|
|
14769
14801
|
|
|
14770
14802
|
if (overflowY) {
|
|
14771
|
-
const
|
|
14772
|
-
|
|
14773
|
-
options.top =
|
|
14803
|
+
const choiceCenter =
|
|
14804
|
+
choiceRect.top - hostRect.top + this.scrollTop + choiceRect.height / 2;
|
|
14805
|
+
options.top = choiceCenter - this.clientHeight / 2;
|
|
14774
14806
|
}
|
|
14775
14807
|
|
|
14776
14808
|
if (overflowX) {
|
|
14777
|
-
const
|
|
14778
|
-
|
|
14779
|
-
|
|
14809
|
+
const choiceCenter =
|
|
14810
|
+
choiceRect.left -
|
|
14811
|
+
hostRect.left +
|
|
14812
|
+
this.scrollLeft +
|
|
14813
|
+
choiceRect.width / 2;
|
|
14814
|
+
options.left = choiceCenter - this.clientWidth / 2;
|
|
14780
14815
|
}
|
|
14781
14816
|
|
|
14782
14817
|
this.scrollTo(options);
|
|
@@ -15037,6 +15072,7 @@ class FigHandle extends HTMLElement {
|
|
|
15037
15072
|
}
|
|
15038
15073
|
|
|
15039
15074
|
connectedCallback() {
|
|
15075
|
+
if (!this.hasAttribute("type")) this.setAttribute("type", "canvas");
|
|
15040
15076
|
this.#syncDrag();
|
|
15041
15077
|
this.#syncHitArea();
|
|
15042
15078
|
this.addEventListener("click", this.#handleSelect);
|
package/package.json
CHANGED