You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get this error when I try to use this in swiftui: "Animation must have a non-nil value before starting."
my code is here:
`.onAppear {
offsetAnimator.value = .zero
// The offset animator's callback will update the `offset` state variable.
offsetAnimator.valueChanged = { newValue in
boxOffset = newValue
}
}
.offset(x: boxOffset.x, y: boxOffset.y)
.gesture(
DragGesture()
.onChanged { value in
// Update the animator's target to the new drag translation.
offsetAnimator.target = CGPoint(x: value.translation.width, y: value.translation.height)
// Don't animate the box's position when we're dragging it.
offsetAnimator.mode = .nonAnimated
offsetAnimator.start()
}
.onEnded { value in
// Animate the box to its original location (i.e. with zero translation).
offsetAnimator.target = .zero
// We want the box to animate to its original location, so use an `animated` mode.
// This is different than the
offsetAnimator.mode = .animated
// Take the velocity of the gesture, and give it to the animator.
// This makes the throw animation feel natural and continuous.
offsetAnimator.velocity = CGPoint(x: value.velocity.width, y: value.velocity.height)
offsetAnimator.start()
}
)`
thank you for your help
The text was updated successfully, but these errors were encountered:
I get this error when I try to use this in swiftui: "Animation must have a non-nil
value
before starting."my code is here:
`.onAppear {
offsetAnimator.value = .zero
thank you for your help
The text was updated successfully, but these errors were encountered: