Gathering detailed insights and metrics for kevinseghetti-react-cursor-position
Gathering detailed insights and metrics for kevinseghetti-react-cursor-position
Gathering detailed insights and metrics for kevinseghetti-react-cursor-position
Gathering detailed insights and metrics for kevinseghetti-react-cursor-position
npm install kevinseghetti-react-cursor-position
Typescript
Module System
Node Version
NPM Version
71.8
Supply Chain
99.4
Quality
74.2
Maintenance
100
Vulnerability
100
License
JavaScript (87.78%)
HTML (10.37%)
CSS (1.84%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
8,309
Last Day
1
Last Week
8
Last Month
26
Last Year
91
80 Commits
1 Watching
5 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
3.0.3
Package Id
kevinseghetti-react-cursor-position@3.0.3
Unpacked Size
132.45 kB
Size
20.55 kB
File Count
30
NPM Version
6.9.0
Node Version
10.16.0
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
33.3%
8
Compared to previous week
Last month
225%
26
Compared to previous month
Last year
18.2%
91
Compared to previous year
3
1
26
react-cursor-position is a primitive component for composing UI features that require notification of cursor or touch position changes. Position coordinates are plotted relative to the HTML element rendered by react-cursor-position. react-cursor-position re-renders child components with new position props when the cursor or touch position changes.
See the react-cursor-position demo site.
Experiment with react-cursor-position live on CodePen.
1npm install --save react-cursor-position
If you are upgrading from v2x to v3x please see the release notes
If you are upgrading from v1x to v2x please see the release notes.
1import ReactCursorPosition from 'react-cursor-position'; 2... 3 4<ReactCursorPosition> 5 <YourComponentOne/> 6 <YourComponentTwo/> 7</ReactCursorPosition>
react-cursor-position wraps its children in a div, which mouse and touch position are plotted relative to.
Each child component will receive the following props:
1{ 2 detectedEnvironment: { 3 isMouseDetected: false, 4 isTouchDetected: false, 5 }, 6 elementDimensions: { 7 width: Number, 8 height: Number 9 }, 10 isActive: Boolean, 11 isPositionOutside: Boolean, 12 position: { 13 x: Number, 14 y: Number 15 } 16}
This structure may be customized by implementing mapChildProps
API feature.
The information in detectedEnvironment
is acquired from interaction with this component and will be unset until the first interaction.
All props are optional.
activationInteractionMouse : String - One of INTERACTIONS.HOVER (default), INTERACTIONS.CLICK. Import Interactions like this import ReactCursorPosition, { Interactions } from 'react-cursor-position'
. See examples. for more.
activationInteractionTouch : String - One of INTERACTIONS.PRESS (default), INTERACTIONS.TAP, or INTERACTIONS.TOUCH. Import Interactions like this import ReactCursorPosition, { Interactions } from 'react-cursor-position'
. See examples.
className : String - CSS class name(s) to be applied to the div rendered by react-cursor-position.
hoverDelayInMs : Number - Amount of time, in milliseconds, to delay hover interaction from activating. Defaults to 0.
hoverOffDelayInMs : Number - Amount of time, in milliseconds, to delay hover off interaciton from deactivating. Defaults to 0.
isEnabled : Boolean - Enable or disable cursor position monitoring without remounting. Defaults to true.
mapChildProps : Function - Model child component props to your custom shape.
Function receives one parameter with the signature
{ isActive: Boolean, isPositionOutside: Boolean, position: { x: Number, y: Number } }
.
It should return an object that is compatible with the props interface of your child components.
See example demo.
onActivationChanged : Function - Called when the component is active.
Function receives one parameter with the signature { isActive: Boolean }
.
onPositionChanged : Function - Called when cursor or touch position changes.
Function receives one parameter with the signature { elementDimensions: { width: Number, height: Number }, isPositionOutside: Boolean, position: { x: Number, y: Number } }
.
onDetectedEnvironmentChanged : Function - Called when detected environment (mouse or touch) changes.
Function receives one parameter with the signature { isMouseDetected: Boolean, isTouchDetected: Boolean }
.
pressDurationInMs : Number - Milliseconds delay before press gesture is activated. Defaults to 500.
pressMoveThreshold : Number - Amount of movement, in pixels, allowed during press gesture detection. Defaults to 5.
shouldDecorateChildren : Boolean - Suppress decoration of child components by setting this prop false. Defaults to true.
shouldStopTouchMovePropagation : Boolean - Stop touchmove event bubbling when react-cursor-position is active. Defaults to false.
style : Object - Style to be applied to the div rendered by react-cursor-position.
tapDurationInMs : Number - Max milliseconds allowed for a screen touch to be considered a tap gesture. Defaults to 180.
tapMoveThreshold : Number - Amount of movement, in pixels, allowed during tap gesture detection. Defaults to 5.
reset: Invoking the reset method instructs react-cursor-position to recalculate its position relative to the page.
See API Examples section of the demo site for more.
Please open an issue.
1git clone https://github.com/ethanselzer/react-cursor-position.git 2cd react-cursor-position 3npm install 4npm run build 5cd example 6yarn 7yarn start
If your default browser does not start automatically, open a new browser window and go to localhost:3000
1git clone https://github.com/ethanselzer/react-cursor-position.git 2cd react-cursor-position 3npm install 4npm run #print available commands
The Example Project may be used in development of react-cursor-position.
To rebuild the source automatically when changes are made, run npm run build-watch
.
Please contribute by opening an issue or a pull request.
Thanks to the following community members for opening GitHub Issues and Pull Requests. Your input is very much appreciated!
You are awesome! ✨💫
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
188 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More