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

嘿 man 有个bug #23

Closed harryzjm closed 8 years ago

harryzjm commented 8 years ago

dome中 把 DefaultTableViewController 中
数据量改为2行 即 缩小到 并没有占满一屏 上拉刷新 改为

self.tableView.es_addInfiniteScrolling {
            [weak self] in

            let minseconds = 0.1 * Double(NSEC_PER_SEC)   //此处改为0.1  加快反馈

            let dtime = dispatch_time(DISPATCH_TIME_NOW, Int64(minseconds))
            dispatch_after(dtime, dispatch_get_main_queue() , {
                self?.page += 1
                if self?.page <= 3 {
                    for _ in 1...1{
                        self?.array.append(" ")
                    }
                    self?.tableView.reloadData()
                    self?.tableView.es_stopLoadingMore()
                } else {
                    self?.tableView.es_noticeNoMoreData()
                }
            })
        }

会使得在 ESRefreshFooterView.stopAnimating方法 中的scrollView.decelerating为true
造成 执行了

var contentOffset = scrollView.contentOffset
contentOffset.y = min(contentOffset.y, scrollView.contentSize.height - scrollView.frame.size.height)
scrollView.setContentOffset(contentOffset, animated: false)

使cell弹到了 下半屏
建议

 public override func stopAnimating() {
        guard let scrollView = scrollView else {
            return
        }
        self.animator.refreshAnimationDidEnd(self)
        self.animator.refresh(self, stateDidChange: .PullToRefresh)
        UIView .animateWithDuration(0.3, delay: 0, options: .CurveLinear, animations: { 
            self.animator.refresh(self, progressDidChange: 0.0)
            }) { (finished) in
                super.stopAnimating()
        }
    }
eggswift commented 8 years ago

Hi,请问您的demo是最新的版本嘛?

if scrollView.isDecelerating {
            var contentOffset = scrollView.contentOffset
            contentOffset.y = min(contentOffset.y, scrollView.contentSize.height - scrollView.frame.size.height)
            scrollView.setContentOffset(contentOffset, animated: false)
        }

这一部分主要是想解决这样一个场景:当loadingmore的时候,scrollview还保持着惯性滑动,体验很奇怪。 我没有看懂您的建议是指改动哪个地方?

eggswift commented 8 years ago

已修改,目前在swift3的分支😄~

harryzjm commented 8 years ago

是这个意思!👍