Spring
A representation of a spring's motion.
Declaration
type Spring =
| 'bouncy'
| 'smooth'
| 'snappy'
| { bouncy: { duration?: number; extraBounce?: number; }; }
| { duration?: number; bounce?: number; }
| { mass?: number; stiffness: number; damping: number; allowOverDamping?: boolean; }
| { response: number; dampingRatio: number; }
| { settlingDuration: number; dampingRatio: number; epsilon?: number; }
| { smooth: { duration?: number; extraBounce?: number; }; }
| { snappy: { duration?: number; extraBounce?: number; }; };struct SpringPass a literal, or build one with SwiftUI.Spring from import { SwiftUI } from 'swiftui-react-native'.
Type properties
'bouncy'SwiftUI.Spring.bouncyA spring with a predefined duration and higher amount of bounce.
'smooth'SwiftUI.Spring.smoothA smooth spring with a predefined duration and no bounce.
'snappy'SwiftUI.Spring.snappyA spring with a predefined duration and small amount of bounce that feels more snappy.
Type methods
Overview
Use this type to convert between different representations of spring parameters:
let spring = Spring(duration: 0.5, bounce: 0.3)
let (mass, stiffness, damping) = (spring.mass, spring.stiffness, spring.damping)
// (1.0, 157.9, 17.6)
let spring2 = Spring(mass: 1, stiffness: 100, damping: 10)
let (duration, bounce) = (spring2.duration, spring2.bounce)
// (0.63, 0.5)You can also use it to query for a spring's position and its other properties for a given set of inputs:
func unitPosition(time: TimeInterval) -> Double {
let spring = Spring(duration: 0.5, bounce: 0.3)
return spring.position(target: 1.0, time: time)
}From Apple’s SwiftUI documentation. Code samples there are Swift.
See also
More in Animation.
- AnimationThe way a view changes over time to create a smooth visual transition from one state to another.
- AnimationChainAnimation with chained calls: SwiftUI.Animation.delay(...).
- AnimationCompletionCriteriaThe criteria that determines when an animation is considered finished.
- AnimationTimelineScheduleA pausable schedule of dates updating at a frequency no more quickly than the provided interval.
- AnyTransitionA type-erased transition.
- AnyTransitionChainAnyTransition with chained calls: SwiftUI.AnyTransition.animation(...).
- BlurReplaceTransitionA transition that animates the insertion or removal of a view by combining blurring and scaling effects.
- BlurReplaceTransitionConfigurationConfiguration properties for a transition.
- ContentTransitionA kind of transition that applies to the content within a single view, rather than to the insertion or removal of a view.
- DropSessionPhaseThe phase of the current drop session.
- GlassEffectTransitionA structure that describes changes to apply when a glass effect is added or removed from the view hierarchy.
- IdentityTransitionA transition that returns the input view, unmodified, as the output view.