@@ -24,6 +24,7 @@ @interface TiUIListView ()
2424@property (nonatomic , readonly ) TiUIListViewProxy *listViewProxy;
2525@property (nonatomic , copy , readwrite ) NSString *searchString;
2626@property (nonatomic , copy , readwrite ) NSString *searchedString;
27+ @property (nonatomic , assign ) CGFloat lastContentOffset;
2728@end
2829
2930static TiViewProxy *FindViewProxyWithBindIdContainingPoint (UIView *view, CGPoint point);
@@ -79,8 +80,8 @@ @implementation TiUIListView {
7980 BOOL isSearched;
8081 UIView *dimmingView;
8182 BOOL isSearchBarInNavigation;
82- int lastVisibleItem;
83- int lastVisibleSection;
83+ NSInteger lastVisibleItem;
84+ NSInteger lastVisibleSection;
8485 BOOL forceUpdates;
8586}
8687
@@ -2011,6 +2012,15 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
20112012 TiUIListSectionProxy *section;
20122013 CGFloat topSpacing = scrollView.contentOffset .y + scrollView.adjustedContentInset .top ;
20132014
2015+ NSString *direction = @" unknown" ;
2016+
2017+ if (self.lastContentOffset > scrollView.contentOffset .y ) {
2018+ direction = @" down" ;
2019+ } else if (self.lastContentOffset < scrollView.contentOffset .y ) {
2020+ direction = @" up" ;
2021+ }
2022+ self.lastContentOffset = scrollView.contentOffset .y ;
2023+
20142024 if ([indexPaths count ] > 0 ) {
20152025 NSIndexPath *indexPath = [self pathForSearchPath: [indexPaths objectAtIndex: 0 ]];
20162026 NSUInteger visibleItemCount = [indexPaths count ];
@@ -2022,6 +2032,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
20222032 [eventArgs setValue: section forKey: @" firstVisibleSection" ];
20232033 [eventArgs setValue: [section itemAtIndex: [indexPath row ]] forKey: @" firstVisibleItem" ];
20242034 [eventArgs setValue: NUMINTEGER (topSpacing) forKey: @" top" ];
2035+ [eventArgs setValue: direction forKey: @" direction" ];
20252036
20262037 if (lastVisibleItem != [indexPath row ] || lastVisibleSection != [indexPath section ] || forceUpdates) {
20272038 // only log if the item changes or forced
@@ -2038,6 +2049,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
20382049 [eventArgs setValue: section forKey: @" firstVisibleSection" ];
20392050 [eventArgs setValue: NUMINTEGER (-1 ) forKey: @" firstVisibleItem" ];
20402051 [eventArgs setValue: NUMINTEGER (topSpacing) forKey: @" top" ];
2052+ [eventArgs setValue: direction forKey: @" direction" ];
20412053 }
20422054 });
20432055 }
@@ -2110,7 +2122,7 @@ - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
21102122- (void )scrollViewWillEndDragging : (UIScrollView *)scrollView withVelocity : (CGPoint)velocity targetContentOffset : (inout CGPoint *)targetContentOffset
21112123{
21122124 if ([[self proxy ] _hasListeners: @" scrolling" ]) {
2113- NSString *direction = nil ;
2125+ NSString *direction = @" unknown " ;
21142126
21152127 if (velocity.y > 0 ) {
21162128 direction = @" up" ;
0 commit comments