From a1c6d75f304096552580bd9fb747b37ed441c250 Mon Sep 17 00:00:00 2001 From: Alexandre Lision <alexandre.lision@savoirfairelinux.com> Date: Tue, 23 Jun 2015 12:27:38 -0400 Subject: [PATCH] animations: fix glitch after animations After animations, the animated view came back to its original position before properly being updated. We now set its new position right before the animation Refs #75600 Change-Id: I1bcd4e95a831c1d5b301a6b1f8b7afee44132a29 --- src/CurrentCallVC.mm | 2 ++ src/PreferencesVC.mm | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/CurrentCallVC.mm b/src/CurrentCallVC.mm index 7971a6fd..98be9aae 100644 --- a/src/CurrentCallVC.mm +++ b/src/CurrentCallVC.mm @@ -441,6 +441,8 @@ } }]; [self.view.layer addAnimation:animation forKey:animation.keyPath]; + + [self.view.layer setPosition:frame.origin]; [CATransaction commit]; } diff --git a/src/PreferencesVC.mm b/src/PreferencesVC.mm index 26f11d80..9edb1a6e 100644 --- a/src/PreferencesVC.mm +++ b/src/PreferencesVC.mm @@ -68,18 +68,21 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer"; // Set the layer redraw policy. This would be better done in // the initialization method of a NSView subclass instead of here. - self.view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize; + self.view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawOnSetNeedsDisplay; [self.view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; CGRect frame = CGRectOffset(self.view.frame, 0, -self.view.frame.size.height); - CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; - animation.fromValue = [NSValue valueWithPoint:frame.origin]; - animation.toValue = [NSValue valueWithPoint:self.view.frame.origin]; + [CATransaction begin]; + CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.y"]; + animation.fromValue = @(frame.origin.y); + animation.toValue = @(self.view.frame.origin.y); animation.duration = 0.3f; + [animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.7 :0.9 :1 :1]]; [self.view.layer addAnimation:animation forKey:animation.keyPath]; + [CATransaction commit]; } - (void) close @@ -96,9 +99,9 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer"; CGRect frame = CGRectOffset(self.view.frame, 0, -self.view.frame.size.height); [CATransaction begin]; - CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; - animation.fromValue = [NSValue valueWithPoint:self.view.frame.origin]; - animation.toValue = [NSValue valueWithPoint:frame.origin]; + CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.y"]; + animation.fromValue = @(self.view.frame.origin.y); + animation.toValue = @(frame.origin.y); animation.duration = 0.3f; [animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.7 :0.9 :1 :1]]; @@ -106,8 +109,10 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer"; [self.view removeFromSuperview]; }]; - [self.view.layer addAnimation:animation forKey:animation.keyPath]; + + // set final layer position to prevent glitching back to original one + [self.view.layer setPosition:frame.origin];; [CATransaction commit]; } -- GitLab