Skip to content

Commit

Permalink
fix initial mouse pos
Browse files Browse the repository at this point in the history
  • Loading branch information
brycedorn committed Nov 14, 2023
1 parent ee2aa3f commit 112b10e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/ReactIntense.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions lib/ReactIntense.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ function ReactIntense(props: Props) {

const [distance, setDistance] = useState(0);
const [loaded, setLoaded] = useState(false);
const mouseDest = useRef<{ x: number; y: number } | undefined>({
const mouseDest = useRef<{ x: number; y: number }>({
x: 0,
y: 0,
});
const mouseCurr = useRef<{ x: number; y: number } | undefined>({
const mouseCurr = useRef<{ x: number; y: number }>({
x: window.innerWidth / 2,
y: window.innerHeight / 2,
});
Expand All @@ -62,7 +62,7 @@ function ReactIntense(props: Props) {
const intervalKey = useRef<number | undefined>();

function positionTarget() {
if (!imgRef.current || !mouseCurr.current || !mouseDest.current) {
if (!imgRef.current) {
return;
}

Expand Down Expand Up @@ -157,6 +157,11 @@ function ReactIntense(props: Props) {
onClick(e);
}

mouseDest.current = {
x: e.clientX,
y: e.clientY,
};

setVisible(true);
lockBody();
}
Expand Down

0 comments on commit 112b10e

Please sign in to comment.