mirror of
https://github.com/gre/gl-react.git
synced 2026-01-25 16:43:36 +00:00
29 lines
707 B
JavaScript
29 lines
707 B
JavaScript
const React = require("react");
|
|
const Blur = require("./Blur");
|
|
|
|
class Demo extends React.Component {
|
|
constructor (props) {
|
|
super(props);
|
|
this.state = {
|
|
time: 0
|
|
};
|
|
}
|
|
componentDidMount () {
|
|
const loop = time => {
|
|
requestAnimationFrame(loop);
|
|
this.setState({ time: time / 1000 });
|
|
};
|
|
requestAnimationFrame(loop);
|
|
}
|
|
render () {
|
|
const { width, height } = this.props;
|
|
const { time } = this.state;
|
|
const factor = 1 * (1+Math.cos(8 * time));
|
|
return <Blur width={width} height={height} factor={factor}>
|
|
http://i.imgur.com/3On9QEu.jpg
|
|
</Blur>;
|
|
}
|
|
}
|
|
|
|
React.render(<Demo width={640} height={480} />, document.getElementById("container"));
|