diff --git a/src/dat/controllers/CustomController.js b/src/dat/controllers/CustomController.js index 819610b..aca26d8 100644 --- a/src/dat/controllers/CustomController.js +++ b/src/dat/controllers/CustomController.js @@ -14,8 +14,7 @@ import Controller from './Controller'; /** * @class Represents a custom controller. - * @param {Object} object - * @param {string} property + * @param {init} callback function for adding of elements into this.domElement */ class CustomController extends Controller{ constructor(init) { diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index 4f1d87e..49dbcab 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -567,13 +567,12 @@ common.extend( * @instance * */ - addCustomController: function(object, property) { + addCustomController: function(init, property) { return add( this, - object, + new dat.controllers.CustomController( init ), property, { - custom: true, factoryArgs: Array.prototype.slice.call(arguments, 2) } ); @@ -1165,9 +1164,7 @@ function add(gui, object, property, params) { controller = new ColorController(object, property); } else if(customObject && ( property === undefined )){ controller = object; - } else if (!(customObject) && params.custom && (object[property] === undefined)) { - controller = new CustomController(object, property); - }else { + } else { const factoryArgs = customObject ? [property].concat(params.factoryArgs) : [object, property].concat(params.factoryArgs); controller = ControllerFactory.apply(gui, factoryArgs); @@ -1183,9 +1180,8 @@ function add(gui, object, property, params) { const container = document.createElement('div'); - const name = params.custom && ( controller instanceof CustomController === false ) ? - ( customObject ? object.domElement : new CustomController(object).domElement ) : document.createElement('span'); - if (!params.custom) + const name = customObject ? object.domElement : document.createElement('span'); + if (!customObject) name.innerHTML = controller.property; dom.addClass(name, 'property-name'); container.appendChild(name);