Skip to content

Commit

Permalink
fix(ios): optimize ListView continuousUpdate (#13549)
Browse files Browse the repository at this point in the history
* fix(ios): optimize ListView continuousUpdate

* simply if statement
  • Loading branch information
m1ga authored Sep 10, 2022
1 parent 2453af6 commit ca73559
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions iphone/Classes/TiUIListView.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ @implementation TiUIListView {
BOOL isSearched;
UIView *dimmingView;
BOOL isSearchBarInNavigation;
int lastVisibleItem;
int lastVisibleSection;
}

#ifdef TI_USE_AUTOLAYOUT
Expand Down Expand Up @@ -1969,6 +1971,13 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
[eventArgs setValue:NUMINTEGER([indexPath section]) forKey:@"firstVisibleSectionIndex"];
[eventArgs setValue:section forKey:@"firstVisibleSection"];
[eventArgs setValue:[section itemAtIndex:[indexPath row]] forKey:@"firstVisibleItem"];

if (lastVisibleItem != [indexPath row] || lastVisibleSection != [indexPath section]) {
// only log if the item changes
[self.proxy fireEvent:@"scrolling" withObject:eventArgs propagate:NO];
lastVisibleItem = [indexPath row];
lastVisibleSection = [indexPath section];
}
} else {
section = [[self listViewProxy] sectionForIndex:0];

Expand All @@ -1978,8 +1987,6 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
[eventArgs setValue:section forKey:@"firstVisibleSection"];
[eventArgs setValue:NUMINTEGER(-1) forKey:@"firstVisibleItem"];
}

[self.proxy fireEvent:@"scrolling" withObject:eventArgs propagate:NO];
});
}
}
Expand Down

0 comments on commit ca73559

Please sign in to comment.