-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfluid.jsx
40 lines (31 loc) · 981 Bytes
/
fluid.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React from 'react';
export default class Fluid extends React.Component {
constructor(props) {
super(props);
this.state = {
style: {
color: 'white',
height: '100%', // Canvas is will respond to size changes without resetting fluid!
width: '100%',
margin: 0
}
};
}
// Basically when the component mounts it adds a <script> tag containing
// the fluid sim logic which will execute once added, hooking into the <cavnas>
componentDidMount() {
const script = document.createElement("script");
script.src = "./assets/js/fluid-init.js";
script.async = true;
script.onload = () => this.fluidLoaded();
document.body.appendChild(script);
}
fluidLoaded() {
console.log("WebGL Canvas Loaded // also a callback function if you need it.")
}
render() {
return (
<canvas className="fluid-canvas" style={this.state.style}></canvas>
);
}
}