Cursor
The @lqv/cursor
package lets you record your cursor moving around on the screen. The easiest way to get started is to clone the demo:
The package has the following entrypoints:
- npm
- yarn
- pnpm
npm install @lqv/cursor
yarn add @lqv/cursor
pnpm add @lqv/cursor
@lqv/cursor
cursorReplay()
Move an image along a recorder cursor path.
Parameters
Takes a single object with the following keys:
align?: string | [number, number]
Alignment of image. Given by a pair[x, y]
with0 <= x, y <= 1
, corresponding to the point (100x
%,100y
%) of the way along the image. Also accepts aliases"center"
for[0.5, 0.5]
,"top right"
for[0, 1]
, etc.data: ReplayData<[number, number]>
Cursor data to replay.end?: number = start + length(data)
When the cursor should disappear.playback: Playback
Playback to sync with.start?: number = 0
When the cursor should first appear.target: HTMLElement
Element to sync with.infoThe cursor's position is stored as a left/top percentage relative to
target.offsetParent
. Therefore, to display correctly, the aspect ratio oftarget.offsetParent
must remain constant (between recording and replaying), andtarget.offsetParent
must have a nonzero height and width.
Return value
Returns an unsubscription function.
@lqv/cursor/react
<Cursor/>
Move an image along a recorder cursor path. React version of cursorReplay()
.
Props
align?: string | [number, number]
Alignment of image. Given by a pair[x, y]
with0 <= x, y <= 1
, corresponding to the point (100x
%,100y
%) of the way along the image. Also accepts aliases"center"
for[0.5, 0.5]
,"top right"
for[0, 1]
, etc.data: ReplayData<[number, number]>
Cursor data to replay.end: number
When the cursor should disappear. Optional, defaults tostart + length(data)
.src: string
Src of cursor image.start: number
When the cursor should first appear. Optional, defaults to 0.
@lqv/cursor/recording
CursorRecorder
Properties
target: HTMLElement = document.body
Container element for recording.
CursorRecording
Cursor recording plugin. Pass to <RecordingControl>
.