eggswift / pull-to-refresh

#Busy Re-Building....# An easy way to use pull to refresh and infinite scrolling in Swift. Pod 'ESPullToRefresh'
MIT License
1.82k stars 252 forks source link

contentOffset wrong after buttom refresh #135

Open huahuahu opened 6 years ago

huahuahu commented 6 years ago

I had a tableview which contentInset top is 44. When I has only one cell, I scroll up to refresh. After stop, the contentOffset become 0, which should be minus contentInset.y

    if scrollView.isDecelerating {
        var contentOffset = scrollView.contentOffset
        contentOffset.y = min(contentOffset.y, scrollView.contentSize.height - scrollView.frame.size.height)
       // should be -scrollView.contentInset.top??
        if contentOffset.y < 0.0 {
            contentOffset.y = 0.0
            UIView.animate(withDuration: 0.1, animations: {
                scrollView.setContentOffset(contentOffset, animated: false)
            })
        } else {
            scrollView.setContentOffset(contentOffset, animated: false)
        }
    }