Skip to content

Commit

Permalink
disabled wand on mobile devices (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmonisit authored Feb 4, 2024
1 parent 4cf4c79 commit 5bf75bf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/ui/cursor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import React, { useState, useEffect } from "react";
import React, { useState, useEffect, useMemo } from "react";
import Image from 'next/image';
import LugeReact from "./luge";

Expand All @@ -26,8 +26,15 @@ const TrailEffect = () => {
);
}

function detectIfTouchDevice() {
return (('ontouchstart' in window) ||
(navigator.maxTouchPoints > 0) ||
(navigator.maxTouchPoints > 0));
}

const Cursor = () => {
const [position, setPosition] = useState({ x: 0, y: 0 });
const [isTouchDevice, setIsTouchDevice] = useState(true);

const [isPointer, setIsPointer] = useState(false);

Expand All @@ -47,6 +54,8 @@ const Cursor = () => {
useEffect(() => {
window.addEventListener("mousemove", handleMouseMove);

setIsTouchDevice(detectIfTouchDevice());

return () => window.removeEventListener("mousemove", handleMouseMove);
}, []);

Expand All @@ -68,7 +77,7 @@ const Cursor = () => {
height={YSize}
className="select-none z-50"
style={{
display: hasNotMoved ? "none" : "block",
display: hasNotMoved || isTouchDevice ? "none" : "block",
transform: `rotate(${rotationAngle}deg)`,
position: "fixed",
left: `${leftPos}px`,
Expand Down

0 comments on commit 5bf75bf

Please sign in to comment.