samvermette/SVPullToRefresh

scrollOffsetThreshold needs consider originalBottomInset?

Opened this issue · 0 comments

- (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.