Add the convenient API support to use SwiftUI transition with ease-in-out duration
This commit is contained in:
parent
28e68492ec
commit
111a2f6b8a
|
@ -18,6 +18,15 @@ extension AnyTransition {
|
|||
return AnyTransition.asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
/// Fade-in transition with duration
|
||||
/// - Parameter duration: transition duration, use ease-in-out
|
||||
/// - Returns: A transition with duration
|
||||
public static func fade(duration: Double) -> AnyTransition {
|
||||
let insertion = AnyTransition.opacity.animation(.easeInOut(duration: duration))
|
||||
let removal = AnyTransition.identity
|
||||
return AnyTransition.asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
/// Flip from left transition
|
||||
public static var flipFromLeft: AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .leading)
|
||||
|
@ -25,6 +34,15 @@ extension AnyTransition {
|
|||
return AnyTransition.asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
/// Flip from left transition with duration
|
||||
/// - Parameter duration: transition duration, use ease-in-out
|
||||
/// - Returns: A transition with duration
|
||||
public static func flipFromLeft(duration: Double) -> AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .leading).animation(.easeInOut(duration: duration))
|
||||
let removal = AnyTransition.identity
|
||||
return AnyTransition.asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
/// Flip from right transition
|
||||
public static var flipFromRight: AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .trailing)
|
||||
|
@ -32,6 +50,15 @@ extension AnyTransition {
|
|||
return AnyTransition.asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
/// Flip from right transition with duration
|
||||
/// - Parameter duration: transition duration, use ease-in-out
|
||||
/// - Returns: A transition with duration
|
||||
public static func flipFromRight(duration: Double) -> AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .trailing).animation(.easeInOut(duration: duration))
|
||||
let removal = AnyTransition.identity
|
||||
return AnyTransition.asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
/// Flip from top transition
|
||||
public static var flipFromTop: AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .top)
|
||||
|
@ -39,10 +66,28 @@ extension AnyTransition {
|
|||
return AnyTransition.asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
/// Flip from top transition with duration
|
||||
/// - Parameter duration: transition duration, use ease-in-out
|
||||
/// - Returns: A transition with duration
|
||||
public static func flipFromTop(duration: Double) -> AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .top).animation(.easeInOut(duration: duration))
|
||||
let removal = AnyTransition.identity
|
||||
return AnyTransition.asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
/// Flip from bottom transition
|
||||
public static var flipFromBottom: AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .bottom)
|
||||
let removal = AnyTransition.identity
|
||||
return AnyTransition.asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
/// Flip from bottom transition with duration
|
||||
/// - Parameter duration: transition duration, use ease-in-out
|
||||
/// - Returns: A transition with duration
|
||||
public static func flipFromBottom(duration: Double) -> AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .bottom).animation(.easeInOut(duration: duration))
|
||||
let removal = AnyTransition.identity
|
||||
return AnyTransition.asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue