Skip to content

scrollOffsetThreshold needs consider originalBottomInset? #300

@sou1x0

Description

@sou1x0
- (void)scrollViewDidScroll:(CGPoint)contentOffset {
    if(self.state != SVInfiniteScrollingStateLoading && self.enabled) {
        CGFloat scrollViewContentHeight = self.scrollView.contentSize.height;
        CGFloat scrollOffsetThreshold = scrollViewContentHeight-self.scrollView.bounds.size.height;
        
        if(!self.scrollView.isDragging && self.state == SVInfiniteScrollingStateTriggered)
            self.state = SVInfiniteScrollingStateLoading;
        else if(contentOffset.y > scrollOffsetThreshold && self.state == SVInfiniteScrollingStateStopped && self.scrollView.isDragging)
            self.state = SVInfiniteScrollingStateTriggered;
        else if(contentOffset.y < scrollOffsetThreshold  && self.state != SVInfiniteScrollingStateStopped)
            self.state = SVInfiniteScrollingStateStopped;
    }
}

scrollOffsetThreshold should consider originalBottomInset. So I think scrollOffsetThreshold += self.originalBottomInset; should be inserted after CGFloat scrollOffsetThreshold = scrollViewContentHeight-self.scrollView.bounds.size.height;

Otherwise, when scrollview has bottom inset, supposed it's a positive number, and it currently reaches to the end, state will still be loading even though user scrolls up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions