Merge branch 'Sigill-removefolder'

This commit is contained in:
Don McCurdy 2017-12-23 12:00:12 -05:00
commit 269fda085f
2 changed files with 56 additions and 19 deletions

View File

@ -628,6 +628,29 @@ common.extend(
return gui; 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);
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. * Opens the GUI.
*/ */

View File

@ -1187,6 +1187,20 @@ console.log(c2.__checkbox.getAttribute('checked'));
}); });
test('removeFolder', function() {
var gui = new GUI();
var f = gui.addFolder('Temporary folder');
ok($.contains(gui.domElement, f.domElement), "Now you see it");
gui.removeFolder(f);
ok(!$.contains(gui.domElement, f.domElement), "Now you don't.");
gui.destroy();
});
test('min, max & step', function() { test('min, max & step', function() {