@@ -26,6 +26,7 @@ - (void)updateTopViewHorizontalCenterWithRecognizer:(UIPanGestureRecognizer *)re
26
26
- (void )updateTopViewHorizontalCenter : (CGFloat)newHorizontalCenter ;
27
27
- (void )addTopViewSnapshot ;
28
28
- (void )removeTopViewSnapshot ;
29
+ - (CGFloat)resettedCenter ;
29
30
- (CGFloat)screenWidth ;
30
31
- (CGFloat)screenWidthForOrientation : (UIInterfaceOrientation)orientation ;
31
32
- (BOOL )underLeftShowing ;
@@ -144,8 +145,8 @@ - (void)updateTopViewHorizontalCenterWithRecognizer:(UIPanGestureRecognizer *)re
144
145
CGFloat panAmount = self.initialTouchPositionX - currentTouchPositionX;
145
146
CGFloat newCenterPosition = self.initialHoizontalCenter - panAmount;
146
147
147
- if ((newCenterPosition < self.view . center . x && self.leftSidePeekAmount == NSNotFound ) || (newCenterPosition > self.view . center . x && self.rightSidePeekAmount == NSNotFound )) {
148
- newCenterPosition = self.view . center . x ;
148
+ if ((newCenterPosition < self.resettedCenter && self.leftSidePeekAmount == NSNotFound ) || (newCenterPosition > self.resettedCenter && self.rightSidePeekAmount == NSNotFound )) {
149
+ newCenterPosition = self.resettedCenter ;
149
150
}
150
151
151
152
[self updateTopViewHorizontalCenter: newCenterPosition];
@@ -168,9 +169,9 @@ - (void)slideInDirection:(ECSlideDirection)slideDirection peekAmount:(CGFloat)pe
168
169
CGFloat newCenter = self.topView .center .x ;
169
170
170
171
if (slideDirection == ECSlideLeft) {
171
- newCenter = -self.screenWidth + self.view . center . x + peekAmount;
172
+ newCenter = -self.screenWidth + self.resettedCenter + peekAmount;
172
173
} else if (slideDirection == ECSlideRight) {
173
- newCenter = self.screenWidth + self.view . center . x - peekAmount;
174
+ newCenter = self.screenWidth + self.resettedCenter - peekAmount;
174
175
}
175
176
176
177
[UIView animateWithDuration: 0 .25f animations: ^{
@@ -198,7 +199,7 @@ - (void)enablePanningInDirection:(ECSlideDirection)slideDirection forView:(UIVie
198
199
- (void )reset
199
200
{
200
201
[UIView animateWithDuration: 0 .25f animations: ^{
201
- [self updateTopViewHorizontalCenter: self .view.center.x ];
202
+ [self updateTopViewHorizontalCenter: self .resettedCenter ];
202
203
}];
203
204
}
204
205
@@ -231,16 +232,16 @@ - (void)updateTopViewHorizontalCenter:(CGFloat)newHorizontalCenter
231
232
{
232
233
CGPoint center = self.topView .center ;
233
234
234
- if (center.x <= self.view . center . x && newHorizontalCenter > self.view . center . x ) {
235
+ if (center.x <= self.resettedCenter && newHorizontalCenter > self.resettedCenter ) {
235
236
[self underLeftWillAppear ];
236
- } else if (center.x >= self.view . center . x && newHorizontalCenter < self.view . center . x ) {
237
+ } else if (center.x >= self.resettedCenter && newHorizontalCenter < self.resettedCenter ) {
237
238
[self underRightWillAppear ];
238
239
}
239
240
240
241
center.x = newHorizontalCenter;
241
242
self.topView .center = center;
242
243
243
- if (newHorizontalCenter == self.view . center . x ) {
244
+ if (newHorizontalCenter == self.resettedCenter ) {
244
245
[self topDidReset ];
245
246
}
246
247
}
@@ -261,6 +262,11 @@ - (void)removeTopViewSnapshot
261
262
}
262
263
}
263
264
265
+ - (CGFloat)resettedCenter
266
+ {
267
+ return ceil (self.screenWidth / 2 );
268
+ }
269
+
264
270
- (CGFloat)screenWidth
265
271
{
266
272
return [self screenWidthForOrientation: [UIApplication sharedApplication ].statusBarOrientation];
0 commit comments