forked from overtake/telegram
-
Notifications
You must be signed in to change notification settings - Fork 6
/
POPBasicAnimation.mm
executable file
·90 lines (71 loc) · 2.24 KB
/
POPBasicAnimation.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
Copyright (c) 2014-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*/
#import "POPBasicAnimationInternal.h"
@implementation POPBasicAnimation
#undef __state
#define __state ((POPBasicAnimationState *)_state)
#pragma mark - Lifecycle
+ (instancetype)animation
{
return [[self alloc] init];
}
+ (instancetype)animationWithPropertyNamed:(NSString *)aName
{
POPBasicAnimation *anim = [self animation];
anim.property = [POPAnimatableProperty propertyWithName:aName];
return anim;
}
- (void)_initState
{
_state = new POPBasicAnimationState(self);
}
+ (instancetype)linearAnimation
{
POPBasicAnimation *anim = [self animation];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
return anim;
}
+ (instancetype)easeInAnimation
{
POPBasicAnimation *anim = [self animation];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
return anim;
}
+ (instancetype)easeOutAnimation
{
POPBasicAnimation *anim = [self animation];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
return anim;
}
+ (instancetype)easeInEaseOutAnimation
{
POPBasicAnimation *anim = [self animation];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
return anim;
}
+ (instancetype)defaultAnimation
{
POPBasicAnimation *anim = [self animation];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
return anim;
}
- (id)init
{
return [self _init];
}
#pragma mark - Properties
DEFINE_RW_PROPERTY(POPBasicAnimationState, duration, setDuration:, CFTimeInterval);
DEFINE_RW_PROPERTY_OBJ(POPBasicAnimationState, timingFunction, setTimingFunction:, CAMediaTimingFunction*, __state->updatedTimingFunction(););
#pragma mark - Utility
- (void)_appendDescription:(NSMutableString *)s debug:(BOOL)debug
{
[super _appendDescription:s debug:debug];
if (__state->duration)
[s appendFormat:@"; duration = %f", __state->duration];
}
@end