Summary: Minor release fixing TypeScript export.
import { useGesture } from 'react-use-gesture'
should now be functional
Summary: important release introducing trackpad gestures. The library has been fully rewritten in TypeScript with some important refactoring involved.
- Support for for zoom and rotate on trackpad for Safari.
- Support for zoom on trackpad for Chrome and Firefox.
- Added
buttons
attribute to pointer-related gesture state. - Added
origin
attribute to pinch gesture. - Accepts support for genuine element handlers (such as
onMouseDown
) to prevent overriding when passing the prop directly to the bound component.
- Drag gesture will interrupt if a move event has no button pressed (that could happen if triggering a right click) and then moving the mouse around.
config
object must be passed as a second argument.
Summary: minor release.
- Added
onHover
in Typescript definitions.
Summary: release updating dev dependencies and fixing minor bugs.
-
Fixed a bug where
onDragEnd
oronPinchEnd
would be called too late when the gestures are canceled #52 -
Wheel and scroll gestures are also returning modifier keys.
Summary (recap from betas): major release introducing additional gestures on top of drag: pinch, scroll, wheel, hover and move are now supported. This release is dropping support for high-order and render-props component and can only be used through React hooks 🎣. Therefore react-with-gesture
is now react-use-gesture
.
-
Support for pinch, scroll, wheel, move and hover events. Each gesture has now an
active
boolean prop that lets you know whether it’s currently active. State also includedragging
,moving
,scrolling
,wheeling
,pinching
, andhovering
booleans so that you can know within a gesture handler the running state of all others. -
Support for dynamically enabling or disabling gestures in the
config
object:useGesture(actions, { enabled: false })
oruseGesture(actions, { drag: true, move: false })
if you want to disable or enable gestures individually. -
You can now add a gesture to a dom node or the
window
(useful for scroll) with thedomTarget
config prop. In that case you shouldn’t spreadbind
in a component but use theuseEffect
hook that will take care of adding and removing listeners:
const bind = useGesture({ onScroll: () => {...} }, { domTarget: window })
React.useEffect(bind, [bind])
-
Individual per-axis velocity has been added in gesture state props as
vxvy: vector2
. -
There's a new
transform
config prop that can be passed to change the wayx
andy
are calculated (useful for canvas which inverts axis compared to the dom). -
Experimental support for pointer events through config:
{ event : { pointerEvents: true } }
. -
Tests with
react-testing-library
. -
Travis integration.
- State and props are no longer frozen, meaning you can now use state or props values from your component inside your handler and they will be up to date.
const [dragCount, setDragCount] = useState(0)
const bind = useGesture({
onDrag: ({ first }) => {
console.log(dragCount) //<-- count will be up to date
if (first) setDragCount(dragCount + 1)
},
})
- Readme should be clearer (hopefully)!
-
HOC and render-props component support has been dropped. Hooks usage is enforced, therefore this package requires React 16.8+.
-
Default syntax
[bind, props] = useGesture()
has been dropped in favor ofbind = useGesture({ onDrag: () => {...} })
which is more performance-effective since it doesn’t render on each frame. -
onAction
prop is now an alias ofonDrag
but should be avoided as its support could be dropped at any time. Subsequently,onUp
andonDown
have been dropped, and there's nowon[Gesture]Start
andon[Gesture]End
handlers. -
config
object should now be passed as a second argument.
// from this:
useGesture({ onAction: () => {}, config })
// to this:
useGesture({ onDrag: () => {} }, { ...config })
touch
andmouse
config props are dropped.
Summary: Removed default export to match TypeScript import in JS.
- You should now import useGesture as follows:
import { useGesture } from 'react-use-gesture'
Summary: Minor bug fixing.
first
was still set totrue
when the gesture finished if no movement was registered.
Summary: Minor bug fixing.
NaN
orInfinity
velocities are now set to0
.
Summary: bug fixing and more tests.
domTarget
now accepts refs.- Tests are now testing
domTarget
. - Tests are now testing
bind
passing arguments.
onMoveEnd
shouldn't fire if state isn't moving (ieonLeave
was triggered).- Performance optimizations were removed as they were conflicting with passing args to
bind
.
Summary: bug fixing and added tests!
-
Tests have been added with
react-testing-library
: they still throw a warning about some tests not being wrapped inact(...)
but this is probably because of async debouncing in move, scroll, wheel events and RAF forcancel
in drag and pinch. -
Added Travis integration.
- Now using
dtslint
for Typescript definitions and tests.
-
first
was always returning true and this is no longer the case. -
active
wasn't set totrue
when moving inonMove
. -
Added
active
set tofalse
onmouseLeave
foronHover
. This might not be a good idea though.
Summary: major release introducing additional gestures on top of drag: pinch, scroll, wheel, hover and move are now supported. This release is dropping support for high-order and render-props component and can only be used through React hooks 🎣. Therefore react-with-gesture
is now react-use-gesture
.
-
Support for pinch, scroll, wheel, move and hover events. Each gesture has now an
active
boolean prop that lets you know whether it’s currently active. State also includedragging
,moving
,scrolling
,wheeling
,pinching
, andhovering
booleans so that you can know within a gesture handler the running state of all others. -
Support for dynamically enabling or disabling gestures in the
config
object:useGesture(actions, { enabled: false })
oruseGesture(actions, { drag: true, move: false })
if you want to disable or enable gestures individually. -
You can now add a gesture to a dom node or the
window
(useful for scroll) with thedomTarget
config prop. In that case you shouldn’t spreadbind
in a component but use theuseEffect
hook that will take care of adding and removing listeners:
const bind = useGesture({ onScroll: () => {...} }, { domTarget: window })
React.useEffect(bind, [bind])
-
Individual per-axis velocity has been added in gesture state props as
vxvy: vector2
. -
There's a new
transform
config prop that can be passed to change the wayx
andy
are calculated (useful for canvas which inverts axis compared to the dom). -
Experimental support for pointer events through config:
{ event : { pointerEvents: true } }
.
-
useGesture
returned value is now cached which should produce better performance in case of frequent renders produced by external factors (i.e. prop change). -
State and props are no longer frozen, meaning you can now use state or props values from your component inside your handler and they will be up to date.
const [dragCount, setDragCount] = useState(0)
const bind = useGesture({
onDrag: ({ first }) => {
console.log(dragCount) //<-- count will be up to date
if (first) setDragCount(dragCount + 1)
},
})
- Readme should be clearer (hopefully)!
-
HOC and render-props component support has been dropped. Hooks usage is enforced, therefore this package requires React 16.8+.
-
Default syntax
[bind, props] = useGesture()
has been dropped in favor ofbind = useGesture({ onDrag: () => {...} })
which is more performance-effective since it doesn’t render on each frame. -
onAction
prop is now an alias ofonDrag
but should be avoided as its support could be dropped at any time. Subsequently,onUp
andonDown
have been dropped, and there's nowon[Gesture]Start
andon[Gesture]End
handlers. -
config
object should now be passed as a second argument.
// from this:
useGesture({ onAction: () => {}, config })
// to this:
useGesture({ onDrag: () => {} }, { ...config })
touch
andmouse
config props are dropped.