Commit a1c6d75f authored by Alexandre Lision's avatar Alexandre Lision

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
parent 98f67cd3
...@@ -441,6 +441,8 @@ ...@@ -441,6 +441,8 @@
} }
}]; }];
[self.view.layer addAnimation:animation forKey:animation.keyPath]; [self.view.layer addAnimation:animation forKey:animation.keyPath];
[self.view.layer setPosition:frame.origin];
[CATransaction commit]; [CATransaction commit];
} }
......
...@@ -68,18 +68,21 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer"; ...@@ -68,18 +68,21 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer";
// Set the layer redraw policy. This would be better done in // Set the layer redraw policy. This would be better done in
// the initialization method of a NSView subclass instead of here. // the initialization method of a NSView subclass instead of here.
self.view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize; self.view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawOnSetNeedsDisplay;
[self.view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [self.view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
CGRect frame = CGRectOffset(self.view.frame, 0, -self.view.frame.size.height); CGRect frame = CGRectOffset(self.view.frame, 0, -self.view.frame.size.height);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; [CATransaction begin];
animation.fromValue = [NSValue valueWithPoint:frame.origin]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.y"];
animation.toValue = [NSValue valueWithPoint:self.view.frame.origin]; animation.fromValue = @(frame.origin.y);
animation.toValue = @(self.view.frame.origin.y);
animation.duration = 0.3f; animation.duration = 0.3f;
[animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.7 :0.9 :1 :1]]; [animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.7 :0.9 :1 :1]];
[self.view.layer addAnimation:animation forKey:animation.keyPath]; [self.view.layer addAnimation:animation forKey:animation.keyPath];
[CATransaction commit];
} }
- (void) close - (void) close
...@@ -96,9 +99,9 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer"; ...@@ -96,9 +99,9 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer";
CGRect frame = CGRectOffset(self.view.frame, 0, -self.view.frame.size.height); CGRect frame = CGRectOffset(self.view.frame, 0, -self.view.frame.size.height);
[CATransaction begin]; [CATransaction begin];
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.y"];
animation.fromValue = [NSValue valueWithPoint:self.view.frame.origin]; animation.fromValue = @(self.view.frame.origin.y);
animation.toValue = [NSValue valueWithPoint:frame.origin]; animation.toValue = @(frame.origin.y);
animation.duration = 0.3f; animation.duration = 0.3f;
[animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.7 :0.9 :1 :1]]; [animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.7 :0.9 :1 :1]];
...@@ -106,8 +109,10 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer"; ...@@ -106,8 +109,10 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer";
[self.view removeFromSuperview]; [self.view removeFromSuperview];
}]; }];
[self.view.layer addAnimation:animation forKey:animation.keyPath]; [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]; [CATransaction commit];
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment