mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
CustomController
This commit is contained in:
parent
880a802483
commit
e56ba62d3d
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user