dat.gui/elements/base-controller.html
George Michael Brower c70498ebcd basecontroller
2014-08-14 22:21:45 -04:00

66 lines
1.1 KiB
HTML

<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="base-controller">
<template>
<style>
</style>
</template>
</div>
<script>
Polymer('base-controller', {
object: null,
property: null,
ready: function() {
this.update();
},
objectChanged: function() {
if ( this.object && this.property ) {
this.bindToObject();
}
},
propertyChanged: function() {
if ( this.object && this.property ) {
this.bindToObject();
}
},
valueChanged: function() {
if ( this._boundToObject ) this.object[ this.property ] = this.value;
else this.update();
},
bindToObject: function() {
var _this = this;
this._boundToObject = true;
Object.observe( this.object, function( changes ) {
changes.forEach( function( c ) {
if ( c.name == _this.property ) {
_this.update()
}
} );
} );
},
});
</script>
</polymer-element>