mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
66 lines
1.1 KiB
HTML
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> |