mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
added demo
simplified bind
This commit is contained in:
parent
8dcce60d1d
commit
8ffecf6987
49
demo.html
Normal file
49
demo.html
Normal file
@ -0,0 +1,49 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>dat-gui</title>
|
||||
|
||||
<link rel="import" href="gui.html">
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script src="../underscore/underscore.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
Gui.ready( init );
|
||||
|
||||
var object;
|
||||
|
||||
function init() {
|
||||
|
||||
var gui = new Gui();
|
||||
|
||||
object = {
|
||||
numberProperty: 0,
|
||||
stringProperty: 'hey',
|
||||
booleanProperty: false,
|
||||
functionProperty: function() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
gui.add( object, 'numberProperty', 0, 1 ); // Slider
|
||||
gui.add( object, 'stringProperty' ); // Text box
|
||||
gui.add( object, 'booleanProperty' ); // Check box
|
||||
gui.add( object, 'functionProperty' ); // Button
|
||||
|
||||
console.log( gui );
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -2,4 +2,4 @@
|
||||
|
||||
<script src="controller-base.js"></script>
|
||||
|
||||
<polymer-element name="controller-base" attributes="object path"></polymer-element>
|
||||
<polymer-element name="controller-base" attributes="object path value"></polymer-element>
|
@ -26,31 +26,33 @@ Polymer('controller-base', {
|
||||
this.object = object;
|
||||
this.path = path;
|
||||
|
||||
if ( this._observer ) {
|
||||
this._observer.close();
|
||||
delete this._observer;
|
||||
}
|
||||
// if ( this._observer ) {
|
||||
// this._observer.close();
|
||||
// delete this._observer;
|
||||
// }
|
||||
|
||||
var _this = this;
|
||||
this.bind('value', new PathObserver(this.object, this.path));
|
||||
|
||||
this._observer = new PathObserver( this.object, this.path );
|
||||
this._observer.open( function( newValue ) {
|
||||
// var _this = this;
|
||||
|
||||
_this.value = newValue;
|
||||
// this._observer = new PathObserver( this.object, this.path );
|
||||
// this._observer.open( function( newValue ) {
|
||||
|
||||
} );
|
||||
// _this.value = newValue;
|
||||
|
||||
this.value = this.object[ this.path ];
|
||||
// } );
|
||||
|
||||
// this.value = this.object[ this.path ];
|
||||
|
||||
},
|
||||
|
||||
valueChanged: function() {
|
||||
|
||||
if ( this._observer ) {
|
||||
// if ( this._observer ) {
|
||||
|
||||
Path.get( this.path ).setValueFrom( this.object, this.value );
|
||||
// Path.get( this.path ).setValueFrom( this.object, this.value );
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
this.update();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user