Gathering detailed insights and metrics for react-cursor-position
Gathering detailed insights and metrics for react-cursor-position
Gathering detailed insights and metrics for react-cursor-position
Gathering detailed insights and metrics for react-cursor-position
react-input-position
A React component that decorates it's children with mouse/touch position tracking, a status toggle fired by click/gesture events, and more.
react-cursor-position-updated
Made for higher react verions 18 and above
kevinseghetti-react-cursor-position
branched from https://github.com/dan-lee/react-cursor-position/tree/patch-1. A React component that decorates its children with touch and mouse cursor coordinates, plotted relative to itself.
@kevinseghetti/react-cursor-position
branched from https://github.com/dan-lee/react-cursor-position/tree/patch-1. A React component that decorates its children with touch and mouse cursor coordinates, plotted relative to itself.
A React component that decorates its children with mouse and touch coordinates relative to itself.
npm install react-cursor-position
Typescript
Module System
Node Version
NPM Version
95.6
Supply Chain
100
Quality
75.2
Maintenance
100
Vulnerability
100
License
Stop Touch Move Propagation After Activation
Published on 30 Sept 2018
V3.0.2 - Do not declare isReactComponent
Published on 08 Sept 2018
v3.0.0 - Introduce Activation by Tap and Click
Published on 02 Sept 2018
Introduce Reset Method
Published on 09 Jun 2018
Refactor + Update Dependencies
Published on 17 May 2018
Correct Constants Import Path
Published on 28 Feb 2018
JavaScript (89.54%)
HTML (8.99%)
CSS (1.47%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
10,219,869
Last Day
6,633
Last Week
29,044
Last Month
121,167
Last Year
1,884,951
143 Stars
90 Commits
35 Forks
1 Watching
4 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
3.0.3
Package Id
react-cursor-position@3.0.3
Size
20.52 kB
NPM Version
6.4.1
Node Version
9.10.0
Publised On
30 Sept 2018
Cumulative downloads
Total Downloads
Last day
-1.1%
6,633
Compared to previous day
Last week
-11.5%
29,044
Compared to previous week
Last month
15.3%
121,167
Compared to previous month
Last year
-15.2%
1,884,951
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
Found 1/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
169 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