Skip to content

Commit

Permalink
"created cursor component with wang image
Browse files Browse the repository at this point in the history
 with '#' will be ignored, and an empty message aborts the commit.
  • Loading branch information
poojakedia committed Jan 25, 2024
1 parent f9c6f1e commit 35bba11
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions app/ui/cursor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use client";

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

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

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

const handleMouseMove = (e: any) => {
setPosition({ x: e.clientX, y: e.clientY });

const target = e.target;

setIsPointer(
window.getComputedStyle(target).getPropertyValue("cursor") === "pointer"
);

e.stopPropagation();
};

useEffect(() => {
window.addEventListener("mousemove", handleMouseMove);

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

const YSize = isPointer ? 0 : 100;
const XSize = isPointer ? 0 : 20;
const rotationAngle = isPointer ? 0 : 315;
var topPos = position.y - YSize / 2;

const cursorStyle = isPointer ? { display: "none" } : { transform: `rotate(${rotationAngle}deg)`, cursor: "none"};

return (
<Image
src={"/landing/wand.png"}
alt="Custom Cursor"
width = {XSize}
height = {YSize}
style={{
...cursorStyle,
position: "fixed",
left: `${position.x - XSize / 2}px`,
top:`${topPos}px`,
}}
/>
);
};

export default Cursor;
Binary file added public/landing/wand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 35bba11

Please sign in to comment.