import { BaseGestureConfig , ContinousBaseGesture } from './gesture' ; import { ForceTouchGestureConfig , ForceTouchGestureHandlerEventPayload , } from '../ForceTouchGestureHandler' ; import { GestureUpdateEvent } from '../gestureHandlerCommon' ; type ForceTouchGestureChangeEventPayload = { forceChange : number ; } ; function changeEventCalculator ( current , previous ? ) { 'worklet' ; let changePayload ; if ( previous === undefined ) { changePayload = { forceChange : current . force , } ; } else { changePayload = { forceChange : current . force - previous . force , } ; } return { ... current , ... changePayload } ; } export class ForceTouchGesture extends ContinousBaseGesture < ForceTouchGestureHandlerEventPayload , ForceTouchGestureChangeEventPayload > { public config : BaseGestureConfig & ForceTouchGestureConfig = { } ; constructor ( ) { super ( ) ; this . handlerName = 'ForceTouchGestureHandler' ; } minForce ( force ) { this . config . minForce = force ; return this ; } maxForce ( force ) { this . config . maxForce = force ; return this ; } feedbackOnActivation ( value ) { this . config . feedbackOnActivation = value ; return this ; } onChange ( callback ) { this . handlers . changeEventCalculator = changeEventCalculator ; return super . onChange ( callback ) ; } } export type ForceTouchGestureType = InstanceType < typeof ForceTouchGesture > ;