import Hammer from '@egjs/hammerjs' ; import { State } from '../State' ; import PressGestureHandler from './PressGestureHandler' ; import { isnan , isValidNumber } from './utils' ; import { Config } from './GestureHandler' ; import { HammerInputNames } from './constants' ; class LongPressGestureHandler extends PressGestureHandler { get minDurationMs ( ) : number { return isnan ( this . config . minDurationMs ) ? 251 : this . config . minDurationMs ; } get maxDist ( ) { return isnan ( this . config . maxDist ) ? 9 : this . config . maxDist ; } updateHasCustomActivationCriteria ( { maxDistSq } ) { return ! isValidNumber ( maxDistSq ) ; } getConfig ( ) { if ( ! this . hasCustomActivationCriteria ) { return { shouldCancelWhenOutside : true , maxDistSq : 10 , } ; } return this . config ; } getHammerConfig ( ) { return { ... super . getHammerConfig ( ) , time : this . minDurationMs , } ; } getState ( type ) { return { [ Hammer . INPUT_START ] : State . ACTIVE , [ Hammer . INPUT_MOVE ] : State . ACTIVE , [ Hammer . INPUT_END ] : State . END , [ Hammer . INPUT_CANCEL ] : State . FAILED , } [ type ] ; } } export default LongPressGestureHandler ;