Fix touch gestures cancelling, backward flicks, and late onCommit
- Only the host's own lostpointercapture cancels a gesture. Taking capture makes the touched child lose its implicit touch capture, and that bubbling event was cancelling every touch gesture immediately. - A flick at least commitVelocity fast now decides by its direction: backward cancels even past the distance threshold, forward commits. Slower releases still decide by distance. - Pointer-up finishes an already-begun operation without awaiting, so onCommit runs inside the pointer-up event, where iOS still allows haptics, audio, and clipboard writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Faarh2Ts6StJPcz2mRiHiR
This commit is contained in:
@@ -73,17 +73,22 @@ export const DEFAULT_COMMIT_THRESHOLD = 0.36;
|
||||
*/
|
||||
export const DEFAULT_COMMIT_VELOCITY = 0.3;
|
||||
|
||||
/** Decide a release outcome from explicit options or progress/velocity. */
|
||||
/**
|
||||
* Decide a release outcome from explicit options, or from velocity and
|
||||
* progress: a flick at least `commitVelocity` fast decides by its direction,
|
||||
* forward committing and backward cancelling, regardless of distance. Slower
|
||||
* releases commit once progress reaches `commitThreshold`.
|
||||
*/
|
||||
export const shouldCommit = (
|
||||
operation: MutableOriginOperation,
|
||||
options: OriginFinishOptions,
|
||||
): boolean => {
|
||||
if (options.commit !== undefined) return options.commit;
|
||||
const { commitThreshold, commitVelocity } = operation.choreography;
|
||||
return (
|
||||
operation.progress >= (commitThreshold ?? DEFAULT_COMMIT_THRESHOLD) ||
|
||||
operation.velocity >= (commitVelocity ?? DEFAULT_COMMIT_VELOCITY)
|
||||
);
|
||||
const flick = commitVelocity ?? DEFAULT_COMMIT_VELOCITY;
|
||||
if (operation.velocity >= flick) return true;
|
||||
if (operation.velocity <= -flick) return false;
|
||||
return operation.progress >= (commitThreshold ?? DEFAULT_COMMIT_THRESHOLD);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user