11import React from 'react' ;
22import objectAssign from 'object-assign' ;
3- import propTypes from './propTypes' ;
3+ import { propTypes , defaultProps } from './propTypes' ;
44import compareProps from './compareProps' ;
55import mergeAndExtractProps from './mergeAndExtractProps' ;
66import {
@@ -32,6 +32,7 @@ import {
3232
3333class Interactive extends React . Component {
3434 static propTypes = propTypes ;
35+ static defaultProps = defaultProps ;
3536
3637 constructor ( props ) {
3738 super ( props ) ;
@@ -285,7 +286,9 @@ class Interactive extends React.Component {
285286 // add onTouchMove handler to passThroughProps if it's required
286287 if (
287288 deviceHasTouch &&
288- ( mergedProps . touchActiveTapOnly || mergedProps . onTouchMove )
289+ ( mergedProps . touchActiveTapOnly ||
290+ mergedProps . onLongPress ||
291+ mergedProps . onTouchMove )
289292 ) {
290293 passThroughProps . onTouchMove = this . handleEvent ;
291294 }
@@ -950,14 +953,17 @@ class Interactive extends React.Component {
950953
951954 // if going from no touch to touch, set touchTapTimer
952955 if ( newTouchDown ) {
956+ e . persist ( ) ;
953957 this . manageSetTimeout (
954958 'touchTapTimer' ,
955959 ( ) => {
956- // if the timer finishes then fire a touchtapcancel event to cancel the tap,
960+ // if the timer finishes then call onLongPress callback and
961+ // fire a touchtapcancel event to cancel the tap,
957962 // because this goes through handleEvent, updateState will be called if needed
963+ this . p . props . onLongPress && this . p . props . onLongPress ( e ) ;
958964 this . handleEvent ( dummyEvent ( 'touchtapcancel' ) ) ;
959965 } ,
960- 600 ,
966+ this . p . props . tapTimeCutoff ,
961967 ) ;
962968 }
963969
@@ -973,8 +979,9 @@ class Interactive extends React.Component {
973979 if ( extraTouches ( ) )
974980 return this . handleTouchEvent ( { type : 'touchtapcancel' } ) ;
975981
976- // if touchActiveTapOnly prop, check to see if the touch moved enough to cancel tap
977- if ( this . p . props . touchActiveTapOnly ) {
982+ // if touchActiveTapOnly or onLongPress prop,
983+ // check to see if the touch moved enough to cancel tap
984+ if ( this . p . props . touchActiveTapOnly || this . p . props . onLongPress ) {
978985 for ( let i = 0 ; i < e . changedTouches . length ; i ++ ) {
979986 const touch = this . track . touches . points [
980987 e . changedTouches [ i ] . identifier
0 commit comments