-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathNextButton.tsx
More file actions
32 lines (28 loc) · 839 Bytes
/
NextButton.tsx
File metadata and controls
32 lines (28 loc) · 839 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
32
import * as React from 'react';
export default function NextButton() {
const [left, setLeft] = React.useState<number>(0);
const [top, setTop] = React.useState<number>(0);
function handleMouseMove(event: React.MouseEvent<HTMLDivElement>) {
const randomIndex = Math.floor(Math.random() * 4);
const positionArray = [
{ x: -200, y: -200 },
{ x: -400, y: 200 },
{ x: 400, y: -200 },
{ x: 50, y: 200 },
];
setLeft(positionArray[randomIndex].x);
setTop(positionArray[randomIndex].y);
}
const styles: React.CSSProperties = {
padding: '10px',
transform: `translateY(${top}px) translateX(${left}px)`,
transition: 'transform 0.5s linear',
};
return (
<div>
<div style={styles}>
<a href="/challenge_2"> Go to next challenge</a>
</div>
</div>
);
}