@rogieking/figui3 2.34.0 → 2.35.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 +4 -1
- package/fig.js +47 -6
- package/package.json +1 -1
package/components.css
CHANGED
|
@@ -1440,6 +1440,8 @@ fig-3d-rotate {
|
|
|
1440
1440
|
width: 100%;
|
|
1441
1441
|
--aspect-ratio: 1 / 1;
|
|
1442
1442
|
--perspective: 20rem;
|
|
1443
|
+
--perspective-origin: 50% 50%;
|
|
1444
|
+
--transform-origin: 50% 50% -50cqi;
|
|
1443
1445
|
--gradient-start-color: light-dark(
|
|
1444
1446
|
rgba(0, 0, 0, 0.05),
|
|
1445
1447
|
rgba(255, 255, 255, 0.05)
|
|
@@ -1493,6 +1495,7 @@ fig-3d-rotate {
|
|
|
1493
1495
|
max-height: max(3.5rem, 50%);
|
|
1494
1496
|
max-width: max(3.5rem, 50%);
|
|
1495
1497
|
perspective: var(--perspective, 20rem);
|
|
1498
|
+
perspective-origin: var(--perspective-origin, 50% 50%);
|
|
1496
1499
|
container-type: inline-size;
|
|
1497
1500
|
}
|
|
1498
1501
|
|
|
@@ -1502,7 +1505,7 @@ fig-3d-rotate {
|
|
|
1502
1505
|
position: relative;
|
|
1503
1506
|
aspect-ratio: 1 / 1;
|
|
1504
1507
|
transform-style: preserve-3d;
|
|
1505
|
-
transform-origin: 50% 50% -50cqi;
|
|
1508
|
+
transform-origin: var(--transform-origin, 50% 50% -50cqi);
|
|
1506
1509
|
}
|
|
1507
1510
|
|
|
1508
1511
|
.fig-3d-rotate-face {
|
package/fig.js
CHANGED
|
@@ -6462,13 +6462,15 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6462
6462
|
#fieldInputs = {};
|
|
6463
6463
|
|
|
6464
6464
|
static get observedAttributes() {
|
|
6465
|
-
return ["value", "precision", "aspect-ratio", "fields", "perspective"];
|
|
6465
|
+
return ["value", "precision", "aspect-ratio", "fields", "perspective", "perspective-origin", "transform-origin"];
|
|
6466
6466
|
}
|
|
6467
6467
|
|
|
6468
6468
|
connectedCallback() {
|
|
6469
6469
|
this.#precision = parseInt(this.getAttribute("precision") || "1");
|
|
6470
6470
|
this.#syncAspectRatioVar(this.getAttribute("aspect-ratio"));
|
|
6471
6471
|
this.#syncPerspectiveVar(this.getAttribute("perspective"));
|
|
6472
|
+
this.#syncCSSVar("--perspective-origin", this.getAttribute("perspective-origin"));
|
|
6473
|
+
this.#syncTransformOrigin(this.getAttribute("transform-origin"));
|
|
6472
6474
|
this.#parseFields(this.getAttribute("fields"));
|
|
6473
6475
|
const val = this.getAttribute("value");
|
|
6474
6476
|
if (val) this.#parseValue(val);
|
|
@@ -6499,6 +6501,27 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6499
6501
|
}
|
|
6500
6502
|
}
|
|
6501
6503
|
|
|
6504
|
+
#syncCSSVar(prop, value) {
|
|
6505
|
+
if (value && value.trim()) {
|
|
6506
|
+
this.style.setProperty(prop, value.trim());
|
|
6507
|
+
} else {
|
|
6508
|
+
this.style.removeProperty(prop);
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6511
|
+
|
|
6512
|
+
#syncTransformOrigin(value) {
|
|
6513
|
+
if (!value || !value.trim()) {
|
|
6514
|
+
this.style.removeProperty("--transform-origin");
|
|
6515
|
+
return;
|
|
6516
|
+
}
|
|
6517
|
+
const parts = value.trim().split(/\s+/);
|
|
6518
|
+
if (parts.length === 2) {
|
|
6519
|
+
this.style.setProperty("--transform-origin", `${parts[0]} ${parts[1]} -50cqi`);
|
|
6520
|
+
} else {
|
|
6521
|
+
this.style.setProperty("--transform-origin", value.trim());
|
|
6522
|
+
}
|
|
6523
|
+
}
|
|
6524
|
+
|
|
6502
6525
|
#parseFields(str) {
|
|
6503
6526
|
if (!str || !str.trim()) {
|
|
6504
6527
|
this.#fields = [];
|
|
@@ -6520,6 +6543,14 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6520
6543
|
this.#syncPerspectiveVar(newValue);
|
|
6521
6544
|
return;
|
|
6522
6545
|
}
|
|
6546
|
+
if (name === "perspective-origin") {
|
|
6547
|
+
this.#syncCSSVar("--perspective-origin", newValue);
|
|
6548
|
+
return;
|
|
6549
|
+
}
|
|
6550
|
+
if (name === "transform-origin") {
|
|
6551
|
+
this.#syncTransformOrigin(newValue);
|
|
6552
|
+
return;
|
|
6553
|
+
}
|
|
6523
6554
|
if (name === "fields") {
|
|
6524
6555
|
this.#parseFields(newValue);
|
|
6525
6556
|
if (this.#cube) this.#render();
|
|
@@ -6668,6 +6699,7 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6668
6699
|
e.preventDefault();
|
|
6669
6700
|
this.#isDragging = true;
|
|
6670
6701
|
this.#container.classList.add("dragging");
|
|
6702
|
+
this.#container.setPointerCapture(e.pointerId);
|
|
6671
6703
|
|
|
6672
6704
|
const startX = e.clientX;
|
|
6673
6705
|
const startY = e.clientY;
|
|
@@ -6676,6 +6708,10 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6676
6708
|
|
|
6677
6709
|
const onMove = (e) => {
|
|
6678
6710
|
if (!this.#isDragging) return;
|
|
6711
|
+
if (e.buttons === 0) {
|
|
6712
|
+
onEnd();
|
|
6713
|
+
return;
|
|
6714
|
+
}
|
|
6679
6715
|
const dx = e.clientX - startX;
|
|
6680
6716
|
const dy = e.clientY - startY;
|
|
6681
6717
|
this.#ry = this.#snapToIncrement(startRy + dx * 0.5);
|
|
@@ -6686,17 +6722,22 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6686
6722
|
this.#emit("input");
|
|
6687
6723
|
};
|
|
6688
6724
|
|
|
6689
|
-
const
|
|
6725
|
+
const onEnd = () => {
|
|
6726
|
+
if (!this.#isDragging) return;
|
|
6690
6727
|
this.setAttribute("value", this.value);
|
|
6691
6728
|
this.#isDragging = false;
|
|
6692
6729
|
this.#container.classList.remove("dragging");
|
|
6693
|
-
|
|
6694
|
-
|
|
6730
|
+
this.#container.removeEventListener("pointermove", onMove);
|
|
6731
|
+
this.#container.removeEventListener("pointerup", onEnd);
|
|
6732
|
+
this.#container.removeEventListener("pointercancel", onEnd);
|
|
6733
|
+
this.#container.removeEventListener("lostpointercapture", onEnd);
|
|
6695
6734
|
this.#emit("change");
|
|
6696
6735
|
};
|
|
6697
6736
|
|
|
6698
|
-
|
|
6699
|
-
|
|
6737
|
+
this.#container.addEventListener("pointermove", onMove);
|
|
6738
|
+
this.#container.addEventListener("pointerup", onEnd);
|
|
6739
|
+
this.#container.addEventListener("pointercancel", onEnd);
|
|
6740
|
+
this.#container.addEventListener("lostpointercapture", onEnd);
|
|
6700
6741
|
}
|
|
6701
6742
|
}
|
|
6702
6743
|
customElements.define("fig-3d-rotate", Fig3DRotate);
|
package/package.json
CHANGED