@@ -24,6 +24,7 @@ @interface TiUIListView ()
24
24
@property (nonatomic , readonly ) TiUIListViewProxy *listViewProxy;
25
25
@property (nonatomic , copy , readwrite ) NSString *searchString;
26
26
@property (nonatomic , copy , readwrite ) NSString *searchedString;
27
+ @property (nonatomic , assign ) CGFloat lastContentOffset;
27
28
@end
28
29
29
30
static TiViewProxy *FindViewProxyWithBindIdContainingPoint (UIView *view, CGPoint point);
@@ -79,8 +80,8 @@ @implementation TiUIListView {
79
80
BOOL isSearched;
80
81
UIView *dimmingView;
81
82
BOOL isSearchBarInNavigation;
82
- int lastVisibleItem;
83
- int lastVisibleSection;
83
+ NSInteger lastVisibleItem;
84
+ NSInteger lastVisibleSection;
84
85
BOOL forceUpdates;
85
86
}
86
87
@@ -2011,6 +2012,15 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
2011
2012
TiUIListSectionProxy *section;
2012
2013
CGFloat topSpacing = scrollView.contentOffset .y + scrollView.adjustedContentInset .top ;
2013
2014
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
+
2014
2024
if ([indexPaths count ] > 0 ) {
2015
2025
NSIndexPath *indexPath = [self pathForSearchPath: [indexPaths objectAtIndex: 0 ]];
2016
2026
NSUInteger visibleItemCount = [indexPaths count ];
@@ -2022,6 +2032,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
2022
2032
[eventArgs setValue: section forKey: @" firstVisibleSection" ];
2023
2033
[eventArgs setValue: [section itemAtIndex: [indexPath row ]] forKey: @" firstVisibleItem" ];
2024
2034
[eventArgs setValue: NUMINTEGER (topSpacing) forKey: @" top" ];
2035
+ [eventArgs setValue: direction forKey: @" direction" ];
2025
2036
2026
2037
if (lastVisibleItem != [indexPath row ] || lastVisibleSection != [indexPath section ] || forceUpdates) {
2027
2038
// only log if the item changes or forced
@@ -2038,6 +2049,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
2038
2049
[eventArgs setValue: section forKey: @" firstVisibleSection" ];
2039
2050
[eventArgs setValue: NUMINTEGER (-1 ) forKey: @" firstVisibleItem" ];
2040
2051
[eventArgs setValue: NUMINTEGER (topSpacing) forKey: @" top" ];
2052
+ [eventArgs setValue: direction forKey: @" direction" ];
2041
2053
}
2042
2054
});
2043
2055
}
@@ -2110,7 +2122,7 @@ - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
2110
2122
- (void )scrollViewWillEndDragging : (UIScrollView *)scrollView withVelocity : (CGPoint )velocity targetContentOffset : (inout CGPoint *)targetContentOffset
2111
2123
{
2112
2124
if ([[self proxy ] _hasListeners: @" scrolling" ]) {
2113
- NSString *direction = nil ;
2125
+ NSString *direction = @" unknown " ;
2114
2126
2115
2127
if (velocity.y > 0 ) {
2116
2128
direction = @" up" ;
0 commit comments