Declaration
import { KeyframeAnimator } from 'swiftui-react-native';nonisolated struct KeyframeAnimator<Value, KeyframePath, Content> where Value == KeyframePath.Value, KeyframePath : Keyframes, Content : ViewInitializers
2 SwiftUI initializers back <KeyframeAnimator>. The props you pass pick one.
<KeyframeAnimator
initialValue: any
trigger: string | number | boolean
content: (value: any) => ViewModifierChain
keyframes: KeyframeTracks
>
children?: ReactNode
</KeyframeAnimator>nonisolated init(
initialValue: Value,
trigger: some Equatable,
@ContentBuilder content: @escaping (Value) -> Content,
@KeyframesBuilder<Value> keyframes: @escaping (Value) -> KeyframePath
)initialValue*anyThe initial value that the keyframes will animate from.
trigger*string | number | booleanA value to observe for changes.
content*(value: any) => ViewModifierChainA content builder closure that takes the interpolated value generated by the keyframes as its single argument. Runs once, ahead of SwiftUI: numbers of the value it receives are symbolic, so nothing crosses to JavaScript on a frame.
childrenReactNodeContent. The chain applies to it.
keyframes*KeyframeTracksKeyframes defining how the value changes over time. The current value of the animator is the single argument, which is equal to
initialValuewhen the view first appears, then is equal to the end value of the previous keyframe animation on subsequent calls.
Also takes the common view props: modifiers, style and testID.
Overview
The content closure updates every frame while
animating, so avoid performing any expensive operations directly within
content.
From Apple’s SwiftUI documentation. Code samples there are Swift.
Relationships
Conforms to
- View
See also
More in Animation.