-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
31 lines (26 loc) · 802 Bytes
/
script.js
File metadata and controls
31 lines (26 loc) · 802 Bytes
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
import React from 'react';
import ReactDOM from 'react-dom';
function transform(offset) {
const cos = Math.cos(offset);
const sin = Math.sin(offset);
return { transform: `matrix3d(${sin}, ${-cos}, ${sin}, 0, ${-cos}, ${sin}, 0, 0, 0, ${cos}, ${cos}, ${sin}, 0, 0, 0, 1)` };
}
class App extends React.Component{
state = { styleOne:{} ,styleTwo: {}};
onMouseMove=(event)=>{
this.setState({
styleOne : transform(-event.clientX/event.clientY),
styleTwo : transform(event.clientX/event.clientY)
})
}
render(){
return <div onMouseMove={this.onMouseMove}>
<div className = "panel" style = {this.state.styleOne}/>
<div className = "panel" style = {this.state.styleTwo}/>
</div>
}
}
ReactDOM.render(
<App />,
document.querySelector('#root')
);