1.0.0 • Published 2 years ago

gsap-cursor v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

🦄 Cursor.js

Customize mouse cursor completely with JS, powered by GSAP.

npm-version total-download Made in Vietnam jsdelivr license Netlify Status

Key features:

  • Customize native cursor with JS.
  • Update cursor style when hover on specific elements.

Demo 👉 https://cursorjs.netlify.app

Screen Recording 2022-01-23 at 20 44 49

Installation

From NPM

npm i gsap-cursor
import {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 install
npm run dev

Production

npm run build

Publish to NPM

npm run publish

License

MIT License

Copyright (c) 2022 Minh-Phuc Bui

1.0.0

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago