mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 15:45:32 +00:00
fixed coalescing key generation for RCTTouchEvent
Summary:Turns our using the same coalescing key until a person removes all fingers off screen is not ideal. It doesn't work in a case where the first finger starts moving on screen and then a second finger joins it later (almost any pinch gesture), since we would try to coalesce move events from the start when only one finger was touching screen with events where two fingers were moving on screen. That doesn't work and results in a crash. I've changed the logic for generating the coalescing key in order to prevent this. We no longer have a single key for a single gesture, but we change the key each time amount of fingers increases ("touchStart") or decreases ("touchEnd"). Reviewed By: javache Differential Revision: D3138275 fb-gh-sync-id: c32230ba401819fe3a70d1752b286d849520be89 fbshipit-source-id: c32230ba401819fe3a70d1752b286d849520be89
This commit is contained in:
parent
a10c1b5a30
commit
8efc098646
@ -234,7 +234,6 @@ static BOOL RCTAnyTouchesChanged(NSSet<UITouch *> *touches)
|
||||
{
|
||||
// If gesture just recognized, send all touches to JS as if they just began.
|
||||
if (self.state == UIGestureRecognizerStateBegan) {
|
||||
_coalescingKey++;
|
||||
[self _updateAndDispatchTouches:_nativeTouches.set eventName:@"topTouchStart" originatingTime:0];
|
||||
|
||||
// We store this flag separately from `state` because after a gesture is
|
||||
@ -253,6 +252,7 @@ static BOOL RCTAnyTouchesChanged(NSSet<UITouch *> *touches)
|
||||
{
|
||||
[super touchesBegan:touches withEvent:event];
|
||||
|
||||
_coalescingKey++;
|
||||
// "start" has to record new touches before extracting the event.
|
||||
// "end"/"cancel" needs to remove the touch *after* extracting the event.
|
||||
[self _recordNewTouches:touches];
|
||||
@ -278,6 +278,7 @@ static BOOL RCTAnyTouchesChanged(NSSet<UITouch *> *touches)
|
||||
{
|
||||
[super touchesEnded:touches withEvent:event];
|
||||
|
||||
_coalescingKey++;
|
||||
if (_dispatchedInitialTouches) {
|
||||
[self _updateAndDispatchTouches:touches eventName:@"touchEnd" originatingTime:event.timestamp];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user