|
@@ -213,10 +213,12 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
|
213
|
213
|
[self setMaximumLeftDrawerWidth:MMDrawerDefaultWidth];
|
214
|
214
|
[self setMaximumRightDrawerWidth:MMDrawerDefaultWidth];
|
215
|
215
|
|
216
|
|
- [self setAnimationVelocity:MMDrawerDefaultAnimationVelocity];
|
|
216
|
+ [self setAnimationVelocityLeft:MMDrawerDefaultAnimationVelocity];
|
|
217
|
+ [self setAnimationVelocityRight:MMDrawerDefaultAnimationVelocity];
|
217
|
218
|
|
218
|
219
|
[self setShowsShadow:YES];
|
219
|
|
- [self setShouldStretchDrawer:YES];
|
|
220
|
+ [self setShouldStretchLeftDrawer:YES];
|
|
221
|
+ [self setShouldStretchRightDrawer:YES];
|
220
|
222
|
|
221
|
223
|
[self setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeNone];
|
222
|
224
|
[self setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeNone];
|
|
@@ -297,7 +299,8 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
|
297
|
299
|
}
|
298
|
300
|
|
299
|
301
|
-(void)closeDrawerAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion{
|
300
|
|
- [self closeDrawerAnimated:animated velocity:self.animationVelocity animationOptions:UIViewAnimationOptionCurveEaseInOut completion:completion];
|
|
302
|
+ CGFloat velocity = self.openSide == MMDrawerSideLeft ? self.animationVelocityLeft : self.animationVelocityRight;
|
|
303
|
+ [self closeDrawerAnimated:animated velocity:velocity animationOptions:UIViewAnimationOptionCurveEaseInOut completion:completion];
|
301
|
304
|
}
|
302
|
305
|
|
303
|
306
|
-(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion{
|
|
@@ -359,8 +362,8 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
|
359
|
362
|
|
360
|
363
|
-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void (^)(BOOL finished))completion{
|
361
|
364
|
NSParameterAssert(drawerSide != MMDrawerSideNone);
|
362
|
|
-
|
363
|
|
- [self openDrawerSide:drawerSide animated:animated velocity:self.animationVelocity animationOptions:UIViewAnimationOptionCurveEaseInOut completion:completion];
|
|
365
|
+ CGFloat velocity = drawerSide == MMDrawerSideLeft ? self.animationVelocityLeft : self.animationVelocityRight;
|
|
366
|
+ [self openDrawerSide:drawerSide animated:animated velocity:velocity animationOptions:UIViewAnimationOptionCurveEaseInOut completion:completion];
|
364
|
367
|
}
|
365
|
368
|
|
366
|
369
|
-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion{
|
|
@@ -1250,11 +1253,25 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
|
1250
|
1253
|
if(self.drawerVisualState){
|
1251
|
1254
|
self.drawerVisualState(self,drawerSide,percentVisible);
|
1252
|
1255
|
}
|
1253
|
|
- else if(self.shouldStretchDrawer){
|
|
1256
|
+ else if([self shouldStretchForSide:drawerSide]){
|
1254
|
1257
|
[self applyOvershootScaleTransformForDrawerSide:drawerSide percentVisible:percentVisible];
|
1255
|
1258
|
}
|
1256
|
1259
|
}
|
1257
|
1260
|
|
|
1261
|
+- (BOOL)shouldStretchForSide:(MMDrawerSide)drawerSide {
|
|
1262
|
+ switch (drawerSide) {
|
|
1263
|
+ case MMDrawerSideLeft:
|
|
1264
|
+ return self.shouldStretchLeftDrawer;
|
|
1265
|
+ break;
|
|
1266
|
+ case MMDrawerSideRight:
|
|
1267
|
+ return self.shouldStretchRightDrawer;
|
|
1268
|
+ break;
|
|
1269
|
+ default:
|
|
1270
|
+ return YES;
|
|
1271
|
+ break;
|
|
1272
|
+ }
|
|
1273
|
+}
|
|
1274
|
+
|
1258
|
1275
|
- (void)applyOvershootScaleTransformForDrawerSide:(MMDrawerSide)drawerSide percentVisible:(CGFloat)percentVisible{
|
1259
|
1276
|
|
1260
|
1277
|
if (percentVisible >= 1.f) {
|
|
@@ -1283,7 +1300,7 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
|
1283
|
1300
|
-(CGFloat)roundedOriginXForDrawerConstriants:(CGFloat)originX{
|
1284
|
1301
|
|
1285
|
1302
|
if (originX < -self.maximumRightDrawerWidth) {
|
1286
|
|
- if (self.shouldStretchDrawer &&
|
|
1303
|
+ if (self.shouldStretchRightDrawer &&
|
1287
|
1304
|
self.rightDrawerViewController) {
|
1288
|
1305
|
CGFloat maxOvershoot = (CGRectGetWidth(self.centerContainerView.frame)-self.maximumRightDrawerWidth)*MMDrawerOvershootPercentage;
|
1289
|
1306
|
return originXForDrawerOriginAndTargetOriginOffset(originX, -self.maximumRightDrawerWidth, maxOvershoot);
|
|
@@ -1293,7 +1310,7 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
|
1293
|
1310
|
}
|
1294
|
1311
|
}
|
1295
|
1312
|
else if(originX > self.maximumLeftDrawerWidth){
|
1296
|
|
- if (self.shouldStretchDrawer &&
|
|
1313
|
+ if (self.shouldStretchLeftDrawer &&
|
1297
|
1314
|
self.leftDrawerViewController) {
|
1298
|
1315
|
CGFloat maxOvershoot = (CGRectGetWidth(self.centerContainerView.frame)-self.maximumLeftDrawerWidth)*MMDrawerOvershootPercentage;
|
1299
|
1316
|
return originXForDrawerOriginAndTargetOriginOffset(originX, self.maximumLeftDrawerWidth, maxOvershoot);
|
|
@@ -1387,7 +1404,8 @@ static inline CGFloat originXForDrawerOriginAndTargetOriginOffset(CGFloat origin
|
1387
|
1404
|
}
|
1388
|
1405
|
|
1389
|
1406
|
-(NSTimeInterval)animationDurationForAnimationDistance:(CGFloat)distance{
|
1390
|
|
- NSTimeInterval duration = MAX(distance/self.animationVelocity,MMDrawerMinimumAnimationDuration);
|
|
1407
|
+ CGFloat velocity = self.openSide == MMDrawerSideLeft ? self.animationVelocityLeft : self.animationVelocityRight;
|
|
1408
|
+ NSTimeInterval duration = MAX(distance/velocity,MMDrawerMinimumAnimationDuration);
|
1391
|
1409
|
return duration;
|
1392
|
1410
|
}
|
1393
|
1411
|
|