@@ -385,6 +385,8 @@ export default class Pressability {
385385 top : number ,
386386 } > = null ;
387387 _touchActivatePosition: ?Readonly < {
388+ locationX : number ,
389+ locationY : number ,
388390 pageX : number ,
389391 pageY : number ,
390392 } > ;
@@ -721,6 +723,7 @@ export default class Pressability {
721723 ! isActivationSignal ( prevState ) && isActivationSignal ( nextState ) ;
722724
723725 if ( isInitialTransition || isActivationTransition ) {
726+ this . _recordTouchActivatePosition ( event ) ;
724727 this . _measureResponderRegion ( ) ;
725728 }
726729
@@ -764,14 +767,18 @@ export default class Pressability {
764767
765768 _activate ( event : GestureResponderEvent ) : void {
766769 const { onPressIn} = this . _config ;
767- const { pageX, pageY} = getTouchFromPressEvent ( event ) ;
768- this . _touchActivatePosition = { pageX, pageY} ;
770+ this . _recordTouchActivatePosition ( event ) ;
769771 this . _touchActivateTime = Date . now ( ) ;
770772 if ( onPressIn != null ) {
771773 onPressIn ( event ) ;
772774 }
773775 }
774776
777+ _recordTouchActivatePosition ( event : GestureResponderEvent ) : void {
778+ const { locationX, locationY, pageX, pageY} = getTouchFromPressEvent ( event ) ;
779+ this . _touchActivatePosition = { locationX, locationY, pageX, pageY} ;
780+ }
781+
775782 _deactivate ( event : GestureResponderEvent ) : void {
776783 const { onPressOut} = this . _config ;
777784 if ( onPressOut != null ) {
@@ -820,16 +827,42 @@ export default class Pressability {
820827 if ( ! left && ! top && ! width && ! height && ! pageX && ! pageY ) {
821828 return ;
822829 }
823- this . _responderRegion = {
830+ const responderRegion = {
824831 bottom : pageY + height ,
825832 left : pageX ,
826833 right : pageX + width ,
827834 top : pageY ,
828835 } ;
836+
837+ const touch = this . _touchActivatePosition ;
838+ if (
839+ touch != null &&
840+ ! this . _isTouchWithinResponderRegion ( touch , responderRegion )
841+ ) {
842+ const correctedLeft = touch . pageX - touch . locationX ;
843+ const correctedTop = touch . pageY - touch . locationY ;
844+ const correctedRegion = {
845+ bottom : correctedTop + height ,
846+ left : correctedLeft ,
847+ right : correctedLeft + width ,
848+ top : correctedTop ,
849+ } ;
850+
851+ if ( this . _isTouchWithinResponderRegion ( touch , correctedRegion ) ) {
852+ this . _responderRegion = correctedRegion ;
853+ return ;
854+ }
855+ }
856+
857+ this . _responderRegion = responderRegion ;
829858 } ;
830859
831860 _isTouchWithinResponderRegion (
832- touch : GestureResponderEvent [ 'nativeEvent' ] ,
861+ touch : Readonly < {
862+ pageX : number ,
863+ pageY : number ,
864+ ...
865+ } > ,
833866 responderRegion : Readonly < {
834867 bottom : number ,
835868 left : number ,
0 commit comments