A simple wrapper React component for locus-dom
npm install locus-dom react # install the dependencies
npm install locus-react
Wrap <Locus/>
around single React HTML element and provide the
onPositionChange
callback.
import Locus from "locus-react";
/* ... */
<Locus
onPositionChange={position =>
// Or do whatever calculation you want.
this.setState({
top: position.top,
left: position.left
})
}
>
<div>I am tracked</div>
</Locus>;
Remember that, as with locus-dom, position
is relative to the top-left corner
of the page.
- Clone the repository
- Run
npm install
andthen npm start
. - The demo is served at port 9001.