Skip to content

Commit ff3b2fa

Browse files
committed
Allow a custom animation to be passed in
1 parent 1310f67 commit ff3b2fa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/ResponsiveTextField/ResponsiveTextField.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,15 @@ public struct FirstResponderStateChangeHandler {
195195
/// in a `withAnimation` closure - this is useful if your state change handler is performing
196196
/// some state change and you want that change to be animated.
197197
///
198-
public func animation() -> Self {
198+
/// - Parameters:
199+
/// - animation: The animation to perform, or `nil` if you want to explicitly disable animations.
200+
///
201+
public func animation(animation: Animation? = .default) -> Self {
199202
.init(
200203
handleStateChange: { isFirstResponder in
201-
withAnimation { self.handleStateChange(isFirstResponder) }
204+
withAnimation(animation) {
205+
self.handleStateChange(isFirstResponder)
206+
}
202207
},
203208
canBecomeFirstResponder: canBecomeFirstResponder,
204209
canResignFirstResponder: canResignFirstResponder

0 commit comments

Comments
 (0)