-
Notifications
You must be signed in to change notification settings - Fork 6
/
render_to_react.js
26 lines (20 loc) · 1.12 KB
/
render_to_react.js
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
var app = function(width, height){
return React.createElement("div", {layout: {mode: "self-directed",
horizontal: {size: width},
vertical: {size: height}},
childrenLayout: {mode: "stack-horizontal"}},
React.createElement("div"),
React.createElement("div", {layout: {main: {before: 20, size: 50, after: 20},
cross: {before: 10, size: "1s", after: 10}}}),
React.createElement("div"));
};
//This function loads and compiles the web assembly layout engine; callback is given function w/ same signature as ReactDOM.render.
subform_init_react_layout(function(render){
render(app(400, 400), document.getElementById("container"));
//Hold control key and zoom mouse around to get a sense of perf
window.addEventListener("mousemove", function(e){
if(e.ctrlKey){
render(app(e.clientX, e.clientY), document.getElementById("container"));
}
});
});