Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / chrome / browser / ui / animation_util.h
blob778cdc5386a4c03be9f2faba24be13aab575e315
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_CHROME_BROWSER_UI_ANIMATION_UTIL_H_
6 #define IOS_CHROME_BROWSER_UI_ANIMATION_UTIL_H_
8 #import <UIKit/UIKit.h>
10 // Animations returned by these utility methods use kCAFillModeBoth and aren't
11 // automatically removed from the layer when finished. Remove the animations
12 // by calling |RemoveAnimationsFromLayers| in CATransaction completion blocks.
13 // This is done so the effects of animations that finish earlier persist until
14 // all animations in the transaction are finished.
16 // Returns an animation that will animate |layer| from |beginFrame| to
17 // |endFrame|.
18 CAAnimation* FrameAnimationMake(CALayer* layer,
19 CGRect beginFrame,
20 CGRect endFrame);
22 // Returns an animation that will animate the "opacity" property of a layer from
23 // |beginOpacity| to |endOpacity|.
24 CAAnimation* OpacityAnimationMake(CGFloat beginOpacity, CGFloat endOpacity);
26 // Returns an animation group containing the animations in |animations| that has
27 // the shortest duration necessary for all the animations to finish.
28 CAAnimation* AnimationGroupMake(NSArray* animations);
30 // Returns an animation that performs |animation| after |delay|.
31 CAAnimation* DelayedAnimationMake(CAAnimation* animation, CFTimeInterval delay);
33 // If |animation| is a CAAnimationGroup, searches its animations for a
34 // CABasicAnimation for |keyPath|. If |animation| is a CABasicAnimation, it
35 // will check its keyPath against |keyPath|.
36 CABasicAnimation* FindAnimationForKeyPath(NSString* keyPath,
37 CAAnimation* animation);
39 // Removes the animation for |key| from each CALayer in |layers|.
40 void RemoveAnimationForKeyFromLayers(NSString* key, NSArray* layers);
42 #endif // IOS_CHROME_BROWSER_UI_ANIMATION_UTIL_H_