dat.gui/elements/controller-base/controller-base.js

94 lines
1.5 KiB
JavaScript
Raw Normal View History

2014-08-27 00:01:15 +00:00
/*
[ ] onChange( )
[ ] onFinishChange( )
*/
Polymer('controller-base', {
ready: function() {
this.update();
},
update: function() {},
init: function() {},
// Observers
// -------------------------------
watch: function( object, path ) {
this.object = object;
this.path = path;
2014-08-15 22:04:51 +00:00
2014-09-01 03:54:59 +00:00
this.bind('value', new PathObserver(this.object, this.path));
2014-08-15 16:32:49 +00:00
2014-08-27 01:01:16 +00:00
// if ( this._observer ) {
// this._observer.close();
// delete this._observer;
// }
2014-08-27 00:01:15 +00:00
2014-08-27 01:01:16 +00:00
// var _this = this;
2014-08-27 00:01:15 +00:00
2014-08-27 01:01:16 +00:00
// this._observer = new PathObserver( this.object, this.path );
// this._observer.open( function( newValue ) {
2014-08-27 00:01:15 +00:00
2014-08-27 01:01:16 +00:00
// _this.value = newValue;
2014-08-27 00:01:15 +00:00
2014-08-27 01:01:16 +00:00
// } );
// this.value = this.object[ this.path ];
2014-08-27 00:01:15 +00:00
},
valueChanged: function() {
2014-08-27 01:01:16 +00:00
// if ( this._observer ) {
2014-08-27 00:01:15 +00:00
2014-08-27 01:01:16 +00:00
// Path.get( this.path ).setValueFrom( this.object, this.value );
2014-08-27 00:01:15 +00:00
2014-08-27 01:01:16 +00:00
// }
2014-08-27 00:01:15 +00:00
this.update();
},
// Helpers
// -------------------------------
map: function( x, a, b, c, d ) {
return ( x - a ) / ( b - a ) * ( d - c ) + c;
},
// Legacy
// -------------------------------
listen: function() {
Gui.warn( 'controller.listen() is deprecated. All controllers are listened for free.' );
return this;
},
getValue: function() {
return this.value;
},
setValue: function( v ) {
this.value = v;
}
});