-
Starting to learn about use-gesture. Great little tutorial on https://www.youtube.com/watch?v=dBWhAGhw7wM
-
use-gesture tries to make it easy to add new gesture primatives such
onClick
and extend to lots more gestures likeonDrag
andonPinch
so we can create much more native like experiences. -
It works well with react with some out the box hooks. The boilerplate code is quite simple
function MyComponent(){
const myDomRef = useRef()
useGesture({
onDrag: doSomething(event)
domTarget: myDomRef
})
return <div ref={myDomRef}> hey </div>
}
- the library does not do the work to move and transform dom elements, just provides the utilities to do so via the events exposed on the callbacks.
- Within those callback itโs recommended to use an animation lib like Framer or React spring to create interesting touch feedback.