1.2.3 • Published 8 months ago

hover-cursor v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Elevate user experience with seamless cursor interactions using hover-cursor, a powerful JS library. Create captivating web interfaces by dynamically crafting bespoke hover cursors that you can style however you need.

⭐️ Features

  • Custom cursor on hover of a target element
  • Small in size
  • Written purely in Typescript
  • Basic and really simple to use
  • Works everywhere, anytime
  • Options for custom functionality
  • Functionality styles, no styling limitations

📦 Getting Started

NPM

npm i hover-cursor

Yarn

yarn add hover-cursor

In your project, import the HoverCursor class like so:

import { HoverCursor } from 'hover-cursor'

Usage:

Note: If the element does not load, make sure you are initialising your HoverCursor after DOMContentLoaded!

new HoverCursor({
    containerQuery: '.floating-video',
    snapPosition: 'R'
})

🙋‍♂️ Example

The following code produces the behaviour displayed in the GIF.

npm.io

import { HoverCursor } from 'hover-cursor'

document.addEventListener('DOMContentLoaded', () => {
    function toggleCursor() {
        console.log('Function called when element is clicked')
    }

    new HoverCursor({
        containerQuery: '.floating-video',
        snapPosition: 'R',
        title: 'Sound On',
        toggledTitle: 'Sound Off',
        toggledFunction: toggleCursor
    })
})
div.hover-cursor {
    width: 7rem;
    height: 7rem;
    border-radius: 50%;
    background: orange;
}

🚀 Documentation & Properties

Documentation is still being made as the libary is still being worked on, but a brief list is below,

ParameterDescriptionDefaultRequired?
containerQueryQuery to locate the target element(s) (the elements that we are watching to be hovered)
snapPositionL, M or R to define the snap position as left, middle or right'M'
customClassAdds a custom class to the cursor''
titleThe title to display in the markup''
toggledTitleThe title to toggle to after the target element (class) is clicked''
iconThe icon src to display in the markup (e.g. ./images/right-arrow.svg)''
toggledIconThe icon to src toggle to after the target element is clicked''
toggledFunctionA callback function after the user clicked for custom functionality on clicknull

🛣️ Roadmap (TODO)

  • Add in option to change the vertical snap position as well as horizontal
  • Optimise build process & update build tools
  • Add option to change the speed of transitions through parameters

💎 Contribution

I extend a warm invitation to developers and enthusiasts to contribute to hover-cursor. Your insights, expertise, and fresh perspectives are invaluable assets that can help me refine and enhance my work.

To get started, please review my guidelines for contributing, which can be found in the CONTRIBUTING.md file. If you encounter any issues, have questions, or need clarification, don't hesitate to reach out.

1.2.0

8 months ago

1.1.9

8 months ago

1.2.3

8 months ago

1.2.2

8 months ago

1.2.1

8 months ago

1.1.8

10 months ago

1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago