1.0.0 • Published 3 years ago
gsap-cursor v1.0.0
🦄 Cursor.js
Customize mouse cursor completely with JS, powered by GSAP.
Key features:
- Customize native cursor with JS.
- Update cursor style when hover on specific elements.
Demo 👉 https://cursorjs.netlify.app

Installation
From NPM
npm i gsap-cursorimport {Cursor} from "gsap-cursor";
new Cursor();From CDN
<!-- UNPKG (GSAP included) -->
<script src="https://unpkg.com/gsap-cursor/dist/gsap-cursor.min.js"></script>new Cursor();Configuration
const config = {
speed: .2, // the smaller the slower
className: '', // custom class for the cursor
style: {
width: '15px',
height: '15px',
borderRadius: '50%',
backgroundColor: `rgba(0, 0, 0, .5)`
}
};
const cursor = new Cursor(config);Custom style on hover
const config = {
speed: .2, // the smaller the slower
className: '', // custom class for the cursor
style: {
width: '15px',
height: '15px',
borderRadius: '50%',
backgroundColor: `rgba(0, 0, 0, .5)`
},
hover: [
// text
{
selector: 'p',
in: {
borderRadius: 0,
width: '2px',
height: '30px',
backgroundColor: 'rgba(0,0,0,.3)'
}
},
// clickable elements
{
selector: 'a, button',
magnetic: true,
in: data => {
gsap.to(data.cursor, {
width: data.hoverTarget.offsetWidth + 6,
height: data.hoverTarget.offsetHeight + 4,
borderRadius: '4px',
backgroundColor: 'rgba(0,0,0,.05)'
});
}
}
]
};
const cursor = new Cursor(config);Deployment
Development
npm installnpm run devProduction
npm run buildPublish to NPM
npm run publishLicense
Copyright (c) 2022 Minh-Phuc Bui