@@ -40,44 +40,48 @@ public class C4ShapeLayer: CAShapeLayer {
40
40
if C4ShapeLayer . disableActions == true {
41
41
return nil
42
42
}
43
-
43
+
44
+ let animation = C4ViewAnimation . stack. first as? C4ViewAnimation
45
+
46
+ let shouldSpring = animation? . spring == nil ? false : true
47
+
44
48
if key == " lineWidth " {
45
- let animation = C4ViewAnimation . spring == nil ? CABasicAnimation ( keyPath: key) : CASpringAnimation ( keyPath: key)
49
+ let animation = shouldSpring ? CASpringAnimation ( keyPath: key) : CABasicAnimation ( keyPath: key)
46
50
animation. configureOptions ( )
47
51
animation. fromValue = self . lineWidth
48
52
return animation;
49
53
}
50
54
else if key == " strokeEnd " {
51
- let animation = C4ViewAnimation . spring == nil ? CABasicAnimation ( keyPath: key) : CASpringAnimation ( keyPath: key)
55
+ let animation = shouldSpring ? CASpringAnimation ( keyPath: key) : CABasicAnimation ( keyPath: key)
52
56
animation. configureOptions ( )
53
57
animation. fromValue = self . strokeEnd
54
58
return animation;
55
59
}
56
60
else if key == " strokeStart " {
57
- let animation = C4ViewAnimation . spring == nil ? CABasicAnimation ( keyPath: key) : CASpringAnimation ( keyPath: key)
61
+ let animation = shouldSpring ? CASpringAnimation ( keyPath: key) : CABasicAnimation ( keyPath: key)
58
62
animation. configureOptions ( )
59
63
animation. fromValue = self . strokeStart
60
64
return animation;
61
65
}
62
66
else if key == " strokeColor " {
63
- let animation = C4ViewAnimation . spring == nil ? CABasicAnimation ( keyPath: key) : CASpringAnimation ( keyPath: key)
67
+ let animation = shouldSpring ? CASpringAnimation ( keyPath: key) : CABasicAnimation ( keyPath: key)
64
68
animation. configureOptions ( )
65
69
animation. fromValue = self . strokeColor
66
70
return animation;
67
71
}
68
72
else if key == " path " {
69
- let animation = C4ViewAnimation . spring == nil ? CABasicAnimation ( keyPath: key) : CASpringAnimation ( keyPath: key)
73
+ let animation = shouldSpring ? CASpringAnimation ( keyPath: key) : CABasicAnimation ( keyPath: key)
70
74
animation. configureOptions ( )
71
75
animation. fromValue = self . path
72
76
return animation;
73
77
}
74
78
else if key == " fillColor " {
75
- let animation = C4ViewAnimation . spring == nil ? CABasicAnimation ( keyPath: key) : CASpringAnimation ( keyPath: key)
79
+ let animation = shouldSpring ? CASpringAnimation ( keyPath: key) : CABasicAnimation ( keyPath: key)
76
80
animation. configureOptions ( )
77
81
animation. fromValue = self . fillColor
78
82
return animation;
79
83
} else if key == " lineDashPhase " {
80
- let animation = C4ViewAnimation . spring == nil ? CABasicAnimation ( keyPath: key) : CASpringAnimation ( keyPath: key)
84
+ let animation = shouldSpring ? CASpringAnimation ( keyPath: key) : CABasicAnimation ( keyPath: key)
81
85
animation. configureOptions ( )
82
86
animation. fromValue = self . lineDashPhase
83
87
return animation;
@@ -107,7 +111,9 @@ extension CASpringAnimation {
107
111
/// The options set in this method are favorable for the inner workings of C4's animation behaviours.
108
112
public override func configureOptions( ) {
109
113
super. configureOptions ( )
110
- if let spring = C4ViewAnimation . spring {
114
+ if let animation = C4ViewAnimation . stack. last as? C4ViewAnimation ,
115
+ let spring = animation. spring {
116
+
111
117
self . mass = CGFloat ( spring. mass)
112
118
self . damping = CGFloat ( spring. damping)
113
119
self . stiffness = CGFloat ( spring. stiffness)
0 commit comments