aboutsummaryrefslogtreecommitdiff
path: root/paste-ui/src/stateExample.js
diff options
context:
space:
mode:
Diffstat (limited to 'paste-ui/src/stateExample.js')
-rw-r--r--paste-ui/src/stateExample.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/paste-ui/src/stateExample.js b/paste-ui/src/stateExample.js
new file mode 100644
index 0000000..91fee18
--- /dev/null
+++ b/paste-ui/src/stateExample.js
@@ -0,0 +1,32 @@
+import { useState } from 'react';
+export default function MovingDot() {
+ const [position, setPosition] = useState({
+ x: 0,
+ y: 0
+ });
+ return (
+ <div
+ onPointerMove={e => {
+ setPosition({
+ x: e.clientX,
+ y: e.clientY
+ });
+ }}
+ style={{
+ position: 'relative',
+ width: '100vw',
+ height: '100vh',
+ }}>
+ <div style={{
+ position: 'absolute',
+ backgroundColor: 'red',
+ borderRadius: '50%',
+ transform: `translate(${position.x}px, ${position.y}px)`,
+ left: -10,
+ top: -10,
+ width: 20,
+ height: 20,
+ }} />
+ </div>
+ );
+} \ No newline at end of file