JSPM

solid-gesture

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 774
  • Score
    100M100P100Q99817F
  • License MIT

👇 Bread n butter utility for component-tied mouse/touch gestures in Solid.

Package Exports

  • solid-gesture

Readme

solid-gesture

npm (tag) npm bundle size NPM

solid-gesture is a port of @use-gesture/react which lets you bind richer mouse and touch events to any component or view. With the data you receive, it becomes trivial to set up gestures, and often takes no more than a few lines of code.

You can use it stand-alone, but to make the most of it you should combine it with an animation library like solid-spring, though you can most certainly use any other.

Installation

pnpm add solid-gesture

Usage

import { createSpring, animated } from 'solid-spring'
import { useDrag } from 'solid-gesture'

function PullRelease() {
  const [coords, setCoords] = createSignal({
    x: 0,
    y: 0
  })

  const styles = createSpring(() => ({
    x: coords().x,
    y: coords().y 
  }))

  // Bind it to a component
  return <animated.div {...bind()} style={styles()} />
}

License

MIT