@solid-primitives/event-props
v0.2.7
Published
Primitive to manage events in a reactive way.
Downloads
5,023
Readme
@solid-primitives/event-props
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