Package Exports
- react-cursor-position
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-cursor-position) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-cursor-position
A React component that decorates its children with mouse cursor coordinates, plotted relative to itself.
Status
Demo
The react-image-magnify project depends on this package for mouse coordinate observation. Please have a look at the react-image-magnify demo to see this package in action.
Related Project
For touch position tracking, see react-touch-position. It has a similar architecture and interface.
Installation
npm install --save react-cursor-positionUsage
Intended as a primitive for composing features that require notification of mouse cursor position status.
<ReactCursorPosition>
<ChildComponentOne/>
<ChildComponentTwo/>
</ReactCursorPosition>ReactCursorPosition wraps its children in a div, which mouse cursor position is plotted relative to.
Each child component will receive a prop named cursorPosition, which
has the following structure.
{
x: Number,
y: Number
}props API
className : String - Optionally provide a CSS class to be applied to the div rendered by react-cursor-position.
style : Object - Optionally provide a style object to be applied to the div rendered by react-cursor-position.
onCursorPositionChanged : Function - Optionally provide a function that will be called when the mouse cursor position changes.
Function will receive cursorPosition object as parameter.
shouldDecorateChildren : Boolean - Defaults to true. Optionally suppress cursorPosition decoration of child components by
setting this prop false.
Support
Please open an issue.
Development
git clone https://github.com/ethanselzer/react-cursor-position.git
cd react-cursor-position
npm installSee available commands:
npm runContributing
Please contribute using Github Flow. Create a branch, add commits, and open a pull request.
License
MIT