uil 4.2.9 → 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)',
@@ -1991,6 +1993,7 @@
1991
1993
 
1992
1994
  this.css = this.main ? this.main.css : Tools.css;
1993
1995
  this.colors = Tools.defineColor(o, this.main ? this.group ? this.group.colors : this.main.colors : Tools.colors);
1996
+ this.overEffect = this.colors.showOver;
1994
1997
  this.svgs = Tools.svgs;
1995
1998
  this.zone = {
1996
1999
  x: 0,
@@ -2220,11 +2223,13 @@
2220
2223
 
2221
2224
  uiout() {
2222
2225
  if (this.lock) return;
2226
+ if (!this.overEffect) return;
2223
2227
  if (this.s) this.s[0].background = this.colors.background;
2224
2228
  }
2225
2229
 
2226
2230
  uiover() {
2227
2231
  if (this.lock) return;
2232
+ if (!this.overEffect) return;
2228
2233
  if (this.s) this.s[0].background = this.colors.backgroundOver;
2229
2234
  }
2230
2235
 
@@ -2654,7 +2659,8 @@
2654
2659
  class Button extends Proto {
2655
2660
  constructor(o = {}) {
2656
2661
  super(o);
2657
- this.value = o.value || '';
2662
+ this.value = '';
2663
+ if (o.value !== undefined) this.value = o.value;
2658
2664
  this.values = o.value || this.txt;
2659
2665
  if (o.values) this.values = o.values;
2660
2666
  if (!o.values && !o.value) this.txt = '';
@@ -3864,6 +3870,17 @@
3864
3870
 
3865
3871
  }
3866
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
+
3867
3884
  class Group extends Proto {
3868
3885
  constructor(o = {}) {
3869
3886
  super(o);
@@ -3877,11 +3894,14 @@
3877
3894
  this.decal = o.group ? 8 : 0; //this.dd = o.group ? o.group.decal + 8 : 0
3878
3895
 
3879
3896
  this.baseH = this.h;
3897
+ this.spaceY = new Empty({
3898
+ h: this.margin
3899
+ });
3880
3900
  let fltop = Math.floor(this.h * 0.5) - 3;
3881
3901
  const cc = this.colors;
3882
3902
  this.useFlex = true;
3883
3903
  let flexible = this.useFlex ? 'display:flex; flex-flow: row wrap;' : '';
3884
- 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');
3885
3905
  this.c[3] = this.dom('path', this.css.basic + 'position:absolute; width:6px; height:6px; left:0; top:' + fltop + 'px;', {
3886
3906
  d: this.svgs.g1,
3887
3907
  fill: cc.text,
@@ -4152,9 +4172,10 @@
4152
4172
  }
4153
4173
 
4154
4174
  calcUis() {
4155
- if (!this.isOpen) this.h = this.baseH; //else this.h = Roots.calcUis( this.uis, this.zone, this.zone.y + this.baseH ) + this.baseH;
4156
- 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;
4157
4177
  this.s[0].height = this.h + 'px';
4178
+ this.s[2].height = this.h - this.baseH + 'px';
4158
4179
  }
4159
4180
 
4160
4181
  parentHeight(t) {
@@ -4165,6 +4186,7 @@
4165
4186
  if (!this.isOpen) return;
4166
4187
  if (this.isUI) this.main.calc();else this.calcUis();
4167
4188
  this.s[0].height = this.h + 'px';
4189
+ this.s[2].height = this.h + 'px';
4168
4190
  }
4169
4191
 
4170
4192
  rSizeContent() {
@@ -4188,17 +4210,25 @@
4188
4210
  if (this.isOpen) this.rSizeContent();
4189
4211
  } //
4190
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
+ */
4191
4231
 
4192
- uiout() {
4193
- if (this.lock) return;
4194
- if (this.s) this.s[0].background = this.colors.background;
4195
- }
4196
-
4197
- uiover() {
4198
- if (this.lock) return; //if( this.isOpen ) return;
4199
-
4200
- if (this.s) this.s[0].background = this.colors.backgroundOver;
4201
- }
4202
4232
 
4203
4233
  }
4204
4234
 
@@ -4608,7 +4638,9 @@
4608
4638
 
4609
4639
  class List extends Proto {
4610
4640
  constructor(o = {}) {
4611
- super(o); // images
4641
+ super(o); // TODO not work
4642
+
4643
+ this.hideCurrent = false; // images
4612
4644
 
4613
4645
  this.path = o.path || '';
4614
4646
  this.format = o.format || '';
@@ -4656,6 +4688,7 @@
4656
4688
 
4657
4689
  this.items = [];
4658
4690
  this.prevName = '';
4691
+ this.tmpId = 0;
4659
4692
  this.baseH = this.h;
4660
4693
  this.itemHeight = o.itemHeight || this.h; //(this.h-3);
4661
4694
  // force full list
@@ -4712,10 +4745,11 @@
4712
4745
  this.dragout = o.dragout || false;
4713
4746
  this.dragstart = o.dragstart || null;
4714
4747
  this.dragend = o.dragend || null; //this.c[0].style.background = '#FF0000'
4748
+ ///if( this.isWithImage ) this.preloadImage();
4715
4749
 
4716
- if (this.isWithImage) this.preloadImage();
4717
4750
  this.setList(this.list);
4718
4751
  this.init();
4752
+ if (this.isWithImage) this.preloadImage();
4719
4753
  if (this.isOpenOnStart) this.open(true);
4720
4754
  this.baseH += this.mtop;
4721
4755
  } // image list
@@ -4731,6 +4765,7 @@
4731
4765
  }
4732
4766
 
4733
4767
  nextImg() {
4768
+ if (this.c === null) return;
4734
4769
  this.tmpUrl.shift();
4735
4770
 
4736
4771
  if (this.tmpUrl.length === 0) {
@@ -4780,13 +4815,19 @@
4780
4815
 
4781
4816
  testItems(y) {
4782
4817
  let name = '';
4783
- 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,
4784
4825
  item,
4785
4826
  a,
4786
4827
  b;
4787
4828
 
4788
4829
  while (i--) {
4789
- item = this.items[i];
4830
+ item = items[i];
4790
4831
  a = item.posy + this.topList;
4791
4832
  b = item.posy + this.itemHeight + 1 + this.topList;
4792
4833
 
@@ -4849,6 +4890,33 @@
4849
4890
  this.items[i].style.background = this.colors.back;
4850
4891
  this.items[i].style.color = this.colors.text;
4851
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
+ }
4852
4920
  } // ----------------------
4853
4921
  // EVENTS
4854
4922
  // ----------------------
@@ -4869,19 +4937,21 @@
4869
4937
  this.modeTitle(2);
4870
4938
 
4871
4939
  if (!this.listOnly) {
4940
+ this.hideActive();
4872
4941
  if (!this.isOpen) this.open();else this.close();
4873
4942
  }
4874
4943
  } else {
4875
4944
  // is item
4876
4945
  if (this.current) {
4877
- this.value = this.list[this.current.id];
4946
+ this.value = this.list[this.current.id]; //this.tmpId = this.current.id
4947
+
4878
4948
  if (this.isSelectable) this.selected(); //this.send( this.refObject !== null ? this.refObject[ this.list[this.current.id]] : this.value );
4879
4949
 
4880
4950
  this.send(this.value);
4881
4951
 
4882
4952
  if (!this.listOnly) {
4883
4953
  this.close();
4884
- this.setTopItem();
4954
+ this.setTopItem(); //this.hideActive()
4885
4955
  }
4886
4956
  }
4887
4957
  }
@@ -5000,10 +5070,11 @@
5000
5070
  this.clearList();
5001
5071
  this.list = list;
5002
5072
  this.length = this.list.length;
5003
- this.maxItem = this.full ? this.length : 5;
5004
- 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;
5005
5076
  this.maxHeight = this.maxItem * (this.itemHeight + 1) + 2;
5006
- this.max = this.length * (this.itemHeight + 1) + 2;
5077
+ this.max = lng * (this.itemHeight + 1) + 2;
5007
5078
  this.ratio = this.maxHeight / this.max;
5008
5079
  this.sh = this.maxHeight * this.ratio;
5009
5080
  this.range = this.maxHeight - this.sh;
@@ -5105,7 +5176,8 @@
5105
5176
  }
5106
5177
 
5107
5178
  setValue(value) {
5108
- 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
+
5109
5181
  this.setTopItem();
5110
5182
  }
5111
5183
 
@@ -6211,17 +6283,6 @@
6211
6283
 
6212
6284
  }
6213
6285
 
6214
- class Empty extends Proto {
6215
- constructor(o = {}) {
6216
- o.isSpace = true;
6217
- o.margin = 0;
6218
- if (!o.h) o.h = 10;
6219
- super(o);
6220
- this.init();
6221
- }
6222
-
6223
- }
6224
-
6225
6286
  class Item extends Proto {
6226
6287
  constructor(o = {}) {
6227
6288
  super(o);
@@ -6939,7 +7000,8 @@
6939
7000
  this.plane = o.plane || null; // color
6940
7001
 
6941
7002
  if (o.config) o.colors = o.config;
6942
- 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
6943
7005
 
6944
7006
  this.css = Tools.cloneCss();
6945
7007
  this.isReset = true;
@@ -7036,7 +7098,7 @@
7036
7098
  } // height transition
7037
7099
 
7038
7100
 
7039
- this.transition = o.transition || Tools.transition;
7101
+ this.transition = o.transition !== undefined ? o.transition : Tools.transition;
7040
7102
  if (this.transition) setTimeout(this.addTransition.bind(this), 1000);
7041
7103
  this.setWidth();
7042
7104
  if (this.isCanvas) this.makeCanvas();
@@ -7201,6 +7263,7 @@
7201
7263
 
7202
7264
 
7203
7265
  handleEvent(e) {
7266
+ //if( this.cleanning ) return
7204
7267
  let type = e.type;
7205
7268
  let change = false;
7206
7269
  let protoChange = false;
@@ -7300,6 +7363,7 @@
7300
7363
 
7301
7364
 
7302
7365
  add() {
7366
+ //if(this.cleanning) this.cleanning = false
7303
7367
  let a = arguments;
7304
7368
  let ontop = false;
7305
7369
 
@@ -7346,6 +7410,7 @@
7346
7410
 
7347
7411
 
7348
7412
  empty() {
7413
+ //this.cleanning = true
7349
7414
  //this.close();
7350
7415
  let i = this.uis.length,
7351
7416
  item;
@@ -7365,6 +7430,10 @@
7365
7430
  this.empty();
7366
7431
  }
7367
7432
 
7433
+ clear2() {
7434
+ setTimeout(this.empty.bind(this), 0);
7435
+ }
7436
+
7368
7437
  dispose() {
7369
7438
  this.clear();
7370
7439
  if (this.parent !== null) this.parent.removeChild(this.content);