From cefc5a66f2e4971cbcad25b3b2a31422971909b1 Mon Sep 17 00:00:00 2001 From: Martin Kralik Date: Fri, 1 Apr 2016 06:53:08 -0700 Subject: [PATCH] adding coalescing key generation for scroll events Reviewed By: javache Differential Revision: D3092857 fb-gh-sync-id: 79a1e235d97d484ee7247f17250759b161bc2c07 fbshipit-source-id: 79a1e235d97d484ee7247f17250759b161bc2c07 --- React/Views/RCTScrollView.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/React/Views/RCTScrollView.m b/React/Views/RCTScrollView.m index eeb00ab0a79..5440084e6ad 100644 --- a/React/Views/RCTScrollView.m +++ b/React/Views/RCTScrollView.m @@ -392,6 +392,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) NSMutableArray *_cachedChildFrames; BOOL _allowNextScrollNoMatterWhat; CGRect _lastClippedToRect; + uint16_t _coalescingKey; + RCTScrollEventType _lastEmittedEventType; } @synthesize nativeScrollDelegate = _nativeScrollDelegate; @@ -925,11 +927,15 @@ RCT_SET_AND_PRESERVE_OFFSET(setScrollIndicatorInsets, scrollIndicatorInsets, UIE scrollView:(UIScrollView *)scrollView userData:(NSDictionary *)userData { + if (_lastEmittedEventType != type) { + _coalescingKey++; + _lastEmittedEventType = type; + } [_eventDispatcher sendScrollEventWithType:type reactTag:reactTag scrollView:scrollView userData:userData - coalescingKey:0]; + coalescingKey:_coalescingKey]; } @end