perfect-gui 3.2.0 → 3.3.1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "perfect-gui",
3
- "version": "3.2.0",
3
+ "version": "3.3.1",
4
4
  "description": "Nice and simple GUI for JavaScript.",
5
5
  "main": "src/index.js",
6
6
  "directories": {
package/src/index.js CHANGED
@@ -29,7 +29,7 @@ export default class GUI {
29
29
  }
30
30
  this.instanceId = GUI[GUI.instanceCounter];
31
31
 
32
- this.wrapperWidth = (options != undefined && options.width) ? options.width : 290;
32
+ this.wrapperWidth = options.width || 290;
33
33
  this.stylesheet = document.createElement('style');
34
34
  this.stylesheet.setAttribute('type', 'text/css');
35
35
  this.stylesheet.setAttribute('id', 'lm-gui-stylesheet');
@@ -60,8 +60,17 @@ export default class GUI {
60
60
  this.position = {prevX:this.xOffset, prevY:this.yOffset, x:this.xOffset, y:this.yOffset};
61
61
 
62
62
  let verticalCSSPositioning = this.screenCorner.y == 'top' ? '' : 'top: auto; bottom: 0;';
63
+ if ( options.maxHeight ) {
64
+ this.maxHeight = options.maxHeight;
65
+ } else {
66
+ this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight)
67
+ }
68
+ window.addEventListener('resize', () => {
69
+ this.maxHeight = Math.min(options.maxHeight || '', Math.min(this.container.clientHeight, window.innerHeight));
70
+ });
63
71
  this._addStyles(`#p-gui-${this.instanceId} {
64
72
  width: ${this.wrapperWidth}px;
73
+ max-height: ${this.maxHeight}px;
65
74
  transform: translate3d(${this.xOffset}px,${this.yOffset}px,0);
66
75
  ${verticalCSSPositioning}
67
76
  }`);
package/src/styles.js CHANGED
@@ -17,7 +17,7 @@ return /* css */`
17
17
  flex-wrap: wrap;
18
18
  font-family: Verdana, Arial, sans-serif;
19
19
  width: 290px;
20
- overflow: hidden;
20
+ overflow: auto;
21
21
  box-shadow: 0 0 10px black;
22
22
  box-sizing: border-box;
23
23
  z-index: 99999;
@@ -195,6 +195,7 @@
195
195
  <p>They can also have a custom width, by using the <span class="code-inline">width</span> option.</p>
196
196
  <p>The <span class="code-inline">toggleClose()</span> method can be used to open / close a GUI panel.</p>
197
197
  <p>Just like folders, GUI panels can be closed by default by setting the <span class="code-inline">close</span> option to <span class="code-inline">true</span>.</p>
198
+ <p>The <span class="code-inline">maxHeight</span> option can be used to define the maximum height of a panel beyond which scrolling is necessary. Default is the smallest value between the height of the window and the height of the container.</p>
198
199
 
199
200
  <div id="container-4" class="container"></div>
200
201
 
@@ -26,11 +26,28 @@ export default function other() {
26
26
 
27
27
  const gui_3 = new GUI({
28
28
  container,
29
- name: 'GUI 3 (closed)',
29
+ name: 'GUI 3 (closed, scrollable)',
30
30
  closed: true,
31
31
  });
32
32
 
33
33
  gui_3.button('gui_2.toggleClose();', () => {
34
34
  gui_2.toggleClose();
35
35
  });
36
+
37
+ gui_3.button('lorem', () => {});
38
+ gui_3.button('ipsum', () => {});
39
+ gui_3.button('dolor', () => {});
40
+ gui_3.button('sit', () => {});
41
+ gui_3.button('amet', () => {});
42
+ gui_3.button('lorem', () => {});
43
+ gui_3.button('ipsum', () => {});
44
+ let f = gui_3.folder('dolor');
45
+ f.button('dolor', () => {});
46
+ f.button('dolor', () => {});
47
+ f.button('dolor', () => {});
48
+ gui_3.button('sit', () => {});
49
+ gui_3.button('amet', () => {});
50
+ gui_3.button('lorem', () => {});
51
+ gui_3.button('ipsum', () => {});
52
+ gui_3.button('ipsum', () => {});
36
53
  }
@@ -35,6 +35,10 @@ h2 {
35
35
  margin-top: 80px;
36
36
  }
37
37
 
38
+ p {
39
+ line-height: 1.4;
40
+ }
41
+
38
42
  .code-button {
39
43
  text-decoration: underline;
40
44
  cursor: pointer;