This commit is contained in:
Don McCurdy 2018-02-16 20:03:17 -08:00
parent 69faca4d74
commit f3cdfde17f
7 changed files with 41 additions and 13 deletions

View File

@ -1958,14 +1958,18 @@ Common.extend(GUI.prototype,
});
},
destroy: function destroy() {
if (this.parent) {
throw new Error('Only the root GUI should be removed with .destroy(). ' + 'For subfolders, use gui.removeFolder(folder) instead.');
}
if (this.autoPlace) {
autoPlaceContainer.removeChild(this.domElement);
}
var _this = this;
Common.each(this.__folders, function (subfolder) {
_this.removeFolder(subfolder);
});
dom.unbind(window, 'keydown', GUI._keydownHandler, false);
dom.unbind(window, 'resize', this.__resizeHandler);
if (this.saveToLocalStorageIfPossible) {
dom.unbind(window, 'unload', this.saveToLocalStorageIfPossible);
}
removeListeners(this);
},
addFolder: function addFolder(name) {
if (this.__folders[name] !== undefined) {
@ -1993,7 +1997,11 @@ Common.extend(GUI.prototype,
this.load.folders[folder.name]) {
delete this.load.folders[folder.name];
}
removeListeners(folder);
var _this = this;
Common.each(folder.__folders, function (subfolder) {
folder.removeFolder(subfolder);
});
Common.defer(function () {
_this.onResize();
});
@ -2143,6 +2151,12 @@ function addRow(gui, newDom, liBefore) {
gui.onResize();
return li;
}
function removeListeners(gui) {
dom.unbind(window, 'resize', gui.__resizeHandler);
if (gui.saveToLocalStorageIfPossible) {
dom.unbind(window, 'unload', gui.saveToLocalStorageIfPossible);
}
}
function markPresetModified(gui, modified) {
var opt = gui.__preset_select[gui.__preset_select.selectedIndex];
if (modified) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1952,14 +1952,18 @@ Common.extend(GUI.prototype,
});
},
destroy: function destroy() {
if (this.parent) {
throw new Error('Only the root GUI should be removed with .destroy(). ' + 'For subfolders, use gui.removeFolder(folder) instead.');
}
if (this.autoPlace) {
autoPlaceContainer.removeChild(this.domElement);
}
var _this = this;
Common.each(this.__folders, function (subfolder) {
_this.removeFolder(subfolder);
});
dom.unbind(window, 'keydown', GUI._keydownHandler, false);
dom.unbind(window, 'resize', this.__resizeHandler);
if (this.saveToLocalStorageIfPossible) {
dom.unbind(window, 'unload', this.saveToLocalStorageIfPossible);
}
removeListeners(this);
},
addFolder: function addFolder(name) {
if (this.__folders[name] !== undefined) {
@ -1987,7 +1991,11 @@ Common.extend(GUI.prototype,
this.load.folders[folder.name]) {
delete this.load.folders[folder.name];
}
removeListeners(folder);
var _this = this;
Common.each(folder.__folders, function (subfolder) {
folder.removeFolder(subfolder);
});
Common.defer(function () {
_this.onResize();
});
@ -2137,6 +2145,12 @@ function addRow(gui, newDom, liBefore) {
gui.onResize();
return li;
}
function removeListeners(gui) {
dom.unbind(window, 'resize', gui.__resizeHandler);
if (gui.saveToLocalStorageIfPossible) {
dom.unbind(window, 'unload', gui.saveToLocalStorageIfPossible);
}
}
function markPresetModified(gui, modified) {
var opt = gui.__preset_select[gui.__preset_select.selectedIndex];
if (modified) {

File diff suppressed because one or more lines are too long

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "dat.gui",
"version": "0.7.0",
"version": "0.7.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "dat.gui",
"version": "0.7.0",
"version": "0.7.1",
"description": "A lightweight graphical user interface for changing variables in JavaScript.",
"main": "build/dat.gui.js",
"module": "build/dat.gui.module.js",