├── public
├── robots.txt
├── favicon.ico
├── logo192.png
├── logo512.png
├── manifest.json
└── index.html
├── src
├── final.JPG
├── index.js
├── index.css
├── App.css
└── App.js
├── .gitignore
├── README.md
└── package.json
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/src/final.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/candraKriswinarto/custom-cursor-react-framer-motion/HEAD/src/final.JPG
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/candraKriswinarto/custom-cursor-react-framer-motion/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/candraKriswinarto/custom-cursor-react-framer-motion/HEAD/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/candraKriswinarto/custom-cursor-react-framer-motion/HEAD/public/logo512.png
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom/client';
3 | import './index.css';
4 | import App from './App';
5 |
6 | const root = ReactDOM.createRoot(document.getElementById('root'));
7 | root.render(
8 |
16 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
17 |
18 | ### Link
19 |
20 | Reactjs: https://reactjs.org/docs/create-a-new-react-app.html
21 | Framer Motion: https://www.framer.com/motion/
22 |
23 | ### Video Tutorial
24 |
25 | You can see my youtube video for this project in [here](https://youtu.be/nr3U-RpaQuM)
26 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "custom-cursor",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.14.1",
7 | "@testing-library/react": "^13.0.0",
8 | "@testing-library/user-event": "^13.2.1",
9 | "framer-motion": "^6.3.1",
10 | "react": "^18.0.0",
11 | "react-dom": "^18.0.0",
12 | "react-scripts": "5.0.1",
13 | "web-vitals": "^2.1.0"
14 | },
15 | "scripts": {
16 | "start": "react-scripts start",
17 | "build": "react-scripts build",
18 | "test": "react-scripts test",
19 | "eject": "react-scripts eject"
20 | },
21 | "eslintConfig": {
22 | "extends": [
23 | "react-app",
24 | "react-app/jest"
25 | ]
26 | },
27 | "browserslist": {
28 | "production": [
29 | ">0.2%",
30 | "not dead",
31 | "not op_mini all"
32 | ],
33 | "development": [
34 | "last 1 chrome version",
35 | "last 1 firefox version",
36 | "last 1 safari version"
37 | ]
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from 'react';
2 | import { motion } from 'framer-motion';
3 | import './App.css';
4 |
5 | function App() {
6 | const [mousePosition, setMousePosition] = useState({
7 | x: 0,
8 | y: 0
9 | });
10 | const [cursorVariant, setCursorVariant] = useState("default");
11 |
12 |
13 | useEffect(() => {
14 | const mouseMove = e => {
15 | setMousePosition({
16 | x: e.clientX,
17 | y: e.clientY
18 | })
19 | }
20 |
21 | window.addEventListener("mousemove", mouseMove);
22 |
23 | return () => {
24 | window.removeEventListener("mousemove", mouseMove);
25 | }
26 | }, []);
27 |
28 | const variants = {
29 | default: {
30 | x: mousePosition.x - 16,
31 | y: mousePosition.y - 16,
32 | },
33 | text: {
34 | height: 150,
35 | width: 150,
36 | x: mousePosition.x - 75,
37 | y: mousePosition.y - 75,
38 | backgroundColor: "yellow",
39 | mixBlendMode: "difference"
40 | }
41 | }
42 |
43 | const textEnter = () => setCursorVariant("text");
44 | const textLeave = () => setCursorVariant("default");
45 |
46 |
47 | return (
48 |