An interactive cursor animation system that dynamically changes cursor styling on hover. Features smooth GSAP-powered transitions and responsive cursor tracking.
This project showcases interactive cursor animations using GSAP (GreenSock Animation Platform). The cursor system includes:
- Dynamic Cursor Tracking: Smooth cursor position updates
- Hover State Transitions: Animated cursor changes on element hover
- Custom Cursor Styling: Interactive cursor elements with visual feedback
- Responsive Design: Cursor animations that work across all screen sizes
✨ Advanced Animations
- GSAP timeline-based orchestration
- Smooth staggered transitions
- Expo easing for natural motion
🎨 Modern Design
- Custom typography
- Elegant interactive elements
- Responsive layout
⚡ Performance Optimized
- Vite build tool with Rolldown bundler
- Efficient cursor tracking
- Font preloading and optimization
🛠️ Developer Experience
- ESLint with modern config
- Hot Module Replacement (HMR)
- Module-based architecture
- Animation: GSAP v3.14.2+
- Build Tool: Vite with Rolldown
- Linting: ESLint 9.x
- Package Manager: pnpm
- Module System: ES Modules
.
├── index.html # Main HTML entry point
├── src/
│ ├── scripts/
│ │ └── main.js # Cursor animation logic and DOM manipulation
│ ├── styles/
│ │ └── style.css # Main stylesheet
│ └── assets/ # Project assets
├── public/ # Static assets
├── package.json # Project dependencies
├── eslint.config.mjs # ESLint configuration
└── pnpm-lock.yaml # Dependency lock file
- Node.js 18+ (or latest LTS)
- pnpm 8+ (or npm/yarn)
- Clone the repository:
git clone https://github.com/jmarellanes/gsap__change-cursor-hover--01.git
cd gsap__change-cursor-hover--01- Install dependencies:
pnpm installStart the development server with hot reload:
pnpm devThe site will be available at http://localhost:5173
Create an optimized production build:
pnpm buildPreview the production build locally:
pnpm preview| Script | Purpose |
|---|---|
pnpm dev |
Start development server with HMR |
pnpm build |
Create production-optimized build |
pnpm preview |
Preview production build locally |
pnpm lint |
Run ESLint to check code quality |
pnpm lint:fix |
Auto-fix ESLint issues |
The project uses GSAP to create smooth cursor animations that respond to user interactions:
-
Cursor Initialization
- Custom cursor elements are created and positioned
- Cursor tracking system monitors mouse position
-
Hover Detection
- When hovering over interactive elements, cursor state changes
- Smooth transitions between cursor states using GSAP
-
Animation Execution
- Scale, opacity, and color animations on hover
- Staggered animations for multiple cursor elements
- Smooth return to default state on hover exit
HTML
- Interactive elements with hover triggers
- Custom cursor markup
- Semantic HTML structure
CSS
- Custom cursor styling
- Interactive element styles
- Responsive design patterns
- Animation states
JavaScript
- Cursor tracking logic
- Event listener system for hover states
- GSAP timeline orchestration
- Module-based architecture
Edit CSS variables in src/styles/style.css to customize cursor appearance and interactive elements.
Modify animation timing and easing in src/scripts/main.js:
- Duration values (in seconds)
- Scale and opacity changes
- Easing functions (e.g.,
expo.inOut,power2.out) - Hover target selectors
Add or modify interactive elements by updating the hover target selectors in the JavaScript code.
- Chrome/Edge: Latest 2 versions
- Firefox: Latest 2 versions
- Safari: Latest 2 versions
- Mobile: iOS Safari 12+, Chrome Android
- GSAP uses GPU acceleration for smooth animations
- Cursor tracking is optimized for minimal repaints
- Vite's code splitting minimizes initial bundle size
- Event delegation reduces memory footprint
Cursor not appearing?
- Check browser console for JavaScript errors
- Ensure cursor elements are properly created in the DOM
- Verify CSS visibility is not hidden
Animations not playing?
- Check browser console for JavaScript errors
- Ensure GSAP is properly imported
- Verify hover target selectors match your HTML elements
Build failing?
- Clear node_modules:
rm -rf node_modules && pnpm install - Check pnpm version:
pnpm --version - Review ESLint errors:
pnpm lint
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2026 José Manuel Díaz
Contributions are welcome! Please feel free to submit a Pull Request.
For questions or feedback, please reach out to the project author.
Last Updated: February 2026