npm.io
0.3.1 • Published 1 year ago

@solid-primitives/event-props

Licence
MIT
Version
0.3.1
Deps
0
Size
6 kB
Vulns
0
Weekly
0
Stars
1.5K

Solid Primitives Event Props

@solid-primitives/event-props

size size

A helpful primitive that creates the event props and a reactive store with the latest events

Installation

npm install @solid-primitives/event-props
# or
yarn add @solid-primitives/event-props

How to use it

createEventProps

Receive the event props and a props with the latest events:

const [events, eventProps] = createEventProps('mousedown', 'mousemove', 'mouseup');

const isMouseDown = createMemo(() => (events.mousedown?.ts ?? 0) > (events.mouseup?.ts ?? 1));

createEffect(() => {
  if (isMouseDown()) {
    console.log(events.mousemove?.clientX, events.mousemove?.clientY);
  }
})

<div {...eventProps}>Click and drag on me</div>

Demo

TODO

Changelog

See CHANGELOG.md

Keywords