set get controller

This commit is contained in:
Andrej 2019-06-30 18:06:23 +07:00
parent cbcd3d5e3c
commit cfa3631b0d
2 changed files with 18 additions and 7 deletions

View File

@ -20,12 +20,15 @@ import ControllerFactory from './ControllerFactory';
*
* @extends dat.controllers.Controller
*
*/
class CustomController extends Controller{
/**
* Represents a custom controller.
* @param {Object} object The object to be manipulated
* @param {Function} [object.property] Returns an object with elements for adding into "property-name" class element.
* @param {string} property The name of the property to be manipulated
* @param {Object} [params] Optional parameters
*/
class CustomController extends Controller{
constructor(object, property) {
super(object, property);
@ -33,7 +36,13 @@ class CustomController extends Controller{
object: object, property: property, opts: Array.prototype.slice.call(arguments, 2)
}
if(object.property)
this.property = object.property();
this.property = object.property( this );
}
set controller( newController ){
this._controller = newController;
}
get controller(){
return this._controller;
}
}

View File

@ -1158,6 +1158,8 @@ function add(gui, object, property, params) {
}
if ( controller === null )
controller = customObject;
else if( customObject !== undefined )
customObject.controller = controller;
if (params.before instanceof Controller) {
params.before = params.before.__li;