@jamesrock/rockjs 1.37.0 → 1.39.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.
Files changed (2) hide show
  1. package/index.js +39 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -959,7 +959,7 @@ export class Tempo {
959
959
  this.taps.push(now);
960
960
 
961
961
  if(this.taps.length > 1 && now - this.taps[this.taps.length - 2] > 2000) {
962
- taps = [now];
962
+ this.taps = [now];
963
963
  return base;
964
964
  };
965
965
 
@@ -978,6 +978,44 @@ export class Tempo {
978
978
  };
979
979
  };
980
980
 
981
+ export class Toggle extends DisplayObject {
982
+ constructor(items, name = '{name}', initialValue, className) {
983
+
984
+ super();
985
+
986
+ this.node = makeNode('form', className);
987
+ this.name = name;
988
+ this.initialValue = initialValue;
989
+ this.toggle = makeToggle(items, name, initialValue);
990
+
991
+ append(this.node)(this.toggle);
992
+
993
+ };
994
+ getValue() {
995
+
996
+ const data = new FormData(this.node);
997
+ return data.get(this.name);
998
+
999
+ };
1000
+ getValueAsNumber() {
1001
+
1002
+ return Number(this.getValue());
1003
+
1004
+ };
1005
+ updateItemLabel(value, label) {
1006
+
1007
+ this.toggle.querySelector(`label[for="${this.name}-${value}"]`).innerText = label;
1008
+ return this;
1009
+
1010
+ };
1011
+ scrollIntoView() {
1012
+
1013
+ this.toggle.querySelector(`input[value="${this.initialValue}"]`).scrollIntoView({block: 'center'});
1014
+ return this;
1015
+
1016
+ };
1017
+ };
1018
+
981
1019
  // temporary alias
982
1020
  export const createNode = makeNode;
983
1021
  export const createSVGNode = makeSVGNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamesrock/rockjs",
3
- "version": "1.37.0",
3
+ "version": "1.39.0",
4
4
  "description": "utility bliss",
5
5
  "license": "ISC",
6
6
  "author": "James Rock",