@rogieking/figui3 1.2.3 → 1.2.5
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/example.html +7 -2
- package/fig.js +9 -1
- package/package.json +1 -1
package/example.html
CHANGED
|
@@ -584,9 +584,14 @@
|
|
|
584
584
|
<fig-field>
|
|
585
585
|
<label>Minimal ranges</label>
|
|
586
586
|
<fig-slider text="true"
|
|
587
|
-
|
|
587
|
+
min="0"
|
|
588
|
+
max="1"
|
|
589
|
+
style="width: 100%;"
|
|
590
|
+
step="0.01"
|
|
591
|
+
transform="100"
|
|
592
|
+
default="0.5"
|
|
588
593
|
variant="minimal"
|
|
589
|
-
value="
|
|
594
|
+
value="0.5"></fig-slider>
|
|
590
595
|
</fig-field>
|
|
591
596
|
<fig-field direction="horizontal">
|
|
592
597
|
<label>Opacity</label>
|
package/fig.js
CHANGED
|
@@ -936,7 +936,9 @@ class FigInputText extends HTMLElement {
|
|
|
936
936
|
this.input.focus();
|
|
937
937
|
}
|
|
938
938
|
#transformNumber(value) {
|
|
939
|
-
|
|
939
|
+
let transformed = value === "" ? "" : Number(value) * (this.transform || 1);
|
|
940
|
+
transformed = this.#formatNumber(transformed);
|
|
941
|
+
return transformed;
|
|
940
942
|
}
|
|
941
943
|
#handleInput(e) {
|
|
942
944
|
let value = e.target.value;
|
|
@@ -995,9 +997,15 @@ class FigInputText extends HTMLElement {
|
|
|
995
997
|
sanitized
|
|
996
998
|
);
|
|
997
999
|
}
|
|
1000
|
+
sanitized = this.#formatNumber(sanitized);
|
|
998
1001
|
}
|
|
999
1002
|
return sanitized;
|
|
1000
1003
|
}
|
|
1004
|
+
#formatNumber(num, precision = 2) {
|
|
1005
|
+
// Check if the number has any decimal places after rounding
|
|
1006
|
+
const rounded = Math.round(num * 100) / 100;
|
|
1007
|
+
return Number.isInteger(rounded) ? rounded : rounded.toFixed(precision);
|
|
1008
|
+
}
|
|
1001
1009
|
|
|
1002
1010
|
static get observedAttributes() {
|
|
1003
1011
|
return [
|