1.2.1 • Published 3 years ago

react-cursors v1.2.1

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

npm.io npm.io react' (1) 1

Currently we have a few cursors ready for you to use, you may also customize them to your liking and contribute to this repo ✨

Installation

npm i react-cursors

Usage

Import the component

import { CircleCursor } from 'react-cursors'

Use it

<CircleCursor 
        safeBoundaryX="1000"
        safeBoundaryY="700"
        initial={{
                dotSize:"2rem",
                circleSize:"5rem",
                borderStyle:"dotted",
                color:"white",
                borderWidth:"3px",
                circleDay:"0.1s",
                dotDelay:"0.05s"
        }}

        hover={{
                dotSize:"0rem",
                circleSize:"10rem",
                borderStyle:"dotted",
                color:"white",
                borderWidth:"3px",
                circleDay:"0.1s",
                dotDelay:"0.05s"
        }}
/>

Props provided in the initial will be the initial styles of the cursor, and the props provided in the hover will be the styles of cursor when the cursor hovers over an element with class 'hover-detect'.

If you want to use default styling, or no hover elements then you will have to keep the component as :

<CircleCursor initial={{}} hover={{}} />

Further, it is always recommeded to use lazy loading while importing the component, to avoid any DOM related problems.

Problems faced without lazy loading can lead to bugs like, hover styles not getting activated when cursors hovers over elements having class 'hover-detect'

import React, { Suspense } from "react"; // we also need to import suspense

const CircleCursor = React.lazy(() => import('react-cursors').then(module => ({ default: module.CircleCursor }))) ;

And using it like :

     <div> 
          <Components />
          <Suspense fallback={<div>Loading ... </div>}>
            <CircleCursor initial={{circleSize:'30px',dotSize:'6px',color:'white'}} hover={{circleSize:'50px',dotSize:'0px',color:'white'}}/>
          </Suspense> 
      </div>

Element attributes

All the attributes are optional, incase values are not provided, the default values will be used

Common for all

AttributeValuesDescription
safeBoundaryXstringUsed to set the boundary of the cursor along the x-axis, helpful inorder to prevent overflow
safeBoundaryYstringUsed to set the boundary of the cursor along the y-axis, helpful inorder to prevent overflow

Circle Cursor

AttributeValuesDescription
dotSizestringUsed to set the size of the inner dot
circleSizestringUsed to set the size of the outer circle
borderStylestringUsed to set the border style of the outer circle
colorstringUsed to set the color of the outer circle and inner dot
borderWidthstringUsed to set the border width of the outer circle
circleDelaystringUsed to set the delay of the outer circle
dotDelaystringUsed to set the delay of the inner circle

Emoji Cursor

AttributeValuesDescription
sizestringUsed to set the size of the emoji
delaystringUsed to set the delay of the emoji
emojistringUsed to set the emoji

Image Cursor

Experimental âš 

AttributeValuesDescription
widthstringUsed to set the width of the image
heightstringUsed to set the height of the image
delaystringUsed to set the delay of the image
urlstringUrl of the image


Project Maintainers ğŸ›