@@ -5,6 +5,11 @@ import { readRecordingNumber } from './recording-values.ts';
55const DEFAULT_GESTURE_TRAVEL_DURATION_MS = 250 ;
66const DEFAULT_PINCH_DURATION_MS = 280 ;
77
8+ type SwipeTravelEventOptions = {
9+ referenceFrame ?: ReferenceFrame ;
10+ classifyBackSwipe ?: boolean ;
11+ } ;
12+
813export function buildCanonicalGestureEvents (
914 positionals : string [ ] ,
1015 result : Record < string , unknown > ,
@@ -20,6 +25,9 @@ export function buildCanonicalGestureEvents(
2025 const from = readPoint ( result . from ) ;
2126 const to = readPoint ( result . to ) ;
2227 if ( ! from || ! to ) return [ ] ;
28+ const allowBackSwipeClassification =
29+ ( result . kind === 'pan' || result . kind === 'fling' ) &&
30+ readRecordingNumber ( result . pointerCount ) !== 2 ;
2331 return [
2432 buildSwipeTravelEvent (
2533 tMs ,
@@ -32,7 +40,10 @@ export function buildCanonicalGestureEvents(
3240 result . durationMs ,
3341 DEFAULT_GESTURE_TRAVEL_DURATION_MS ,
3442 ) ,
35- referenceFrame ,
43+ {
44+ referenceFrame,
45+ classifyBackSwipe : allowBackSwipeClassification ,
46+ } ,
3647 ) ,
3748 ] ;
3849 }
@@ -68,9 +79,10 @@ export function buildSwipeTravelEvent(
6879 x2 : number ,
6980 y2 : number ,
7081 durationMs : number ,
71- referenceFrame ?: ReferenceFrame ,
82+ options : SwipeTravelEventOptions = { } ,
7283) : RecordingGestureEvent {
73- const kind = classifySwipeKind ( x , y , x2 , y2 , referenceFrame ) ;
84+ const { referenceFrame, classifyBackSwipe = true } = options ;
85+ const kind = classifyBackSwipe ? classifySwipeKind ( x , y , x2 , y2 , referenceFrame ) : 'swipe' ;
7486 if ( kind === 'back-swipe' ) {
7587 return {
7688 kind,
0 commit comments