Improve animations in image viewer.
This commit is contained in:
parent
6476b8c584
commit
c160b48b03
|
@ -96,9 +96,12 @@ struct ImagesViewer: View {
|
|||
self.rotationAngle = Angle(degrees: Double(self.currentOffset.width / 30))
|
||||
} else {
|
||||
// Bigger images we can move only horizontally (we have to include magnifications).
|
||||
let offsetWidth = (amount.translation.width / self.finalMagnification) + self.accumulatedOffset.width
|
||||
let offsetWidth = (amount.predictedEndTranslation.width / self.finalMagnification) + self.accumulatedOffset.width
|
||||
|
||||
withAnimation(.spring()) {
|
||||
self.currentOffset = CGSize(width: offsetWidth, height: 0)
|
||||
}
|
||||
}
|
||||
} .onEnded { amount in
|
||||
self.accumulatedOffset = CGSize(width: (amount.predictedEndTranslation.width / self.finalMagnification) + self.accumulatedOffset.width,
|
||||
height: (amount.predictedEndTranslation.height / self.finalMagnification) + self.accumulatedOffset.height)
|
||||
|
@ -115,6 +118,7 @@ struct ImagesViewer: View {
|
|||
withAnimation(.linear(duration: 0.3).delay(0.1)) {
|
||||
self.currentOffset = CGSize.zero
|
||||
self.accumulatedOffset = CGSize.zero
|
||||
self.rotationAngle = Angle.zero
|
||||
}
|
||||
} else {
|
||||
// Close the screen.
|
||||
|
@ -134,8 +138,6 @@ struct ImagesViewer: View {
|
|||
} else {
|
||||
self.moveToEdge()
|
||||
}
|
||||
|
||||
self.rotationAngle = Angle.zero
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue