-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathon-position-changed.html
More file actions
56 lines (51 loc) · 1.55 KB
/
on-position-changed.html
File metadata and controls
56 lines (51 loc) · 1.55 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//cdn.jsdelivr.net/highlight.js/9.9.0/styles/solarized-light.min.css">
<script src="//cdn.jsdelivr.net/highlight.js/9.9.0/highlight.min.js"></script>
<link rel="stylesheet" href="styles.css">
<title>On Cursor Position Changed | Code Example | React Cursor Position</title>
</head>
<body>
<pre>
<code class="JavaScript">
import React from 'react';
import ReactCursorPosition from 'react-cursor-position';
import PositionChangedLabel from './PositionChangedLabel';
import InstructionsLabel from './InstructionsLabel';
export default class extends React.Component {
constructor(props) {
super(props);
this.state = {
isPositionOutside: true,
position: {
x: 0,
y: 0
}
}
}
render() {
return (
<div className="example">
<ReactCursorPosition {...{
className: 'example__target',
onPositionChanged: props => this.setState(props)
}}>
{() => (
<InstructionsLabel />
)}
</ReactCursorPosition>
<PositionChangedLabel {...this.state} />
</div>
);
}
}
</code>
</pre>
<script>
hljs.initHighlightingOnLoad();
</script>
</body>
</html>