Fixed the controller's 'option' method

When a controller's contents were modified with the 'option' method, the
newly created controller was appended to the bottom of the GUI instead
of replacing the position of the former controller. This bug has been
fixed.
This commit is contained in:
jaxry 2014-05-06 01:38:46 -06:00
parent f36a8273a1
commit 6994bee8f0
3 changed files with 90 additions and 86 deletions

View File

@ -2350,7 +2350,7 @@ dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, contro
var li = document.createElement('li');
if (dom) li.appendChild(dom);
if (liBefore) {
gui.__ul.insertBefore(li, params.before);
gui.__ul.insertBefore(li, liBefore);
} else {
gui.__ul.appendChild(li);
}
@ -2368,6 +2368,7 @@ dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, contro
options: function(options) {
if (arguments.length > 1) {
var next_sibling = controller.__li.nextElementSibling;
controller.remove();
return add(
@ -2375,7 +2376,7 @@ dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, contro
controller.object,
controller.property,
{
before: controller.__li.nextElementSibling,
before: next_sibling,
factoryArgs: [common.toArray(arguments)]
}
);
@ -2383,6 +2384,7 @@ dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, contro
}
if (common.isArray(options) || common.isObject(options)) {
var next_sibling = controller.__li.nextElementSibling;
controller.remove();
return add(
@ -2390,7 +2392,7 @@ dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, contro
controller.object,
controller.property,
{
before: controller.__li.nextElementSibling,
before: next_sibling,
factoryArgs: [options]
}
);

160
build/dat.gui.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -855,7 +855,7 @@ define([
var li = document.createElement('li');
if (dom) li.appendChild(dom);
if (liBefore) {
gui.__ul.insertBefore(li, params.before);
gui.__ul.insertBefore(li, liBefore);
} else {
gui.__ul.appendChild(li);
}
@ -873,6 +873,7 @@ define([
options: function(options) {
if (arguments.length > 1) {
var next_sibling = controller.__li.nextElementSibling;
controller.remove();
return add(
@ -880,7 +881,7 @@ define([
controller.object,
controller.property,
{
before: controller.__li.nextElementSibling,
before: next_sibling,
factoryArgs: [common.toArray(arguments)]
}
);
@ -888,6 +889,7 @@ define([
}
if (common.isArray(options) || common.isObject(options)) {
var next_sibling = controller.__li.nextElementSibling;
controller.remove();
return add(
@ -895,7 +897,7 @@ define([
controller.object,
controller.property,
{
before: controller.__li.nextElementSibling,
before: next_sibling,
factoryArgs: [options]
}
);