-
Notifications
You must be signed in to change notification settings - Fork 0
/
POPAnimationEvent.mm
108 lines (94 loc) · 2.68 KB
/
POPAnimationEvent.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
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 "POPAnimationEvent.h"
#import "POPAnimationEventInternal.h"
static NSString *stringFromType(POPAnimationEventType aType)
{
switch (aType) {
case kPOPAnimationEventPropertyRead:
return @"read";
case kPOPAnimationEventPropertyWrite:
return @"write";
case kPOPAnimationEventToValueUpdate:
return @"toValue";
case kPOPAnimationEventFromValueUpdate:
return @"fromValue";
case kPOPAnimationEventVelocityUpdate:
return @"velocity";
case kPOPAnimationEventSpeedUpdate:
return @"speed";
case kPOPAnimationEventBouncinessUpdate:
return @"bounciness";
case kPOPAnimationEventFrictionUpdate:
return @"friction";
case kPOPAnimationEventMassUpdate:
return @"mass";
case kPOPAnimationEventTensionUpdate:
return @"tension";
case kPOPAnimationEventDidStart:
return @"didStart";
case kPOPAnimationEventDidStop:
return @"didStop";
case kPOPAnimationEventDidReachToValue:
return @"didReachToValue";
case kPOPAnimationEventAutoreversed:
return @"autoreversed";
default:
return nil;
}
}
@implementation POPAnimationEvent
@synthesize type = _type;
@synthesize time = _time;
@synthesize animationDescription = _animationDescription;
- (instancetype)initWithType:(POPAnimationEventType)aType time:(CFTimeInterval)aTime
{
self = [super init];
if (nil != self) {
_type = aType;
_time = aTime;
}
return self;
}
- (NSString *)description
{
NSMutableString *s = [NSMutableString stringWithFormat:@"<POPAnimationEvent:%f; type = %@", _time, stringFromType(_type)];
[self _appendDescription:s];
[s appendString:@">"];
return s;
}
// subclass override
- (void)_appendDescription:(NSMutableString *)s
{
if (0 != _animationDescription.length) {
[s appendFormat:@"; animation = %@", _animationDescription];
}
}
@end
@implementation POPAnimationValueEvent
@synthesize value = _value;
@synthesize velocity = _velocity;
- (instancetype)initWithType:(POPAnimationEventType)aType time:(CFTimeInterval)aTime value:(id)aValue
{
self = [self initWithType:aType time:aTime];
if (nil != self) {
_value = aValue;
}
return self;
}
- (void)_appendDescription:(NSMutableString *)s
{
[super _appendDescription:s];
if (nil != _value) {
[s appendFormat:@"; value = %@", _value];
}
if (nil != _velocity) {
[s appendFormat:@"; velocity = %@", _velocity];
}
}
@end