From 60033b6b1d6c85eb16a02f0ff3d6c42cf0ab5131 Mon Sep 17 00:00:00 2001 From: Cyrille Faucheux Date: Wed, 12 Oct 2016 22:05:26 +0200 Subject: [PATCH 1/3] add a way to remove a folder --- src/dat/gui/GUI.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index e0ee00b..b7f290a 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -628,6 +628,24 @@ common.extend( return gui; }, + removeFolder: function(folder) { + this.__ul.removeChild(folder.domElement.parentElement); + + delete this.__folders[folder.name]; + + // Do we have saved appearance data for this folder? + if (this.load && // Anything loaded? + this.load.folders && // Was my parent a dead-end? + this.load.folders[folder.name]) { + delete this.load.folders[folder.name]; + } + + const _this = this; + common.defer(function() { + _this.onResize(); + }); + }, + /** * Opens the GUI. */ From 76c80858c315b8507c71388c59c9359ae1a433e2 Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Sat, 23 Dec 2017 11:48:35 -0500 Subject: [PATCH 2/3] Add JSDoc for .removeFolder(). --- src/dat/gui/GUI.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index b7f290a..801c6c7 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -628,6 +628,11 @@ common.extend( return gui; }, + /** + * Removes a subfolder GUI instance. + * {dat.gui.GUI} folder The folder to remove. + * @instance + */ removeFolder: function(folder) { this.__ul.removeChild(folder.domElement.parentElement); From 59f685b01805c085278fa7d3c7a7d48a013f57b2 Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Sat, 23 Dec 2017 11:59:44 -0500 Subject: [PATCH 3/3] Test .removeFolder(). --- src/dat/gui/GUI.js | 6 +++--- tests/index.html | 52 +++++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index 801c6c7..4c00993 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -640,9 +640,9 @@ common.extend( // Do we have saved appearance data for this folder? if (this.load && // Anything loaded? - this.load.folders && // Was my parent a dead-end? - this.load.folders[folder.name]) { - delete this.load.folders[folder.name]; + this.load.folders && // Was my parent a dead-end? + this.load.folders[folder.name]) { + delete this.load.folders[folder.name]; } const _this = this; diff --git a/tests/index.html b/tests/index.html index c5b13ca..6b146c0 100644 --- a/tests/index.html +++ b/tests/index.html @@ -6,7 +6,7 @@ - + - +

@@ -1433,4 +1447,4 @@ console.log(c2.__checkbox.getAttribute('checked'));
    test markup, will be hidden
    - \ No newline at end of file +