Created
January 10, 2014 16:59
-
-
Save automata/8358078 to your computer and use it in GitHub Desktop.
react + dat.gui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var KielerOptions = function () { | |
this.spacing = 15.0; | |
this.apply = function () { | |
var event = new CustomEvent("kieler", { detail: this }); | |
window.dispatchEvent(event); | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TheGraph.Graph = React.createClass({ | |
getInitialState: function() { | |
return { | |
graph: this.props.graph | |
}; | |
}, | |
componentDidUpdate: function (prevProps, prevState, rootNode) { | |
console.log('graph updated', this.state.graph); | |
}, | |
componentDidMount: function () { | |
window.addEventListener('kieler', function (event) { | |
var layoutOptions = event.detail; | |
kieler(this.state.graph, layoutOptions, function (g) { | |
this.setState({graph: g}); | |
}.bind(this)); | |
}.bind(this)); | |
}, | |
componentWillMount: function () { | |
// xhr to kieler and update the graph | |
kieler(this.state.graph, {spacing: 15}, function (g) { | |
this.setState({graph: g}); | |
}.bind(this)); | |
}, | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment