OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/chrome/common/material_timing.h" | 5 #import "ios/chrome/common/material_timing.h" |
6 | 6 |
7 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
8 #error "This file requires ARC support." | |
9 #endif | |
10 | |
7 namespace { | 11 namespace { |
8 | 12 |
9 UIViewAnimationOptions AnimationOptionsForceLinearTiming( | 13 UIViewAnimationOptions AnimationOptionsForceLinearTiming( |
10 UIViewAnimationOptions options) { | 14 UIViewAnimationOptions options) { |
11 // Remove any non-linear timing options from |options|. They should be | 15 // Remove any non-linear timing options from |options|. They should be |
12 // ignored. | 16 // ignored. |
13 options &= | 17 options &= |
14 ~(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionCurveEaseIn | | 18 ~(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionCurveEaseIn | |
15 UIViewAnimationOptionCurveEaseOut); | 19 UIViewAnimationOptionCurveEaseOut); |
16 // Since default is EaseInOut, ensure linear is specified instead so the outer | 20 // Since default is EaseInOut, ensure linear is specified instead so the outer |
(...skipping 15 matching lines...) Expand all Loading... | |
32 const CGFloat kDuration1 = 0.25 * kSlowAnimationModifier; | 36 const CGFloat kDuration1 = 0.25 * kSlowAnimationModifier; |
33 const CGFloat kDuration2 = 0.1 * kSlowAnimationModifier; | 37 const CGFloat kDuration2 = 0.1 * kSlowAnimationModifier; |
34 const CGFloat kDuration3 = 0.35 * kSlowAnimationModifier; | 38 const CGFloat kDuration3 = 0.35 * kSlowAnimationModifier; |
35 const CGFloat kDuration4 = 0.05 * kSlowAnimationModifier; | 39 const CGFloat kDuration4 = 0.05 * kSlowAnimationModifier; |
36 const CGFloat kDuration5 = 0.5 * kSlowAnimationModifier; | 40 const CGFloat kDuration5 = 0.5 * kSlowAnimationModifier; |
37 const CGFloat kDuration6 = 0.15 * kSlowAnimationModifier; | 41 const CGFloat kDuration6 = 0.15 * kSlowAnimationModifier; |
38 const CGFloat kDuration7 = 0.4 * kSlowAnimationModifier; | 42 const CGFloat kDuration7 = 0.4 * kSlowAnimationModifier; |
39 const CGFloat kDuration8 = 0.07 * kSlowAnimationModifier; | 43 const CGFloat kDuration8 = 0.07 * kSlowAnimationModifier; |
40 | 44 |
41 CAMediaTimingFunction* TransformCurve2() { | 45 CAMediaTimingFunction* TransformCurve2() { |
42 return [[[CAMediaTimingFunction alloc] | 46 return [[CAMediaTimingFunction alloc] initWithControlPoints: |
43 initWithControlPoints:0.0f :0.84f :0.13f :0.99f] autorelease]; | 47 0.0f: |
48 0.84f: | |
49 0.13f:0.99f]; | |
pkl (ping after 24h if needed)
2017/02/09 16:46:37
Is this what git-cl-format did? This looks less re
lody
2017/02/09 16:51:50
Yeah, I just tried to make sure and it is git cl f
| |
44 } | 50 } |
45 | 51 |
46 CAMediaTimingFunction* TimingFunction(Curve curve) { | 52 CAMediaTimingFunction* TimingFunction(Curve curve) { |
47 switch (curve) { | 53 switch (curve) { |
48 case CurveEaseInOut: | 54 case CurveEaseInOut: |
49 // This curve is slow both at the begining and end. | 55 // This curve is slow both at the begining and end. |
50 // Visualization of curve http://cubic-bezier.com/#.4,0,.2,1 | 56 // Visualization of curve http://cubic-bezier.com/#.4,0,.2,1 |
51 return [[[CAMediaTimingFunction alloc] | 57 return [[CAMediaTimingFunction alloc] initWithControlPoints: |
52 initWithControlPoints:0.4f :0.0f :0.2f :1.0f] autorelease]; | 58 0.4f: |
59 0.0f: | |
60 0.2f:1.0f]; | |
53 case CurveEaseOut: | 61 case CurveEaseOut: |
54 // This curve is slow at the end. | 62 // This curve is slow at the end. |
55 // Visualization of curve http://cubic-bezier.com/#0,0,.2,1 | 63 // Visualization of curve http://cubic-bezier.com/#0,0,.2,1 |
56 return [[[CAMediaTimingFunction alloc] | 64 return [[CAMediaTimingFunction alloc] initWithControlPoints: |
57 initWithControlPoints:0.0f :0.0f :0.2f :1.0f] autorelease]; | 65 0.0f: |
66 0.0f: | |
67 0.2f:1.0f]; | |
58 case CurveEaseIn: | 68 case CurveEaseIn: |
59 // This curve is slow at the begining. | 69 // This curve is slow at the begining. |
60 // Visualization of curve http://cubic-bezier.com/#.4,0,1,1 | 70 // Visualization of curve http://cubic-bezier.com/#.4,0,1,1 |
61 return [[[CAMediaTimingFunction alloc] | 71 return [[CAMediaTimingFunction alloc] initWithControlPoints: |
62 initWithControlPoints:0.4f :0.0f :1.0f :1.0f] autorelease]; | 72 0.4f: |
73 0.0f: | |
74 1.0f:1.0f]; | |
63 case CurveLinear: | 75 case CurveLinear: |
64 // This curve is linear. | 76 // This curve is linear. |
65 return | 77 return |
66 [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; | 78 [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; |
67 } | 79 } |
68 } | 80 } |
69 | 81 |
70 } // material | 82 } // material |
71 } // ios | 83 } // ios |
72 | 84 |
(...skipping 25 matching lines...) Expand all Loading... | |
98 [CATransaction setAnimationTimingFunction:TimingFunction(curve)]; | 110 [CATransaction setAnimationTimingFunction:TimingFunction(curve)]; |
99 [UIView transitionWithView:view | 111 [UIView transitionWithView:view |
100 duration:duration | 112 duration:duration |
101 options:AnimationOptionsForceLinearTiming(options) | 113 options:AnimationOptionsForceLinearTiming(options) |
102 animations:animations | 114 animations:animations |
103 completion:completion]; | 115 completion:completion]; |
104 [CATransaction commit]; | 116 [CATransaction commit]; |
105 } | 117 } |
106 | 118 |
107 @end | 119 @end |
OLD | NEW |