Skip to content
Snippets Groups Projects
Commit a1c6d75f authored by Alexandre Lision's avatar Alexandre Lision
Browse files

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
Branches
Tags
No related merge requests found
......@@ -441,6 +441,8 @@
}
}];
[self.view.layer addAnimation:animation forKey:animation.keyPath];
[self.view.layer setPosition:frame.origin];
[CATransaction commit];
}
......
......@@ -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];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment