@rogieking/figui3 4.9.0 → 4.9.1
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 +37 -62
- package/dist/components.css +1 -1
- package/dist/fig.css +1 -1
- package/dist/fig.js +35 -35
- package/fig.js +17 -44
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -8380,7 +8380,6 @@ customElements.define("fig-swatch", FigSwatch);
|
|
|
8380
8380
|
*/
|
|
8381
8381
|
class FigMedia extends HTMLElement {
|
|
8382
8382
|
#src = null;
|
|
8383
|
-
#chit = null;
|
|
8384
8383
|
#mediaEl = null;
|
|
8385
8384
|
#fileInput = null;
|
|
8386
8385
|
#blobUrl = null;
|
|
@@ -8465,27 +8464,16 @@ class FigMedia extends HTMLElement {
|
|
|
8465
8464
|
|
|
8466
8465
|
const ar = this.getAttribute("aspect-ratio");
|
|
8467
8466
|
if (ar) {
|
|
8468
|
-
this.style.setProperty("--aspect-ratio", ar);
|
|
8467
|
+
this.style.setProperty("--fig-media-aspect-ratio", ar);
|
|
8468
|
+
} else {
|
|
8469
|
+
this.style.setProperty("--fig-media-aspect-ratio", "4/3");
|
|
8469
8470
|
}
|
|
8470
8471
|
const fit = this.getAttribute("fit");
|
|
8471
8472
|
if (fit) {
|
|
8472
|
-
this.style.setProperty("--fit", fit);
|
|
8473
|
+
this.style.setProperty("--fig-media-fit", fit);
|
|
8473
8474
|
}
|
|
8474
8475
|
|
|
8475
|
-
|
|
8476
|
-
const chit = document.createElement("fig-chit");
|
|
8477
|
-
chit.setAttribute("data-generated", "");
|
|
8478
|
-
chit.setAttribute("size", "large");
|
|
8479
|
-
chit.setAttribute("data-type", this.mediaKind);
|
|
8480
|
-
chit.setAttribute("disabled", "");
|
|
8481
|
-
this.#applyChitBackground(chit);
|
|
8482
|
-
if (this.hasAttribute("checkerboard") && this.getAttribute("checkerboard") !== "false") {
|
|
8483
|
-
chit.setAttribute("checkerboard", "");
|
|
8484
|
-
}
|
|
8485
|
-
this.prepend(chit);
|
|
8486
|
-
}
|
|
8487
|
-
this.#chit = this.querySelector("fig-chit");
|
|
8488
|
-
this.#syncChitType();
|
|
8476
|
+
this.querySelectorAll("fig-chit[data-generated]").forEach((el) => el.remove());
|
|
8489
8477
|
this.#ensureMediaElement();
|
|
8490
8478
|
this.#syncGeneratedMediaElement();
|
|
8491
8479
|
|
|
@@ -8504,16 +8492,6 @@ class FigMedia extends HTMLElement {
|
|
|
8504
8492
|
}
|
|
8505
8493
|
}
|
|
8506
8494
|
|
|
8507
|
-
#applyChitBackground(chit) {
|
|
8508
|
-
const cb = this.hasAttribute("checkerboard") && this.getAttribute("checkerboard") !== "false";
|
|
8509
|
-
chit.setAttribute("background", cb ? "url()" : "var(--figma-color-bg-secondary)");
|
|
8510
|
-
}
|
|
8511
|
-
|
|
8512
|
-
#syncChitType() {
|
|
8513
|
-
if (!this.#chit) return;
|
|
8514
|
-
this.#chit.setAttribute("data-type", this.mediaKind);
|
|
8515
|
-
}
|
|
8516
|
-
|
|
8517
8495
|
#removeMediaElementListeners() {
|
|
8518
8496
|
if (!this.#mediaEl) return;
|
|
8519
8497
|
if (this.#mediaEl.tagName === "VIDEO") {
|
|
@@ -8556,12 +8534,19 @@ class FigMedia extends HTMLElement {
|
|
|
8556
8534
|
video.setAttribute("data-generated", "");
|
|
8557
8535
|
video.className = "fig-media-element";
|
|
8558
8536
|
video.setAttribute("playsinline", "");
|
|
8559
|
-
video.preload = "
|
|
8537
|
+
video.preload = "auto";
|
|
8560
8538
|
this.prepend(video);
|
|
8561
8539
|
this.#mediaEl = video;
|
|
8562
8540
|
this.#mediaEl.addEventListener("play", this.#boundHandleMediaPlay);
|
|
8563
8541
|
this.#mediaEl.addEventListener("pause", this.#boundHandleMediaPause);
|
|
8564
8542
|
this.#mediaEl.addEventListener("ended", this.#boundHandleMediaEnded);
|
|
8543
|
+
const seekToFirstFrame = () => {
|
|
8544
|
+
if (this.#mediaEl?.autoplay) return;
|
|
8545
|
+
try {
|
|
8546
|
+
this.#mediaEl.currentTime = 0.001;
|
|
8547
|
+
} catch {}
|
|
8548
|
+
};
|
|
8549
|
+
this.#mediaEl.addEventListener("loadedmetadata", seekToFirstFrame, { once: true });
|
|
8565
8550
|
} else {
|
|
8566
8551
|
const img = document.createElement("img");
|
|
8567
8552
|
img.setAttribute("data-generated", "");
|
|
@@ -8724,7 +8709,6 @@ class FigMedia extends HTMLElement {
|
|
|
8724
8709
|
}
|
|
8725
8710
|
|
|
8726
8711
|
if (name === "type") {
|
|
8727
|
-
this.#syncChitType();
|
|
8728
8712
|
this.#ensureMediaElement();
|
|
8729
8713
|
this.#syncGeneratedMediaElement();
|
|
8730
8714
|
if (this.#fileInput) {
|
|
@@ -8750,28 +8734,17 @@ class FigMedia extends HTMLElement {
|
|
|
8750
8734
|
|
|
8751
8735
|
if (name === "aspect-ratio") {
|
|
8752
8736
|
if (newValue) {
|
|
8753
|
-
this.style.setProperty("--aspect-ratio", newValue);
|
|
8737
|
+
this.style.setProperty("--fig-media-aspect-ratio", newValue);
|
|
8754
8738
|
} else {
|
|
8755
|
-
this.style.removeProperty("--aspect-ratio");
|
|
8739
|
+
this.style.removeProperty("--fig-media-aspect-ratio");
|
|
8756
8740
|
}
|
|
8757
8741
|
}
|
|
8758
8742
|
|
|
8759
8743
|
if (name === "fit") {
|
|
8760
8744
|
if (newValue) {
|
|
8761
|
-
this.style.setProperty("--fit", newValue);
|
|
8745
|
+
this.style.setProperty("--fig-media-fit", newValue);
|
|
8762
8746
|
} else {
|
|
8763
|
-
this.style.removeProperty("--fit");
|
|
8764
|
-
}
|
|
8765
|
-
}
|
|
8766
|
-
|
|
8767
|
-
if (name === "checkerboard") {
|
|
8768
|
-
if (this.#chit) {
|
|
8769
|
-
if (newValue !== null && newValue !== "false") {
|
|
8770
|
-
this.#chit.setAttribute("checkerboard", "");
|
|
8771
|
-
} else {
|
|
8772
|
-
this.#chit.removeAttribute("checkerboard");
|
|
8773
|
-
}
|
|
8774
|
-
this.#applyChitBackground(this.#chit);
|
|
8747
|
+
this.style.removeProperty("--fig-media-fit");
|
|
8775
8748
|
}
|
|
8776
8749
|
}
|
|
8777
8750
|
|
package/package.json
CHANGED