@@ -252,22 +252,22 @@ - (void)updateTopViewHorizontalCenterWithRecognizer:(UIPanGestureRecognizer *)re
252
252
self.initialTouchPositionX = currentTouchPositionX;
253
253
self.initialHoizontalCenter = self.topView .center .x ;
254
254
} else if (recognizer.state == UIGestureRecognizerStateChanged) {
255
+
256
+ CGPoint translation = [recognizer translationInView: self .view];
257
+
258
+ if (fabs (translation.x ) > fabs (translation.y ))
259
+ {
260
+ CGFloat panAmount = self.initialTouchPositionX - currentTouchPositionX;
261
+ CGFloat newCenterPosition = self.initialHoizontalCenter - panAmount;
255
262
256
- CGPoint translation = [recognizer translationInView: self .view];
257
-
258
- if (fabs (translation.x ) > fabs (translation.y ))
259
- {
260
- CGFloat panAmount = self.initialTouchPositionX - currentTouchPositionX;
261
- CGFloat newCenterPosition = self.initialHoizontalCenter - panAmount;
262
-
263
- if ((newCenterPosition < self.resettedCenter && self.anchorLeftTopViewCenter == NSNotFound ) || (newCenterPosition > self.resettedCenter && self.anchorRightTopViewCenter == NSNotFound )) {
264
- newCenterPosition = self.resettedCenter ;
265
- }
266
-
267
- [self topViewHorizontalCenterWillChange: newCenterPosition];
268
- [self updateTopViewHorizontalCenter: newCenterPosition];
269
- [self topViewHorizontalCenterDidChange: newCenterPosition];
263
+ if ((newCenterPosition < self.resettedCenter && self.anchorLeftTopViewCenter == NSNotFound ) || (newCenterPosition > self.resettedCenter && self.anchorRightTopViewCenter == NSNotFound )) {
264
+ newCenterPosition = self.resettedCenter ;
270
265
}
266
+
267
+ [self topViewHorizontalCenterWillChange: newCenterPosition];
268
+ [self updateTopViewHorizontalCenter: newCenterPosition];
269
+ [self topViewHorizontalCenterDidChange: newCenterPosition];
270
+ }
271
271
} else if (recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled) {
272
272
CGPoint currentVelocityPoint = [recognizer velocityInView: self .view];
273
273
CGFloat currentVelocityX = currentVelocityPoint.x ;
0 commit comments