gh-EmergeTools-Pow/Example/Pow Example/Examples/Transitions/SkidExample.swift
Joe Fabisevich 5b95fe95b0
Moving Pow to @emergetools (#36)
Co-authored-by: Robert Böhnke <robb@robb.is>
Co-authored-by: Kasper Lahti <kasper@lahti.email>
2023-11-29 12:08:53 -03:00

44 lines
1.3 KiB
Swift

import Pow
import SwiftUI
struct SkidExample: View, Example {
@State
var isVisible: Bool = false
var body: some View {
VStack {
if isVisible {
let overshoot = Animation.movingParts.overshoot(duration: 0.8)
PlaceholderView()
.frame(maxWidth: 120, maxHeight: 120)
.transition(.movingParts.skid(direction: .leading).animation(overshoot))
let mediumSpring = Animation.interactiveSpring(dampingFraction: 0.5)
PlaceholderView()
.frame(maxWidth: 120, maxHeight: 120)
.transition(.movingParts.skid.animation(mediumSpring))
let looseSpring = Animation.interpolatingSpring(stiffness: 100, damping: 8)
PlaceholderView()
.frame(maxWidth: 120, maxHeight: 120)
.transition(.movingParts.skid.animation(looseSpring))
}
}
.defaultBackground()
.onTapGesture {
withAnimation {
isVisible.toggle()
}
}
.autotoggle($isVisible)
}
static let localPath = LocalPath()
static var icon: Image? {
Image(systemName: "arrow.left.and.right.square")
}
}