V2 to V3
[BREAKING CHANGE] Drop support for 'both'
option in detect
param
'both'
option in detect
paramReturning both mouse and touch handlers as a hook result caused unintended edge cases on touch devices that emulated clicks. Therefore 'both'
value was removed and hook is now using 'pointer'
as a default value for detect
param.
This also enables to support more type of events in the future.
Pointer events should be sufficient replacement for 'both'
option, but you can also programmatically detect if current device support touch events and set proper detect
value based on that.
Before
After
[BREAKING CHANGE] Typings and param values
TypeScript's typings were refactored to use more consistent and precise names. Also changed callback reason values (see LongPressEventReason
)
Changed generics order from
useLongPress<Target, Callback, Context>
touseLongPress<Target, Context, Callback>
Renamed
LongPressDetectEvents
enum toLongPressEventType
LongPressDetectEvents.MOUSE
->LongPressEventType.Mouse
LongPressDetectEvents.TOUCH
->LongPressEventType.Touch
Added
LongPressEventType.Pointer
Renamed
LongPressEventReason
enum toLongPressCallbackReason
LongPressEventReason.CANCELED_BY_MOVEMENT
('canceled-by-movement') ->LongPressCallbackReason.CancelledByMovement
('cancelled-by-movement')LongPressEventReason.CANCELED_BY_TIMEOUT
('canceled-by-timeout') ->LongPressCallbackReason.CancelledByRelease
('cancelled-by-release')
Removed
Coordinates
typeRenamed
EmptyObject
type toLongPressEmptyHandlers
Renamed
CallableContextResult
type toLongPressResult
Renamed
LongPressResult
type toLongPressHandlers
Added mouse and touch handlers types -
LongPressMouseHandlers
andLongPressTouchHandlers
Last updated