Skip to content
This repository was archived by the owner on Jan 14, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion ECSlidingViewController/ECPercentDrivenInteractiveTransition.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ - (void)updateInteractiveTransition:(CGFloat)percentComplete {
CFTimeInterval pausedTime = [self.animationController transitionDuration:self.transitionContext] * _percentComplete;
layer.speed = 0.0;
layer.timeOffset = pausedTime;
layer.beginTime = 0.0;
}

- (void)cancelInteractiveTransition {
Expand All @@ -84,6 +85,12 @@ - (void)finishInteractiveTransition {
layer.beginTime = 0.0;
CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
layer.beginTime = timeSincePause;

// Reset the begin time after animation completes
NSTimeInterval duration = [self.animationController transitionDuration:self.transitionContext];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
layer.beginTime = 0.0;
});
}

#pragma mark - CADisplayLink action
Expand All @@ -100,9 +107,13 @@ - (void)reversePausedAnimation:(CADisplayLink *)displayLink {

[self updateInteractiveTransition:self.percentComplete];

CALayer *layer = [self.transitionContext containerView].layer;

layer.timeOffset = 0.0;
layer.beginTime = 0.0;

if (_percentComplete == 0.0) {
self.isActive = NO;
CALayer *layer = [self.transitionContext containerView].layer;
[layer removeAllAnimations];
layer.speed = 1.0;
}
Expand Down