uil 4.2.8 → 4.3.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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <p align="center"><a href="http://lo-th.github.io/uil/"><img src="http://lo-th.github.io/uil/examples/assets/uil.jpg"/></a><br>UIL v4.2.5</p>
1
+ <p align="center"><a href="http://lo-th.github.io/uil/"><img src="http://lo-th.github.io/uil/examples/assets/uil.jpg"/></a><br>UIL v4.3.0</p>
2
2
 
3
3
  uil.js is a lightweight ui for javascript with a complete 3d display support.<br>
4
4
  totally customizable, only 6 events, auto resize<br>
package/build/uil.js CHANGED
@@ -12,7 +12,7 @@
12
12
  /**
13
13
  * @author lth / https://github.com/lo-th
14
14
  */
15
- const REVISION = '4.2.8'; // INTENAL FUNCTION
15
+ const REVISION = '4.3.0'; // INTENAL FUNCTION
16
16
 
17
17
  const R = {
18
18
  ui: [],
@@ -286,7 +286,7 @@
286
286
  // ----------------------
287
287
  // GUI / GROUP FUNCTION
288
288
  // ----------------------
289
- calcUis: (uis, zone, py) => {
289
+ calcUis: (uis, zone, py, group = false) => {
290
290
  //console.log('calc_uis')
291
291
  let i = uis.length,
292
292
  u,
@@ -299,7 +299,7 @@
299
299
  while (i--) {
300
300
  u = uis[n];
301
301
  n++;
302
- if (u.isGroup) u.calcUis();
302
+ if (!group && u.isGroup) u.calcUis();
303
303
  m = u.margin; //div = u.marginDiv
304
304
 
305
305
  u.zone.w = u.w;
@@ -736,7 +736,7 @@
736
736
  if (o.bgOver) color.backgroundOver = o.bgOver;
737
737
 
738
738
  for (let m in color) {
739
- if (o[m]) color[m] = o[m];
739
+ if (o[m] !== undefined) color[m] = o[m];
740
740
  }
741
741
 
742
742
  for (let m in o) {
@@ -752,6 +752,8 @@
752
752
  sy: 2,
753
753
  //2
754
754
  radius: 2,
755
+ showOver: 1,
756
+ //groupOver : 1,
755
757
  content: 'none',
756
758
  background: 'rgba(50,50,50,0.15)',
757
759
  backgroundOver: 'rgba(50,50,50,0.3)',
@@ -779,6 +781,9 @@
779
781
  fontShadow: 'none',
780
782
  //'#000',
781
783
  fontSize: 12,
784
+ joyOver: 'rgba(48,138,255,0.25)',
785
+ joyOut: 'rgba(100,100,100,0.5)',
786
+ joySelect: '#308AFF',
782
787
  hide: 'rgba(0,0,0,0)'
783
788
  },
784
789
  // style css
@@ -1703,6 +1708,15 @@
1703
1708
  }
1704
1709
  }];
1705
1710
  break;
1711
+
1712
+ case 'lut':
1713
+ t = [{
1714
+ description: 'Lut',
1715
+ accept: {
1716
+ 'text/plain': ['.cube', '.3dl']
1717
+ }
1718
+ }];
1719
+ break;
1706
1720
  }
1707
1721
 
1708
1722
  return t;
@@ -1744,18 +1758,18 @@
1744
1758
  let img = new Image();
1745
1759
 
1746
1760
  img.onload = function () {
1747
- if (o.callback) o.callback(img, fname);
1761
+ if (o.callback) o.callback(img, fname, ftype);
1748
1762
  };
1749
1763
 
1750
1764
  img.src = content;
1751
1765
  break;
1752
1766
 
1753
1767
  case 'json':
1754
- if (o.callback) o.callback(JSON.parse(content), fname);
1768
+ if (o.callback) o.callback(JSON.parse(content), fname, ftype);
1755
1769
  break;
1756
1770
 
1757
1771
  default:
1758
- if (o.callback) o.callback(content, fname);
1772
+ if (o.callback) o.callback(content, fname, ftype);
1759
1773
  break;
1760
1774
  }
1761
1775
  };
@@ -1979,6 +1993,7 @@
1979
1993
 
1980
1994
  this.css = this.main ? this.main.css : Tools.css;
1981
1995
  this.colors = Tools.defineColor(o, this.main ? this.group ? this.group.colors : this.main.colors : Tools.colors);
1996
+ this.overEffect = this.colors.showOver;
1982
1997
  this.svgs = Tools.svgs;
1983
1998
  this.zone = {
1984
1999
  x: 0,
@@ -2208,11 +2223,13 @@
2208
2223
 
2209
2224
  uiout() {
2210
2225
  if (this.lock) return;
2226
+ if (!this.overEffect) return;
2211
2227
  if (this.s) this.s[0].background = this.colors.background;
2212
2228
  }
2213
2229
 
2214
2230
  uiover() {
2215
2231
  if (this.lock) return;
2232
+ if (!this.overEffect) return;
2216
2233
  if (this.s) this.s[0].background = this.colors.backgroundOver;
2217
2234
  }
2218
2235
 
@@ -2642,7 +2659,8 @@
2642
2659
  class Button extends Proto {
2643
2660
  constructor(o = {}) {
2644
2661
  super(o);
2645
- this.value = o.value || '';
2662
+ this.value = '';
2663
+ if (o.value !== undefined) this.value = o.value;
2646
2664
  this.values = o.value || this.txt;
2647
2665
  if (o.values) this.values = o.values;
2648
2666
  if (!o.values && !o.value) this.txt = '';
@@ -3852,6 +3870,17 @@
3852
3870
 
3853
3871
  }
3854
3872
 
3873
+ class Empty extends Proto {
3874
+ constructor(o = {}) {
3875
+ o.isSpace = true;
3876
+ o.margin = 0;
3877
+ if (!o.h) o.h = 10;
3878
+ super(o);
3879
+ this.init();
3880
+ }
3881
+
3882
+ }
3883
+
3855
3884
  class Group extends Proto {
3856
3885
  constructor(o = {}) {
3857
3886
  super(o);
@@ -3865,11 +3894,14 @@
3865
3894
  this.decal = o.group ? 8 : 0; //this.dd = o.group ? o.group.decal + 8 : 0
3866
3895
 
3867
3896
  this.baseH = this.h;
3897
+ this.spaceY = new Empty({
3898
+ h: this.margin
3899
+ });
3868
3900
  let fltop = Math.floor(this.h * 0.5) - 3;
3869
3901
  const cc = this.colors;
3870
3902
  this.useFlex = true;
3871
3903
  let flexible = this.useFlex ? 'display:flex; flex-flow: row wrap;' : '';
3872
- this.c[2] = this.dom('div', this.css.basic + flexible + 'width:100%; left:0; height:auto; overflow:hidden; top:' + this.h + 'px');
3904
+ this.c[2] = this.dom('div', this.css.basic + flexible + 'width:100%; left:0; overflow:hidden; top:' + this.h + 'px');
3873
3905
  this.c[3] = this.dom('path', this.css.basic + 'position:absolute; width:6px; height:6px; left:0; top:' + fltop + 'px;', {
3874
3906
  d: this.svgs.g1,
3875
3907
  fill: cc.text,
@@ -4140,9 +4172,10 @@
4140
4172
  }
4141
4173
 
4142
4174
  calcUis() {
4143
- if (!this.isOpen) this.h = this.baseH; //else this.h = Roots.calcUis( this.uis, this.zone, this.zone.y + this.baseH ) + this.baseH;
4144
- else this.h = Roots.calcUis(this.uis, this.zone, this.zone.y + this.baseH + this.margin) + this.baseH;
4175
+ if (!this.isOpen || this.isEmpty) this.h = this.baseH; //else this.h = Roots.calcUis( this.uis, this.zone, this.zone.y + this.baseH ) + this.baseH;
4176
+ else this.h = Roots.calcUis([...this.uis, this.spaceY], this.zone, this.zone.y + this.baseH + this.margin, true) + this.baseH;
4145
4177
  this.s[0].height = this.h + 'px';
4178
+ this.s[2].height = this.h - this.baseH + 'px';
4146
4179
  }
4147
4180
 
4148
4181
  parentHeight(t) {
@@ -4153,6 +4186,7 @@
4153
4186
  if (!this.isOpen) return;
4154
4187
  if (this.isUI) this.main.calc();else this.calcUis();
4155
4188
  this.s[0].height = this.h + 'px';
4189
+ this.s[2].height = this.h + 'px';
4156
4190
  }
4157
4191
 
4158
4192
  rSizeContent() {
@@ -4176,17 +4210,25 @@
4176
4210
  if (this.isOpen) this.rSizeContent();
4177
4211
  } //
4178
4212
 
4213
+ /*
4214
+ uiout() {
4215
+
4216
+ if( this.lock ) return;
4217
+ if(!this.overEffect) return;
4218
+ if(this.s) this.s[0].background = this.colors.background;
4219
+
4220
+ }
4221
+
4222
+ uiover() {
4223
+
4224
+ if( this.lock ) return;
4225
+ if(!this.overEffect) return;
4226
+ //if( this.isOpen ) return;
4227
+ if(this.s) this.s[0].background = this.colors.backgroundOver;
4228
+
4229
+ }
4230
+ */
4179
4231
 
4180
- uiout() {
4181
- if (this.lock) return;
4182
- if (this.s) this.s[0].background = this.colors.background;
4183
- }
4184
-
4185
- uiover() {
4186
- if (this.lock) return; //if( this.isOpen ) return;
4187
-
4188
- if (this.s) this.s[0].background = this.colors.backgroundOver;
4189
- }
4190
4232
 
4191
4233
  }
4192
4234
 
@@ -4204,11 +4246,12 @@
4204
4246
  this.pos = new V2();
4205
4247
  this.tmp = new V2();
4206
4248
  this.interval = null;
4207
- this.c[0].style.display = 'block'; //this.radius = this.w * 0.5;
4249
+ this.c[0].style.display = 'block';
4250
+ this.haveText = o.text !== undefined ? o.text : true; //this.radius = this.w * 0.5;
4208
4251
  //this.distance = this.radius*0.25;
4209
4252
 
4210
4253
  this.distance = this.diam * 0.5 * 0.25;
4211
- this.h = o.h || this.w + 10;
4254
+ this.h = o.h || this.w + (this.haveText ? 10 : 0);
4212
4255
  this.c[0].style.width = this.w + 'px';
4213
4256
 
4214
4257
  if (this.c[1] !== undefined) {
@@ -4221,7 +4264,7 @@
4221
4264
 
4222
4265
  let cc = this.colors;
4223
4266
  this.c[2] = this.dom('div', this.css.txt + 'justify-content:center; top:' + (this.h - 20) + 'px; width:100%; color:' + cc.text);
4224
- this.c[2].textContent = this.value;
4267
+ this.c[2].textContent = this.haveText ? this.value : '';
4225
4268
  this.c[3] = this.getJoystick(this.model);
4226
4269
  this.setSvg(this.c[3], 'viewBox', '0 0 ' + this.diam + ' ' + this.diam);
4227
4270
  this.setCss(this.c[3], {
@@ -4230,6 +4273,7 @@
4230
4273
  left: 0,
4231
4274
  top: this.top
4232
4275
  });
4276
+ this.mode(0);
4233
4277
  this.ratio = 128 / this.w;
4234
4278
  this.init();
4235
4279
  this.update(false);
@@ -4245,9 +4289,9 @@
4245
4289
  this.setSvg(this.c[3], 'fill', 'url(#gradIn)', 4);
4246
4290
  this.setSvg(this.c[3], 'stroke', '#000', 4);
4247
4291
  } else {
4248
- this.setSvg(this.c[3], 'stroke', 'rgba(100,100,100,0.25)', 2); //this.setSvg( this.c[3], 'stroke', 'rgb(0,0,0,0.1)', 3 );
4292
+ this.setSvg(this.c[3], 'stroke', cc.joyOut, 2); //this.setSvg( this.c[3], 'stroke', 'rgb(0,0,0,0.1)', 3 );
4249
4293
 
4250
- this.setSvg(this.c[3], 'stroke', '#666', 4);
4294
+ this.setSvg(this.c[3], 'stroke', cc.joyOut, 4);
4251
4295
  this.setSvg(this.c[3], 'fill', 'none', 4);
4252
4296
  }
4253
4297
 
@@ -4259,10 +4303,10 @@
4259
4303
  this.setSvg(this.c[3], 'fill', 'url(#gradIn2)', 4);
4260
4304
  this.setSvg(this.c[3], 'stroke', 'rgba(0,0,0,0)', 4);
4261
4305
  } else {
4262
- this.setSvg(this.c[3], 'stroke', 'rgba(48,138,255,0.25)', 2); //this.setSvg( this.c[3], 'stroke', 'rgb(0,0,0,0.3)', 3 );
4306
+ this.setSvg(this.c[3], 'stroke', cc.joyOver, 2); //this.setSvg( this.c[3], 'stroke', 'rgb(0,0,0,0.3)', 3 );
4263
4307
 
4264
- this.setSvg(this.c[3], 'stroke', cc.select, 4);
4265
- this.setSvg(this.c[3], 'fill', 'rgba(48,138,255,0.25)', 4);
4308
+ this.setSvg(this.c[3], 'stroke', cc.joySelect, 4);
4309
+ this.setSvg(this.c[3], 'fill', cc.joyOver, 4);
4266
4310
  }
4267
4311
 
4268
4312
  break;
@@ -4364,7 +4408,7 @@
4364
4408
  this.setSvg(this.c[3], 'cy', y * this.ratio, 4);
4365
4409
  this.value[0] = (this.pos.x * this.multiplicator).toFixed(this.precision) * 1;
4366
4410
  this.value[1] = (this.pos.y * this.multiplicator).toFixed(this.precision) * 1;
4367
- this.c[2].textContent = this.value;
4411
+ if (this.haveText) this.c[2].textContent = this.value;
4368
4412
  }
4369
4413
 
4370
4414
  clear() {
@@ -4594,7 +4638,9 @@
4594
4638
 
4595
4639
  class List extends Proto {
4596
4640
  constructor(o = {}) {
4597
- super(o); // images
4641
+ super(o); // TODO not work
4642
+
4643
+ this.hideCurrent = false; // images
4598
4644
 
4599
4645
  this.path = o.path || '';
4600
4646
  this.format = o.format || '';
@@ -4642,6 +4688,7 @@
4642
4688
 
4643
4689
  this.items = [];
4644
4690
  this.prevName = '';
4691
+ this.tmpId = 0;
4645
4692
  this.baseH = this.h;
4646
4693
  this.itemHeight = o.itemHeight || this.h; //(this.h-3);
4647
4694
  // force full list
@@ -4698,10 +4745,11 @@
4698
4745
  this.dragout = o.dragout || false;
4699
4746
  this.dragstart = o.dragstart || null;
4700
4747
  this.dragend = o.dragend || null; //this.c[0].style.background = '#FF0000'
4748
+ ///if( this.isWithImage ) this.preloadImage();
4701
4749
 
4702
- if (this.isWithImage) this.preloadImage();
4703
4750
  this.setList(this.list);
4704
4751
  this.init();
4752
+ if (this.isWithImage) this.preloadImage();
4705
4753
  if (this.isOpenOnStart) this.open(true);
4706
4754
  this.baseH += this.mtop;
4707
4755
  } // image list
@@ -4717,6 +4765,7 @@
4717
4765
  }
4718
4766
 
4719
4767
  nextImg() {
4768
+ if (this.c === null) return;
4720
4769
  this.tmpUrl.shift();
4721
4770
 
4722
4771
  if (this.tmpUrl.length === 0) {
@@ -4766,13 +4815,19 @@
4766
4815
 
4767
4816
  testItems(y) {
4768
4817
  let name = '';
4769
- let i = this.items.length,
4818
+ let items = this.items;
4819
+ /*if(this.hideCurrent){
4820
+ //items = [...this.items]
4821
+ items = this.items.slice(this.tmpId)
4822
+ }*/
4823
+
4824
+ let i = items.length,
4770
4825
  item,
4771
4826
  a,
4772
4827
  b;
4773
4828
 
4774
4829
  while (i--) {
4775
- item = this.items[i];
4830
+ item = items[i];
4776
4831
  a = item.posy + this.topList;
4777
4832
  b = item.posy + this.itemHeight + 1 + this.topList;
4778
4833
 
@@ -4835,6 +4890,33 @@
4835
4890
  this.items[i].style.background = this.colors.back;
4836
4891
  this.items[i].style.color = this.colors.text;
4837
4892
  }
4893
+ }
4894
+
4895
+ hideActive() {
4896
+ if (!this.hideCurrent) return; //if( !this.current ) return
4897
+
4898
+ if (this.current) this.tmpId = this.current.id;
4899
+ this.resetHide(); //this.items[this.tmpId].style.height = 0+'px'
4900
+ }
4901
+
4902
+ resetHide() {
4903
+ console.log(this.tmpId);
4904
+ let i = this.items.length;
4905
+
4906
+ while (i--) {
4907
+ if (i === this.tmpId) {
4908
+ this.items[i].style.height = 0 + 'px';
4909
+ this.items[i].posy = -1;
4910
+ } else {
4911
+ this.items[i].style.height = this.itemHeight + 'px';
4912
+ this.items[i].posy = (this.itemHeight + 1) * (i - 1);
4913
+ } //this.items[i].style.display = 'flex'
4914
+
4915
+ /*this.items[i].select = false
4916
+ this.items[i].style.background = this.colors.back;
4917
+ this.items[i].style.color = this.colors.text;*/
4918
+
4919
+ }
4838
4920
  } // ----------------------
4839
4921
  // EVENTS
4840
4922
  // ----------------------
@@ -4855,19 +4937,21 @@
4855
4937
  this.modeTitle(2);
4856
4938
 
4857
4939
  if (!this.listOnly) {
4940
+ this.hideActive();
4858
4941
  if (!this.isOpen) this.open();else this.close();
4859
4942
  }
4860
4943
  } else {
4861
4944
  // is item
4862
4945
  if (this.current) {
4863
- this.value = this.list[this.current.id];
4946
+ this.value = this.list[this.current.id]; //this.tmpId = this.current.id
4947
+
4864
4948
  if (this.isSelectable) this.selected(); //this.send( this.refObject !== null ? this.refObject[ this.list[this.current.id]] : this.value );
4865
4949
 
4866
4950
  this.send(this.value);
4867
4951
 
4868
4952
  if (!this.listOnly) {
4869
4953
  this.close();
4870
- this.setTopItem();
4954
+ this.setTopItem(); //this.hideActive()
4871
4955
  }
4872
4956
  }
4873
4957
  }
@@ -4986,10 +5070,11 @@
4986
5070
  this.clearList();
4987
5071
  this.list = list;
4988
5072
  this.length = this.list.length;
4989
- this.maxItem = this.full ? this.length : 5;
4990
- this.maxItem = this.length < this.maxItem ? this.length : this.maxItem;
5073
+ let lng = this.hideCurrent ? this.length - 1 : this.length;
5074
+ this.maxItem = this.full ? lng : 5;
5075
+ this.maxItem = lng < this.maxItem ? lng : this.maxItem;
4991
5076
  this.maxHeight = this.maxItem * (this.itemHeight + 1) + 2;
4992
- this.max = this.length * (this.itemHeight + 1) + 2;
5077
+ this.max = lng * (this.itemHeight + 1) + 2;
4993
5078
  this.ratio = this.maxHeight / this.max;
4994
5079
  this.sh = this.maxHeight * this.ratio;
4995
5080
  this.range = this.maxHeight - this.sh;
@@ -5091,7 +5176,8 @@
5091
5176
  }
5092
5177
 
5093
5178
  setValue(value) {
5094
- if (!isNaN(value)) this.value = this.list[value];else this.value = value;
5179
+ if (!isNaN(value)) this.value = this.list[value];else this.value = value; //this.tmpId = value
5180
+
5095
5181
  this.setTopItem();
5096
5182
  }
5097
5183
 
@@ -6197,17 +6283,6 @@
6197
6283
 
6198
6284
  }
6199
6285
 
6200
- class Empty extends Proto {
6201
- constructor(o = {}) {
6202
- o.isSpace = true;
6203
- o.margin = 0;
6204
- if (!o.h) o.h = 10;
6205
- super(o);
6206
- this.init();
6207
- }
6208
-
6209
- }
6210
-
6211
6286
  class Item extends Proto {
6212
6287
  constructor(o = {}) {
6213
6288
  super(o);
@@ -6925,7 +7000,8 @@
6925
7000
  this.plane = o.plane || null; // color
6926
7001
 
6927
7002
  if (o.config) o.colors = o.config;
6928
- if (o.colors) this.setConfig(o.colors);else this.colors = Tools.defineColor(o); // style
7003
+ if (o.colors) this.setConfig(o.colors);else this.colors = Tools.defineColor(o); //this.cleanning = false
7004
+ // style
6929
7005
 
6930
7006
  this.css = Tools.cloneCss();
6931
7007
  this.isReset = true;
@@ -7022,7 +7098,7 @@
7022
7098
  } // height transition
7023
7099
 
7024
7100
 
7025
- this.transition = o.transition || Tools.transition;
7101
+ this.transition = o.transition !== undefined ? o.transition : Tools.transition;
7026
7102
  if (this.transition) setTimeout(this.addTransition.bind(this), 1000);
7027
7103
  this.setWidth();
7028
7104
  if (this.isCanvas) this.makeCanvas();
@@ -7187,6 +7263,7 @@
7187
7263
 
7188
7264
 
7189
7265
  handleEvent(e) {
7266
+ //if( this.cleanning ) return
7190
7267
  let type = e.type;
7191
7268
  let change = false;
7192
7269
  let protoChange = false;
@@ -7286,6 +7363,7 @@
7286
7363
 
7287
7364
 
7288
7365
  add() {
7366
+ //if(this.cleanning) this.cleanning = false
7289
7367
  let a = arguments;
7290
7368
  let ontop = false;
7291
7369
 
@@ -7332,6 +7410,7 @@
7332
7410
 
7333
7411
 
7334
7412
  empty() {
7413
+ //this.cleanning = true
7335
7414
  //this.close();
7336
7415
  let i = this.uis.length,
7337
7416
  item;
@@ -7351,6 +7430,10 @@
7351
7430
  this.empty();
7352
7431
  }
7353
7432
 
7433
+ clear2() {
7434
+ setTimeout(this.empty.bind(this), 0);
7435
+ }
7436
+
7354
7437
  dispose() {
7355
7438
  this.clear();
7356
7439
  if (this.parent !== null) this.parent.removeChild(this.content);