Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
+ [ios] list component section header sticky event
Browse files Browse the repository at this point in the history
  • Loading branch information
lybeen committed May 9, 2017
1 parent 5d4d6ba commit b9a1cd0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXListComponent.m
Expand Up @@ -100,6 +100,8 @@ - (NSString *)description

@interface WXListComponent () <UITableViewDataSource, UITableViewDelegate, WXCellRenderDelegate, WXHeaderRenderDelegate>

@property (nonatomic, assign) NSUInteger currentTopVisibleSection;

@end

@implementation WXListComponent
Expand Down Expand Up @@ -576,6 +578,25 @@ - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSIntege
}
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[super scrollViewDidScroll:scrollView];
NSIndexPath *topCellPath = [[_tableView indexPathsForVisibleRows] objectAtIndex:0];
if (self.currentTopVisibleSection != topCellPath.section) {
if (self.currentTopVisibleSection) {
WXSection *removeSection = [_sections objectAtIndex:self.currentTopVisibleSection];
if (removeSection.header && [removeSection.header.events containsObject:@"unSticky"]) {
[removeSection.header fireEvent:@"unSticky" params:nil];
}
}
self.currentTopVisibleSection = topCellPath.section;
WXSection *showSection = [_sections objectAtIndex:topCellPath.section];
if (showSection.header && [showSection.header.events containsObject:@"sticky"]) {
[showSection.header fireEvent:@"sticky" params:nil];
}
}
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
WXHeaderComponent *header = ((WXSection *)_completedSections[section]).header;
Expand Down

0 comments on commit b9a1cd0

Please sign in to comment.