Skip to content

Commit a8e3738

Browse files
committed
fixed scale animation
1 parent 97ac5e6 commit a8e3738

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Sources/CodeEditTextView/EmphasizeAPI/EmphasizeAPI.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ public class EmphasizeAPI {
128128
layer.path = shapePath.cgPathFallback
129129
}
130130

131+
// Set bounds of the layer; needed for the scale animation
132+
if let cgPath = layer.path {
133+
let boundingBox = cgPath.boundingBox
134+
layer.bounds = boundingBox
135+
layer.position = CGPoint(x: boundingBox.midX, y: boundingBox.midY)
136+
}
137+
131138
return layer
132139
}
133140

@@ -167,13 +174,10 @@ public class EmphasizeAPI {
167174

168175
private func applyPopAnimation(to layer: CALayer) {
169176
let scaleAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
170-
scaleAnimation.values = [1.0, 1.01, 1.0]
171-
scaleAnimation.keyTimes = [0, 0.5, 1]
172-
scaleAnimation.duration = 0.1
173-
scaleAnimation.timingFunctions = [
174-
CAMediaTimingFunction(name: .easeInEaseOut),
175-
CAMediaTimingFunction(name: .easeInEaseOut)
176-
]
177+
scaleAnimation.values = [1.0, 1.5, 1.0]
178+
scaleAnimation.keyTimes = [0, 0.3, 1]
179+
scaleAnimation.duration = 0.2
180+
scaleAnimation.timingFunctions = [CAMediaTimingFunction(name: .easeOut)]
177181

178182
layer.add(scaleAnimation, forKey: "popAnimation")
179183
}

0 commit comments

Comments
 (0)