uil 1.0.1 → 4.0.3

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/package.json CHANGED
@@ -1,54 +1,52 @@
1
- {
2
- "name": "uil",
3
- "version": "1.0.1",
4
- "description": "JavaScript 3D library",
5
- "main": "build/uil.js",
6
- "repository": "lo-th/uil",
7
- "jsnext:main": "build/uil.module.js",
8
- "module": "build/uil.module.js",
9
- "files": [
10
- "package.json",
11
- "LICENSE",
12
- "README.md",
13
- "build/uil.js",
14
- "build/uil.min.js",
15
- "build/uil.module.js",
16
- "src",
17
- "examples/js",
18
- "examples/fonts"
19
- ],
20
- "directories": {
21
- "doc": "docs",
22
- "example": "examples",
23
- "test": "test"
24
- },
25
- "eslintConfig": {
26
- "extends": "mdcs"
27
- },
28
- "scripts": {
29
- "build": "rollup -c",
30
- "build-uglify": "rollup -c && uglifyjs build/uil.js -cm --preamble \"// lo-th.github.io/uil/license\" > build/uil.min.js",
31
- "build-closure": "rollup -c && java -jar utils/build/compiler/closure-compiler-v20160713.jar --warning_level=VERBOSE --jscomp_off=globalThis --jscomp_off=checkTypes --externs utils/build/externs.js --language_in=ECMASCRIPT5_STRICT --js build/uil.js --js_output_file build/uil.min.js",
32
- "dev": "rollup -c -w",
33
- "lint": "eslint src",
34
- "test": "echo \"Error: no test specified\" && exit 1"
35
- },
36
- "keywords": [
37
- "uil",
38
- "uil.js",
39
- "ui"
40
- ],
41
- "author": "lo-th",
42
- "license": "MIT",
43
- "bugs": {
44
- "url": "https://github.com/lo-th/uil/issues"
45
- },
46
- "homepage": "http://lo-th.github.io/uil/",
47
- "devDependencies": {
48
- "eslint": "latest",
49
- "eslint-config-mdcs": "latest",
50
- "rollup": "latest",
51
- "rollup-watch": "latest",
52
- "uglify-js": "latest"
53
- }
54
- }
1
+ {
2
+ "name": "uil",
3
+ "version": "4.0.3",
4
+ "description": "JavaScript gui library",
5
+ "main": "build/uil.js",
6
+ "repository": "lo-th/uil",
7
+ "jsnext:main": "build/uil.module.js",
8
+ "module": "build/uil.module.js",
9
+ "files": [
10
+ "package.json",
11
+ "LICENSE",
12
+ "README.md",
13
+ "build/uil.js",
14
+ "build/uil.min.js",
15
+ "build/uil.module.js"
16
+ ],
17
+ "directories": {
18
+ "doc": "docs",
19
+ "example": "examples"
20
+ },
21
+ "eslintConfig": {
22
+ "extends": "mdcs"
23
+ },
24
+ "scripts": {
25
+ "build": "rollup -c utils/rollup.config.js",
26
+ "dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/rollup.config.js -w -m inline\" \"servez -p 8111 --index\"",
27
+ "start": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/rollup.config.js -w -m inline\" \"http-server -c-1 -p 8111 -o index.html\""
28
+ },
29
+ "keywords": [
30
+ "uil",
31
+ "uil.js",
32
+ "ui"
33
+ ],
34
+ "author": "lo-th",
35
+ "license": "MIT",
36
+ "bugs": {
37
+ "url": "https://github.com/lo-th/uil/issues"
38
+ },
39
+ "homepage": "http://lo-th.github.io/uil/",
40
+ "devDependencies": {
41
+ "@babel/core": "^7.12.16",
42
+ "@babel/plugin-proposal-class-properties": "^7.12.13",
43
+ "@babel/preset-env": "^7.12.16",
44
+ "@rollup/plugin-babel": "^5.3.0",
45
+ "@rollup/plugin-node-resolve": "^11.2.0",
46
+ "concurrently": "^5.3.0",
47
+ "regenerator-runtime": "^0.13.7",
48
+ "rollup": "^2.39.0",
49
+ "rollup-plugin-terser": "^7.0.2",
50
+ "servez": "^1.11.0"
51
+ }
52
+ }
package/src/Uil.js DELETED
@@ -1,21 +0,0 @@
1
- import './polyfills.js';
2
-
3
- export { Tools } from './core/Tools.js';
4
- export { Gui } from './core/Gui.js';
5
- export { Proto } from './core/Proto.js';
6
- //export { add } from './core/add.js';
7
- export * from './core/add.js';
8
- //
9
- export { Bool } from './proto/Bool.js';
10
- export { Button } from './proto/Button.js';
11
- export { Circular } from './proto/Circular.js';
12
- export { Color } from './proto/Color.js';
13
- export { Fps } from './proto/Fps.js';
14
- export { Group } from './proto/Group.js';
15
- export { Joystick } from './proto/Joystick.js';
16
- export { Knob } from './proto/Knob.js';
17
- export { List } from './proto/List.js';
18
- export { Numeric } from './proto/Numeric.js';
19
- export { Slide } from './proto/Slide.js';
20
- export { TextInput } from './proto/TextInput.js';
21
- export { Title } from './proto/Title.js';
package/src/core/Gui.js DELETED
@@ -1,505 +0,0 @@
1
-
2
- import { Tools } from './Tools';
3
- import { add } from './add';
4
-
5
- /**
6
- * @author lo-th / https://github.com/lo-th
7
- */
8
-
9
- function Gui ( o ) {
10
-
11
- o = o || {};
12
-
13
- // css plus
14
- this.css = o.css !== undefined ? o.css : '';
15
-
16
- // size define
17
- this.size = Tools.size;
18
- if( o.p !== undefined ) this.size.p = o.p;
19
- if( o.w !== undefined ) this.size.w = o.w;
20
- if( o.h !== undefined ) this.size.h = o.h;
21
- if( o.s !== undefined ) this.size.s = o.s;
22
-
23
- this.size.h = this.size.h < 11 ? 11 : this.size.h;
24
-
25
- this.width = this.size.w;
26
-
27
- // bottom height
28
- this.bh = this.size.h;
29
-
30
-
31
-
32
-
33
- //this.width = o.width !== undefined ? o.width : Tools.size.width;
34
- //this.width = o.size !== undefined ? o.size : this.width;
35
-
36
-
37
- // tmp variable
38
- this.height = 0;
39
- this.left = 0;
40
- this.h = 0;
41
- this.prevY = -1;
42
- this.sw = 0;
43
-
44
-
45
- // color
46
- this.colors = Tools.colors;
47
- this.bg = o.bg || Tools.colors.background;
48
-
49
- // bottom and close height
50
- this.isWithClose = true;
51
-
52
-
53
- //this.baseH = Tools.size.height;
54
-
55
- if(o.close !== undefined ){
56
- this.isWithClose = o.close;
57
- this.bh = !this.isWithClose ? 0 : this.bh;
58
- }
59
-
60
-
61
-
62
-
63
-
64
- Tools.main = this;
65
-
66
- this.callback = o.callback === undefined ? null : o.callback;
67
-
68
-
69
-
70
- this.isCenter = o.center || false;
71
- this.lockwheel = false;
72
- this.onWheel = false;
73
- this.isOpen = true;
74
-
75
- this.uis = [];
76
-
77
- this.content = Tools.dom( 'div', Tools.css.basic + 'display:block; width:'+this.width+'px; height:auto; top:0; right:10px; transition:height 0.1s ease-out;' + this.css );
78
- if( o.parent !== undefined ) o.parent.appendChild( this.content );
79
- else document.body.appendChild( this.content );
80
-
81
- this.innerContent = Tools.dom( 'div', Tools.css.basic + 'width:100%; top:0; left:0; height:auto; overflow:hidden;');
82
- this.content.appendChild( this.innerContent );
83
-
84
- this.inner = Tools.dom( 'div', Tools.css.basic + 'width:100%; top:0; left:0; height:auto;');
85
- this.innerContent.appendChild(this.inner);
86
- this.inner.name = 'inner';
87
-
88
- // scroll background
89
- this.scrollBG = Tools.dom( 'div', Tools.css.basic + 'right:0; top:0; width:'+this.size.s+'px; height:10px; cursor:s-resize; pointer-events:auto; display:none; background:'+this.bg+'; border-left:1px solid '+this.colors.stroke+';');
90
- this.content.appendChild( this.scrollBG );
91
- this.scrollBG.name = 'scroll';
92
-
93
- // scroll
94
- this.scroll = Tools.dom( 'div', Tools.css.basic + 'background:'+this.colors.scroll+'; right:0px; top:0; width:'+this.size.s+'px; height:10px;');
95
- this.scrollBG.appendChild( this.scroll );
96
-
97
- this.bottom = Tools.dom( 'div', Tools.css.txt + 'width:100%; top:auto; bottom:0; left:0; border-bottom-right-radius:10px; border-bottom-left-radius:10px; text-align:center; pointer-events:auto; cursor:pointer; height:'+this.bh+'px; line-height:'+(this.bh-5)+'px; border-top:1px solid '+Tools.colors.stroke+';');
98
- this.content.appendChild(this.bottom);
99
- this.bottom.textContent = 'close';
100
- this.bottom.name = 'bottom';
101
- this.bottom.style.background = this.bg;
102
-
103
- this.isDown = false;
104
- this.isScroll = false;
105
-
106
- this.callbackClose = function(){};
107
-
108
- this.content.addEventListener( 'mousedown', this, false );
109
- this.content.addEventListener( 'mousemove', this, false );
110
- this.content.addEventListener( 'mouseout', this, false );
111
- this.content.addEventListener( 'mouseup', this, false );
112
- this.content.addEventListener( 'mouseover', this, false );
113
-
114
- //console.log(this.content.getBoundingClientRect().top);
115
-
116
- this.top = o.top || this.content.getBoundingClientRect().top;
117
- //this.content.addEventListener( 'mousewheel', this, false );
118
-
119
- document.addEventListener( 'mousewheel', function(e){this.wheel(e)}.bind(this), false );
120
- window.addEventListener("resize", function(e){this.resize(e)}.bind(this), false );
121
-
122
- //
123
-
124
- this.setWidth( this.width );
125
-
126
- }
127
-
128
- Gui.prototype = {
129
-
130
- constructor: Gui,
131
-
132
- hide : function (b) {
133
-
134
- if(b) this.content.style.display = 'none';
135
- else this.content.style.display = 'block';
136
-
137
- },
138
-
139
- setBG : function(c){
140
-
141
- this.bg = c;
142
-
143
- var i = this.uis.length;
144
- while(i--){
145
- this.uis[i].setBG(c);
146
- }
147
-
148
- this.bottom.style.background = c;
149
-
150
- },
151
-
152
- getHTML : function(){
153
-
154
- return this.content;
155
-
156
- },
157
-
158
- onChange : function( f ){
159
-
160
- this.callback = f;
161
- return this;
162
-
163
- },
164
-
165
- handleEvent : function( e ) {
166
-
167
- //e.preventDefault();
168
- //e.stopPropagation();
169
-
170
- switch( e.type ) {
171
- case 'mousedown': this.down( e ); break;
172
- case 'mouseout': this.out( e ); break;
173
- case 'mouseover': this.over( e ); break;
174
- //case 'mousewheel': this.wheel( e ); break;
175
-
176
- case 'mouseup': this.up( e ); break;
177
- case 'mousemove': this.move( e ); break;
178
- }
179
-
180
- },
181
-
182
- // Mouse event
183
-
184
- down: function( e ){
185
-
186
- if( !e.target.name ) return;
187
-
188
- if(e.target.name === 'scroll'){
189
- this.isDown = true;
190
- this.move( e );
191
- document.addEventListener( 'mouseup', this, false );
192
- document.addEventListener( 'mousemove', this, false );
193
- }
194
- if(e.target.name === 'bottom'){
195
- this.isOpen = this.isOpen ? false : true;
196
- this.bottom.textContent = this.isOpen ? 'close' : 'open';
197
- this.testHeight();
198
- }
199
-
200
- },
201
-
202
- move: function( e ){
203
-
204
- if(!this.isDown) return;
205
- this.scroll.style.background = this.colors.down;
206
- this.update( (e.clientY-this.top)-(this.sh*0.5) );
207
-
208
- },
209
-
210
-
211
-
212
- out: function( e ){
213
-
214
- if( !e.target.name ) return;
215
-
216
- if(e.target.name === 'scroll'){
217
- this.scroll.style.background = this.colors.scroll;
218
- }
219
-
220
- if(e.target.name === 'bottom'){
221
- this.bottom.style.color = '#CCC';
222
- }
223
-
224
- },
225
-
226
- up: function( e ){
227
-
228
- this.isDown = false;
229
- this.scroll.style.background = this.colors.scroll;
230
- document.removeEventListener( 'mouseup', this, false );
231
- document.removeEventListener( 'mousemove', this, false );
232
-
233
- },
234
-
235
- over: function( e ){
236
-
237
- if( !e.target.name ) return;
238
- if(e.target.name === 'scroll'){
239
- this.scroll.style.background = this.colors.select;
240
- }
241
- if(e.target.name === 'bottom'){
242
- this.bottom.style.color = '#FFF';
243
- }
244
-
245
- },
246
-
247
- // Wheel event
248
-
249
- wheel: function ( e ){
250
-
251
- //e.preventDefault();
252
- //e.stopPropagation();
253
-
254
- if( this.lockwheel || !this.isScroll ) return;
255
-
256
- //this.onWheel = true;
257
-
258
- var x = e.clientX;
259
- var px = this.content.getBoundingClientRect().left;
260
-
261
- if(x<px) return;
262
- if(x>(px+this.width)) return;
263
-
264
- var delta = 0;
265
- if(e.wheelDeltaY) delta = -e.wheelDeltaY*0.04;
266
- else if(e.wheelDelta) delta = -e.wheelDelta*0.2;
267
- else if(e.detail) delta = e.detail*4.0;
268
-
269
- this.py += delta;
270
-
271
- this.update( this.py );
272
-
273
- },
274
-
275
- // -----------------------------------
276
-
277
- // Add node to gui
278
-
279
- add:function(){
280
-
281
- var a = arguments;
282
-
283
- if( typeof a[1] === 'object' ){
284
-
285
- a[1].isUI = true;
286
- a[1].main = this;
287
-
288
- } else if( typeof a[1] === 'string' ){
289
-
290
- if( a[2] === undefined ) [].push.call(a, { isUI:true, main:this });
291
- else {
292
- a[2].isUI = true;
293
- a[2].main = this;
294
- }
295
-
296
- }
297
-
298
-
299
- var n = add.apply( this, a );
300
- //var n = UIL.add( ...args );
301
-
302
- this.uis.push( n );
303
- n.py = this.h;
304
-
305
- if( !n.autoWidth ){
306
- var y = n.c[0].getBoundingClientRect().top;
307
- if( this.prevY !== y ){
308
- this.calc( n.h + 1 );
309
- this.prevY = y;
310
- }
311
- }else{
312
- this.prevY = -1;
313
- this.calc( n.h + 1 );
314
- }
315
-
316
- return n;
317
- },
318
-
319
- // remove one node
320
-
321
- remove: function ( n ) {
322
-
323
- var i = this.uis.indexOf( n );
324
- if ( i !== -1 ) this.uis[i].clear();
325
-
326
- },
327
-
328
- // call after uis clear
329
-
330
- clearOne: function ( n ) {
331
-
332
- var i = this.uis.indexOf( n );
333
- if ( i !== -1 ) {
334
- this.inner.removeChild( this.uis[i].c[0] );
335
- this.uis.splice( i, 1 );
336
- }
337
-
338
- },
339
-
340
- // clear all gui
341
-
342
- clear:function(){
343
-
344
- var i = this.uis.length;
345
- while(i--) this.uis[i].clear();
346
-
347
- this.uis = [];
348
- Tools.listens = [];
349
-
350
- this.calc( - this.h );
351
-
352
- },
353
-
354
- // -----------------------------------
355
-
356
- // Scroll
357
-
358
- update: function ( y ){
359
-
360
- y = y < 0 ? 0 :y;
361
- y = y > this.range ? this.range : y;
362
-
363
- this.inner.style.top = - Math.floor( y / this.ratio ) + 'px';
364
- this.scroll.style.top = Math.floor( y ) + 'px';
365
-
366
- this.py = y;
367
-
368
- //this.onWheel = false;
369
-
370
- },
371
-
372
- showScroll:function(h){
373
-
374
- this.isScroll = true;
375
- this.sw = this.size.s;
376
-
377
- this.total = this.h;
378
- this.maxView = this.maxHeight;// - this.height;
379
-
380
- this.ratio = this.maxView / this.total;
381
- this.sh = this.maxView * this.ratio;
382
-
383
- if( this.sh < 20 ) this.sh = 20;
384
-
385
- this.range = this.maxView - this.sh;
386
-
387
- this.scrollBG.style.display = 'block';
388
- this.scrollBG.style.height = this.maxView + 'px';
389
- this.scroll.style.height = this.sh + 'px';
390
-
391
-
392
-
393
- this.setItemWidth( this.width - this.sw );
394
-
395
- this.update( 0 );
396
-
397
- },
398
-
399
- hideScroll:function(){
400
-
401
- this.isScroll = false;
402
- this.sw = 0;
403
-
404
-
405
- this.setItemWidth( this.width - this.sw );
406
-
407
- this.update( 0 );
408
-
409
- this.scrollBG.style.display = 'none';
410
-
411
- },
412
-
413
- // -----------------------------------
414
-
415
- resize:function(e){
416
-
417
- this.testHeight();
418
-
419
- },
420
-
421
- calc:function( y ) {
422
-
423
- this.h += y;
424
- clearTimeout( this.tmp );
425
- this.tmp = setTimeout( this.testHeight.bind(this), 10);
426
-
427
- },
428
-
429
- testHeight:function(){
430
-
431
- if( this.tmp ) clearTimeout( this.tmp );
432
-
433
- this.height = this.top + this.bh;
434
-
435
- if( this.isOpen ){
436
-
437
- this.maxHeight = window.innerHeight - this.top - this.bh;
438
-
439
- if( this.h > this.maxHeight ){
440
-
441
- this.height = this.maxHeight + this.bh;
442
- this.showScroll();
443
-
444
- }else{
445
-
446
- this.height = this.h + this.bh;
447
- this.hideScroll();
448
-
449
- }
450
-
451
- } else {
452
-
453
- this.height = this.bh;
454
- this.hideScroll();
455
-
456
- }
457
-
458
- this.innerContent.style.height = this.height - this.bh + 'px';
459
- this.content.style.height = this.height + 'px';
460
- this.bottom.style.top = this.height - this.bh + 'px';
461
-
462
- },
463
-
464
- setWidth: function( w ) {
465
-
466
- if( w ) this.width = w;
467
- this.content.style.width = this.width + 'px';
468
-
469
- //console.log(this.width)
470
-
471
-
472
- if( this.isCenter ) this.content.style.marginLeft = -(~~ (this.width*0.5)) + 'px';
473
-
474
- this.setItemWidth( this.width - this.sw );
475
-
476
- /*var l = this.uis.length;
477
- var i = l;
478
- while(i--){
479
- this.uis[i].setSize( this.width );
480
- }
481
-
482
- i = l;
483
- while(i--){
484
- this.uis[i].rSize();
485
- }*/
486
-
487
- this.resize();
488
-
489
- },
490
-
491
- setItemWidth: function( w ){
492
-
493
- var i = this.uis.length;
494
- while(i--){
495
- this.uis[i].setSize( w );
496
- this.uis[i].rSize()
497
- }
498
-
499
- },
500
-
501
-
502
- };
503
-
504
-
505
- export { Gui };