-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
.gesture(
DragGesture()
.onChanged { value in
guard !isAnimating else { return }
// Update the position while dragging with 弹性跟手
withAnimation(.spring(duration: onChangedDuration, bounce: onChangedBounce)) {
self.position = value.location
}
}
.onEnded { _ in
guard !isAnimating else { return }
// Animate back to center when released with 速度继承
withAnimation(.spring(duration: onEndedDuration, bounce: onEndedBounce,blendDuration: 0.25)) {
self.position = CGPoint(
x: geometry.size.width / 2,
y: geometry.size.height / 2
)
}
}
)
Metadata
Metadata
Assignees
Labels
No labels