npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-multi-cursor

v0.0.13

Published

Add multiple cursors to your react application.

Downloads

25

Readme

React Multi Cursor

Add one or more custom cursors to your react app.

Check it live here.

Features

  • Create a single or multiple cursors
  • Style each cursor individually
  • Position them as you wish
  • Add smooth easing to cursors

Installation

With npm npm install react-multi-cursor

With yarn yarn add react-multi-cursor

Usage

To add your custom cursors create an array of objects and pass it through the cursors prop

import ReactMultiCursor from "react-multi-cursor"

const cursors = [
  {
    angle: 0, // mouse position
  },
  {
    angle: 180, // opposite
  },
  ...
]

const App = () => (
  <ReactMultiCursor cursors={cursors} />
)

Available props

cursors | array | required

Array of objects to display cursors.

  • angle (required) Angle of rotation. 0 is on mouse position, 180 is the opposite of mouse position.
  • style Style object to pass to each cursor element - to remove default styles pass an empty object
  • className CSS class to pass to each cursor element - default: 'multi-cursor'
const cursors = [
  {
    angle: 0,
    style: { backgroundColor: 'red' },
    className: 'myCustomCursor'
  }
]

<ReactMultiCursor cursors={cursors} />

smoothness | number | optional | default: 1

Smoothness of cursor position.

Default is 1 and it will not add any smooth to the cursor.

<ReactMultiCursor cursors={cursors} smoothness={0.2} />

throttleDelay | number | optional | default: 10

Mousemove event throttle delay

<ReactMultiCursor cursors={cursors} throttleDelay={100} />

hoverItemClassName | string | optional | default: "multi-cursor-item"

ClassName to trigger hover state.

It will add multi-cursor--hover className on each cursor by default.

<div className="hover-item">Hover</div>
<ReactMultiCursor cursors={cursors} hoverItemClassName="hover-item" />

hoverCursorClassName | string | optional | default: "multi-cursor--hover"

Hover state className on each cursor.

It will be added whenever a cursor hover over .multi-cursor-item

<ReactMultiCursor
  cursors={cursors}
  hoverCursorClassName="myCustomCursor--hover"
/>

onUpdate | function | optional

Callback called after each position update. The argument will give you an array of cursors with their current position.

<ReactMultiCursor
  cursors={cursors}
  onUpdate={(c) => {
    console.log("cursors", c)
  }}
/>

onClick | function | optional

Click event callback. The arguments will give you the original event and the array of cursors with their position.

<ReactMultiCursor
  cursors={cursors}
  onClick={(e, c) => {
    console.log("event", e)
    console.log("cursors", c)
  }}
/>

onTouchStart | function | optional

Touch start event callback. The arguments will give you the original event and the array of cursors with their position.

<ReactMultiCursor
  cursors={cursors}
  onTouchStart={(e, c) => {
    console.log("event", e)
    console.log("cursors", c)
  }}
/>

onTouchMove | function | optional

Touch move event callback. The arguments will give you the original event and the array of cursors with their position.

<ReactMultiCursor
  cursors={cursors}
  onTouchMove={(e, c) => {
    console.log("event", e)
    console.log("cursors", c)
  }}
/>

onTouchCancel | function | optional

Touch cancel event callback. The arguments will give you the original event and the array of cursors with their position.

<ReactMultiCursor
  cursors={cursors}
  onTouchCancel={(e, c) => {
    console.log("event", e)
    console.log("cursors", c)
  }}
/>

onTouchEnd | function | optional

Touch end event callback. The arguments will give you the original event and the array of cursors with their position.

<ReactMultiCursor
  cursors={cursors}
  onTouchEnd={(e, c) => {
    console.log("event", e)
    console.log("cursors", c)
  }}
/>