-
Notifications
You must be signed in to change notification settings - Fork 318
Closed
Description
I modified a local version of react-with-gesture to return a simple distance between two fingers
const initialState = {
// [Distance, Scale]
pinch: [0, 1],
}
handleDown() {
const newProps {
{...}
pinch: [0, state.pinch[1]],
}
}
handleMove() {
// Get the current pinch distance from touch event
const pinchDistance = (() => {
if (event.touches && event.touches.length === 2) {
const [finger1, finger2] = event.touches;
return Math.hypot(
finger1.pageX - finger2.pageX,
finger1.pageY - finger2.pageY
);
}
return 0;
})();
// Compare to previous pinch distance, find delta
const pinchDelta = pinchDistance - state.pinch[0];
{...}
return {
{...},
pinch: [pinchDistance, pinchScale]
}
}
I'm using this for calculating a pinch/zoom scale(x)
factor. While I'd like to see this lib support two finger events, what I've got feels really specific to my usecase.
What would/should the api look like if it had handlers/events specific to two finger gestures?
dotlouis
Metadata
Metadata
Assignees
Labels
No labels