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.
|
* @class Represents a custom controller.
|
||||||
* @param {Object} object
|
* @param {init} callback function for adding of elements into this.domElement
|
||||||
* @param {string} property
|
|
||||||
*/
|
*/
|
||||||
class CustomController extends Controller{
|
class CustomController extends Controller{
|
||||||
constructor(init) {
|
constructor(init) {
|
||||||
|
@ -567,13 +567,12 @@ common.extend(
|
|||||||
* @instance
|
* @instance
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
addCustomController: function(object, property) {
|
addCustomController: function(init, property) {
|
||||||
return add(
|
return add(
|
||||||
this,
|
this,
|
||||||
object,
|
new dat.controllers.CustomController( init ),
|
||||||
property,
|
property,
|
||||||
{
|
{
|
||||||
custom: true,
|
|
||||||
factoryArgs: Array.prototype.slice.call(arguments, 2)
|
factoryArgs: Array.prototype.slice.call(arguments, 2)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -1165,9 +1164,7 @@ function add(gui, object, property, params) {
|
|||||||
controller = new ColorController(object, property);
|
controller = new ColorController(object, property);
|
||||||
} else if(customObject && ( property === undefined )){
|
} else if(customObject && ( property === undefined )){
|
||||||
controller = object;
|
controller = object;
|
||||||
} else if (!(customObject) && params.custom && (object[property] === undefined)) {
|
} else {
|
||||||
controller = new CustomController(object, property);
|
|
||||||
}else {
|
|
||||||
const factoryArgs = customObject ?
|
const factoryArgs = customObject ?
|
||||||
[property].concat(params.factoryArgs) : [object, property].concat(params.factoryArgs);
|
[property].concat(params.factoryArgs) : [object, property].concat(params.factoryArgs);
|
||||||
controller = ControllerFactory.apply(gui, factoryArgs);
|
controller = ControllerFactory.apply(gui, factoryArgs);
|
||||||
@ -1183,9 +1180,8 @@ function add(gui, object, property, params) {
|
|||||||
|
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
|
|
||||||
const name = params.custom && ( controller instanceof CustomController === false ) ?
|
const name = customObject ? object.domElement : document.createElement('span');
|
||||||
( customObject ? object.domElement : new CustomController(object).domElement ) : document.createElement('span');
|
if (!customObject)
|
||||||
if (!params.custom)
|
|
||||||
name.innerHTML = controller.property;
|
name.innerHTML = controller.property;
|
||||||
dom.addClass(name, 'property-name');
|
dom.addClass(name, 'property-name');
|
||||||
container.appendChild(name);
|
container.appendChild(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user