fix carousel view scrolling animation

pull/874/head
ryanzhao 2 years ago
parent 068af1136d
commit 3013f9b7fd

@ -135,15 +135,18 @@ struct PageView<Content>: View where Content: View {
let predictedEndOffset = -CGFloat(self.index) * geometry.size.width + value.predictedEndTranslation.width
let predictedIndex = Int(round(predictedEndOffset / -geometry.size.width))
self.index = self.clampedIndex(from: predictedIndex)
withAnimation(.easeOut) {
withAnimation(.easeOut(duration: 0.2)) {
self.dragging = false
}
// FIXME: This is a workaround for withAnimation() not having completion callback
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
switch self.index {
case 0: self.index = self.maxIndex - 1
case self.maxIndex: self.index = 1
default: break
}
}
}
)
}
.clipped()

Loading…
Cancel
Save