Browse Source

Merge pull request #1197 from sxdxzkq/master

解决滑动手势中断带来的计算失误(下拉刷新位置计算错误)
M了个J 7 years ago
parent
commit
5fee65f22a
1 changed files with 9 additions and 7 deletions
  1. 9 7
      MJRefresh/Base/MJRefreshHeader.m

+ 9 - 7
MJRefresh/Base/MJRefreshHeader.m

@@ -127,13 +127,15 @@ - (void)setState:(MJRefreshState)state
     } else if (state == MJRefreshStateRefreshing) {
         MJRefreshDispatchAsyncOnMainQueue({
             [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
-                CGFloat top = self.scrollViewOriginalInset.top + self.mj_h;
-                // 增加滚动区域top
-                self.scrollView.mj_insetT = top;
-                // 设置滚动位置
-                CGPoint offset = self.scrollView.contentOffset;
-                offset.y = -top;
-                [self.scrollView setContentOffset:offset animated:NO];
+                if (self.scrollView.panGestureRecognizer.state != UIGestureRecognizerStateCancelled) {
+                    CGFloat top = self.scrollViewOriginalInset.top + self.mj_h;
+                    // 增加滚动区域top
+                    self.scrollView.mj_insetT = top;
+                    // 设置滚动位置
+                    CGPoint offset = self.scrollView.contentOffset;
+                    offset.y = -top;
+                    [self.scrollView setContentOffset:offset animated:NO];
+                }
             } completion:^(BOOL finished) {
                 [self executeRefreshingCallback];
             }];