Skip to content

Commit 2fda0a6

Browse files
committed
Merge pull request ViewDeck#78 from PierreA/master
Just a little add-on
2 parents 2a7cc28 + 0c5acfa commit 2fda0a6

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

ViewDeck/IIViewDeckController.h

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ typedef enum {
9494
- (void)showCenterView:(BOOL)animated;
9595
- (void)showCenterView:(BOOL)animated completion:(void(^)(IIViewDeckController* controller))completed;
9696

97+
98+
- (void)seLeftLedge:(CGFloat)rightLedge completion:(void(^)(BOOL finished))completion;
99+
- (void)setRightLedge:(CGFloat)rightLedge completion:(void(^)(BOOL finished))completion;
100+
97101
- (void)toggleLeftView;
98102
- (void)openLeftView;
99103
- (void)closeLeftView;

ViewDeck/IIViewDeckController.m

+42
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,27 @@ - (void)setLeftLedge:(CGFloat)leftLedge {
397397
_leftLedge = leftLedge;
398398
}
399399

400+
- (void)setLeftLedge:(CGFloat)leftLedge completion:(void(^)(BOOL finished))completion {
401+
// Compute the final ledge in two steps. This prevents a strange bug where
402+
// nesting MAX(X, MIN(Y, Z)) with miniscule referenceBounds returns a bogus near-zero value.
403+
CGFloat minLedge = MIN(self.referenceBounds.size.width, leftLedge);
404+
leftLedge = MAX(leftLedge, minLedge);
405+
if (_viewAppeared && II_FLOAT_EQUAL(self.slidingControllerView.frame.origin.x, self.referenceBounds.size.width - _leftLedge)) {
406+
if (leftLedge < _leftLedge) {
407+
[UIView animateWithDuration:CLOSE_SLIDE_DURATION(YES) animations:^{
408+
[self setSlidingFrameForOffset:self.referenceBounds.size.width - leftLedge];
409+
} completion:completion];
410+
}
411+
else if (leftLedge > _leftLedge) {
412+
[UIView animateWithDuration:OPEN_SLIDE_DURATION(YES) animations:^{
413+
[self setSlidingFrameForOffset:self.referenceBounds.size.width - leftLedge];
414+
} completion:completion];
415+
}
416+
}
417+
_leftLedge = leftLedge;
418+
}
419+
420+
400421
- (void)setRightLedge:(CGFloat)rightLedge {
401422
// Compute the final ledge in two steps. This prevents a strange bug where
402423
// nesting MAX(X, MIN(Y, Z)) with miniscule referenceBounds returns a bogus near-zero value.
@@ -417,6 +438,27 @@ - (void)setRightLedge:(CGFloat)rightLedge {
417438
_rightLedge = rightLedge;
418439
}
419440

441+
- (void)setRightLedge:(CGFloat)rightLedge completion:(void(^)(BOOL finished))completion {
442+
// Compute the final ledge in two steps. This prevents a strange bug where
443+
// nesting MAX(X, MIN(Y, Z)) with miniscule referenceBounds returns a bogus near-zero value.
444+
CGFloat minLedge = MIN(self.referenceBounds.size.width, rightLedge);
445+
rightLedge = MAX(rightLedge, minLedge);
446+
if (_viewAppeared && II_FLOAT_EQUAL(self.slidingControllerView.frame.origin.x, _rightLedge - self.referenceBounds.size.width)) {
447+
if (rightLedge < _rightLedge) {
448+
[UIView animateWithDuration:CLOSE_SLIDE_DURATION(YES) animations:^{
449+
[self setSlidingFrameForOffset:rightLedge - self.referenceBounds.size.width];
450+
} completion:completion];
451+
}
452+
else if (rightLedge > _rightLedge) {
453+
[UIView animateWithDuration:OPEN_SLIDE_DURATION(YES) animations:^{
454+
[self setSlidingFrameForOffset:rightLedge - self.referenceBounds.size.width];
455+
} completion:completion];
456+
}
457+
}
458+
_rightLedge = rightLedge;
459+
}
460+
461+
420462
- (void)setMaxLedge:(CGFloat)maxLedge {
421463
_maxLedge = maxLedge;
422464
if (_leftController && _rightController) {

0 commit comments

Comments
 (0)