@rogieking/figui3 1.0.80 → 1.0.82
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 +8 -0
- package/fig.js +24 -23
- package/package.json +1 -1
package/example.html
CHANGED
|
@@ -19,6 +19,14 @@
|
|
|
19
19
|
<h2>Heading 2</h2>
|
|
20
20
|
<h3>Heading 3</h3>
|
|
21
21
|
<br />
|
|
22
|
+
<fig-slider id="test"
|
|
23
|
+
type="range"
|
|
24
|
+
min="0"
|
|
25
|
+
max="256"
|
|
26
|
+
value="100"
|
|
27
|
+
units="px"
|
|
28
|
+
text="true"></fig-slider>
|
|
29
|
+
<br />
|
|
22
30
|
<details>
|
|
23
31
|
<summary>Details</summary>
|
|
24
32
|
<p>Some more content here</p>
|
package/fig.js
CHANGED
|
@@ -642,6 +642,13 @@ class FigSlider extends HTMLElement {
|
|
|
642
642
|
super();
|
|
643
643
|
}
|
|
644
644
|
#regenerateInnerHTML() {
|
|
645
|
+
this.value = this.getAttribute("value") || 0;
|
|
646
|
+
this.default = this.getAttribute("default") || null;
|
|
647
|
+
this.type = this.getAttribute("type") || "range";
|
|
648
|
+
this.text = this.getAttribute("text") || false;
|
|
649
|
+
this.units = this.getAttribute("units") || "";
|
|
650
|
+
this.disabled = this.getAttribute("disabled") ? true : false;
|
|
651
|
+
|
|
645
652
|
const defaults = this.#typeDefaults[this.type];
|
|
646
653
|
this.min = this.getAttribute("min") || defaults.min;
|
|
647
654
|
this.max = this.getAttribute("max") || defaults.max;
|
|
@@ -683,18 +690,18 @@ class FigSlider extends HTMLElement {
|
|
|
683
690
|
html = slider;
|
|
684
691
|
}
|
|
685
692
|
this.innerHTML = html;
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
#setupBindings() {
|
|
693
|
+
|
|
689
694
|
//child nodes hack
|
|
690
695
|
requestAnimationFrame(() => {
|
|
691
696
|
this.input = this.querySelector("[type=range]");
|
|
692
697
|
this.input.removeEventListener("input", this.handleInput);
|
|
693
698
|
this.input.addEventListener("input", this.handleInput.bind(this));
|
|
694
|
-
this.handleInput();
|
|
695
699
|
|
|
696
700
|
if (this.default) {
|
|
697
|
-
this.style.setProperty(
|
|
701
|
+
this.style.setProperty(
|
|
702
|
+
"--default",
|
|
703
|
+
this.#calculateNormal(this.default)
|
|
704
|
+
);
|
|
698
705
|
}
|
|
699
706
|
|
|
700
707
|
this.datalist = this.querySelector("datalist");
|
|
@@ -713,19 +720,15 @@ class FigSlider extends HTMLElement {
|
|
|
713
720
|
this.handleTextInput.bind(this)
|
|
714
721
|
);
|
|
715
722
|
}
|
|
723
|
+
|
|
724
|
+
this.handleInput();
|
|
716
725
|
});
|
|
717
726
|
}
|
|
727
|
+
|
|
718
728
|
connectedCallback() {
|
|
719
|
-
this.value = this.getAttribute("value");
|
|
720
|
-
this.default = this.getAttribute("default") || null;
|
|
721
|
-
this.type = this.getAttribute("type") || "range";
|
|
722
|
-
this.text = this.getAttribute("text") || false;
|
|
723
|
-
this.units = this.getAttribute("units") || "";
|
|
724
|
-
this.disabled = this.getAttribute("disabled") ? true : false;
|
|
725
729
|
this.initialInnerHTML = this.innerHTML;
|
|
726
730
|
|
|
727
731
|
this.#regenerateInnerHTML();
|
|
728
|
-
this.#setupBindings();
|
|
729
732
|
}
|
|
730
733
|
static get observedAttributes() {
|
|
731
734
|
return [
|
|
@@ -760,22 +763,20 @@ class FigSlider extends HTMLElement {
|
|
|
760
763
|
this.figInputText.setAttribute("disabled", this.disabled);
|
|
761
764
|
}
|
|
762
765
|
break;
|
|
763
|
-
case "
|
|
764
|
-
|
|
765
|
-
case "step":
|
|
766
|
-
this[name] = this.input[name] = newValue;
|
|
767
|
-
this.input.setAttribute(name, newValue);
|
|
766
|
+
case "value":
|
|
767
|
+
this.value = newValue;
|
|
768
768
|
if (this.figInputText) {
|
|
769
|
-
this.figInputText
|
|
770
|
-
this.figInputText.setAttribute(name, newValue);
|
|
769
|
+
this.figInputText.setAttribute("value", newValue);
|
|
771
770
|
}
|
|
772
771
|
break;
|
|
772
|
+
case "min":
|
|
773
|
+
case "max":
|
|
774
|
+
case "step":
|
|
773
775
|
case "type":
|
|
774
776
|
case "text":
|
|
775
777
|
case "units":
|
|
776
778
|
this[name] = newValue;
|
|
777
779
|
this.#regenerateInnerHTML();
|
|
778
|
-
this.#setupBindings();
|
|
779
780
|
break;
|
|
780
781
|
default:
|
|
781
782
|
this[name] = this.input[name] = newValue;
|
|
@@ -790,7 +791,7 @@ class FigSlider extends HTMLElement {
|
|
|
790
791
|
this.handleInput();
|
|
791
792
|
}
|
|
792
793
|
}
|
|
793
|
-
calculateNormal(value) {
|
|
794
|
+
#calculateNormal(value) {
|
|
794
795
|
let min = Number(this.input.min);
|
|
795
796
|
let max = Number(this.input.max);
|
|
796
797
|
let val = Number(value);
|
|
@@ -800,8 +801,8 @@ class FigSlider extends HTMLElement {
|
|
|
800
801
|
handleInput() {
|
|
801
802
|
let val = Number(this.input.value);
|
|
802
803
|
this.value = val;
|
|
803
|
-
let complete = this
|
|
804
|
-
let defaultValue = this
|
|
804
|
+
let complete = this.#calculateNormal(val);
|
|
805
|
+
let defaultValue = this.#calculateNormal(this.default);
|
|
805
806
|
this.style.setProperty("--slider-complete", complete);
|
|
806
807
|
this.style.setProperty("--default", defaultValue);
|
|
807
808
|
this.style.setProperty("--unchanged", complete === defaultValue ? 1 : 0);
|
package/package.json
CHANGED