@rogieking/figui3 6.4.0 → 6.4.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 +21 -3
- package/dist/base.css +1 -1
- package/dist/components.css +1 -1
- package/dist/fig-editor.css +1 -1
- package/dist/fig.css +1 -1
- package/dist/fig.js +18 -18
- package/fig.js +28 -36
- package/package.json +1 -1
- package/dist/.min-css/fig-y6bay2cg.css +0 -2
- package/dist/.min-css/fig.js +0 -1
- package/dist/editor.js +0 -10718
- package/dist/fig-fill-picker.css +0 -1
- package/dist/fig-fill-picker.js +0 -160
- package/dist/fig.min.js +0 -399
package/fig.js
CHANGED
|
@@ -7878,7 +7878,7 @@ class FigInputGradient extends HTMLElement {
|
|
|
7878
7878
|
}
|
|
7879
7879
|
this.#gradient.stops[idx].position = position;
|
|
7880
7880
|
if (position !== rawPosition) {
|
|
7881
|
-
handle.style.left = `${(position / 100) * trackW
|
|
7881
|
+
handle.style.left = `${(position / 100) * trackW}px`;
|
|
7882
7882
|
}
|
|
7883
7883
|
const tooltip = handle.closest("fig-tooltip");
|
|
7884
7884
|
if (tooltip) {
|
|
@@ -7930,7 +7930,7 @@ class FigInputGradient extends HTMLElement {
|
|
|
7930
7930
|
}
|
|
7931
7931
|
}
|
|
7932
7932
|
this.#gradient.stops[idx].position = position;
|
|
7933
|
-
handle.style.left = `${(position / 100) * trackW
|
|
7933
|
+
handle.style.left = `${(position / 100) * trackW}px`;
|
|
7934
7934
|
this.#gradient.stops.sort((a, b) => a.position - b.position);
|
|
7935
7935
|
this.#syncStopIndices();
|
|
7936
7936
|
this.#syncChit();
|
|
@@ -13537,37 +13537,40 @@ class FigHandle extends HTMLElement {
|
|
|
13537
13537
|
|
|
13538
13538
|
const { xToken, yToken } = this.#parseValue(str);
|
|
13539
13539
|
const rect = container.getBoundingClientRect();
|
|
13540
|
-
const hw = this.offsetWidth / 2;
|
|
13541
|
-
const hh = this.offsetHeight / 2;
|
|
13542
13540
|
|
|
13543
|
-
const resolvePx = (token, containerDim
|
|
13541
|
+
const resolvePx = (token, containerDim) => {
|
|
13544
13542
|
if (token && typeof token === "object" && "px" in token) {
|
|
13545
|
-
return Math.max(
|
|
13546
|
-
-halfHandle,
|
|
13547
|
-
Math.min(containerDim - halfHandle, token.px - halfHandle),
|
|
13548
|
-
);
|
|
13543
|
+
return Math.max(0, Math.min(containerDim, token.px));
|
|
13549
13544
|
}
|
|
13550
13545
|
return null;
|
|
13551
13546
|
};
|
|
13552
13547
|
|
|
13553
|
-
const resolveResponsive = (token
|
|
13548
|
+
const resolveResponsive = (token) => {
|
|
13554
13549
|
const pct = typeof token === "number" ? token : 0;
|
|
13555
|
-
return
|
|
13550
|
+
return `${pct}%`;
|
|
13556
13551
|
};
|
|
13557
13552
|
|
|
13558
13553
|
const axes = this.#axes;
|
|
13554
|
+
this.#syncPositionTranslate(axes);
|
|
13559
13555
|
if (axes.x) {
|
|
13560
|
-
const xPx = resolvePx(xToken, rect.width
|
|
13556
|
+
const xPx = resolvePx(xToken, rect.width);
|
|
13561
13557
|
this.style.left =
|
|
13562
|
-
xPx === null ? resolveResponsive(xToken
|
|
13558
|
+
xPx === null ? resolveResponsive(xToken) : `${Math.round(xPx)}px`;
|
|
13563
13559
|
}
|
|
13564
13560
|
if (axes.y) {
|
|
13565
|
-
const yPx = resolvePx(yToken, rect.height
|
|
13561
|
+
const yPx = resolvePx(yToken, rect.height);
|
|
13566
13562
|
this.style.top =
|
|
13567
|
-
yPx === null ? resolveResponsive(yToken
|
|
13563
|
+
yPx === null ? resolveResponsive(yToken) : `${Math.round(yPx)}px`;
|
|
13568
13564
|
}
|
|
13569
13565
|
}
|
|
13570
13566
|
|
|
13567
|
+
#syncPositionTranslate(axes = this.#axes) {
|
|
13568
|
+
this.style.setProperty(
|
|
13569
|
+
"--fig-handle-position-translate",
|
|
13570
|
+
`${axes.x ? "-50%" : "0"} ${axes.y ? "-50%" : "0"}`,
|
|
13571
|
+
);
|
|
13572
|
+
}
|
|
13573
|
+
|
|
13571
13574
|
#syncValueAttribute() {
|
|
13572
13575
|
this.#applyingValue = true;
|
|
13573
13576
|
this.setAttribute("value", this.value);
|
|
@@ -13768,8 +13771,6 @@ class FigHandle extends HTMLElement {
|
|
|
13768
13771
|
|
|
13769
13772
|
this.#isDragging = true;
|
|
13770
13773
|
const axes = this.#axes;
|
|
13771
|
-
const handleW = this.offsetWidth;
|
|
13772
|
-
const handleH = this.offsetHeight;
|
|
13773
13774
|
let lastRect = null;
|
|
13774
13775
|
|
|
13775
13776
|
const handleRect = this.getBoundingClientRect();
|
|
@@ -13786,27 +13787,19 @@ class FigHandle extends HTMLElement {
|
|
|
13786
13787
|
const rect = container.getBoundingClientRect();
|
|
13787
13788
|
lastRect = rect;
|
|
13788
13789
|
const currentPosition = this.#positionDetail(rect);
|
|
13789
|
-
const
|
|
13790
|
-
const
|
|
13791
|
-
|
|
13792
|
-
const
|
|
13793
|
-
|
|
13794
|
-
const clampedX = Math.max(
|
|
13795
|
-
-handleW / 2,
|
|
13796
|
-
Math.min(rect.width - handleW / 2, rawX),
|
|
13797
|
-
);
|
|
13798
|
-
const clampedY = Math.max(
|
|
13799
|
-
-handleH / 2,
|
|
13800
|
-
Math.min(rect.height - handleH / 2, rawY),
|
|
13801
|
-
);
|
|
13790
|
+
const rawCenterX = clientX - offsetX - rect.left;
|
|
13791
|
+
const rawCenterY = clientY - offsetY - rect.top;
|
|
13792
|
+
|
|
13793
|
+
const clampedCenterX = Math.max(0, Math.min(rect.width, rawCenterX));
|
|
13794
|
+
const clampedCenterY = Math.max(0, Math.min(rect.height, rawCenterY));
|
|
13802
13795
|
|
|
13803
13796
|
let centerX =
|
|
13804
13797
|
rect.width > 0
|
|
13805
|
-
? (
|
|
13798
|
+
? (axes.x ? clampedCenterX / rect.width : currentPosition.px)
|
|
13806
13799
|
: 0.5;
|
|
13807
13800
|
let centerY =
|
|
13808
13801
|
rect.height > 0
|
|
13809
|
-
? (
|
|
13802
|
+
? (axes.y ? clampedCenterY / rect.height : currentPosition.py)
|
|
13810
13803
|
: 0.5;
|
|
13811
13804
|
|
|
13812
13805
|
if (this.#shouldSnap(shiftKey)) {
|
|
@@ -13819,13 +13812,12 @@ class FigHandle extends HTMLElement {
|
|
|
13819
13812
|
}
|
|
13820
13813
|
}
|
|
13821
13814
|
|
|
13815
|
+
this.#syncPositionTranslate(axes);
|
|
13822
13816
|
if (axes.x) {
|
|
13823
|
-
|
|
13824
|
-
this.style.left = `${Math.round(Math.max(-handleW / 2, Math.min(rect.width - handleW / 2, left)))}px`;
|
|
13817
|
+
this.style.left = `${Math.round(Math.max(0, Math.min(rect.width, centerX * rect.width)))}px`;
|
|
13825
13818
|
}
|
|
13826
13819
|
if (axes.y) {
|
|
13827
|
-
|
|
13828
|
-
this.style.top = `${Math.round(Math.max(-handleH / 2, Math.min(rect.height - handleH / 2, top)))}px`;
|
|
13820
|
+
this.style.top = `${Math.round(Math.max(0, Math.min(rect.height, centerY * rect.height)))}px`;
|
|
13829
13821
|
}
|
|
13830
13822
|
};
|
|
13831
13823
|
|
package/package.json
CHANGED
package/dist/.min-css/fig.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var r="./fig-y6bay2cg.css";export{r as default};
|