xy
This commit is contained in:
parent
e4b3a33ebc
commit
11a5cba8fa
@ -413,6 +413,12 @@ struct AvatarViewerView: View {
|
||||
@State private var panOffset: CGSize = .zero
|
||||
@State private var storedPanOffset: CGSize = .zero
|
||||
@State private var dismissOffset: CGSize = .zero
|
||||
@State private var dragMode: DragMode?
|
||||
|
||||
private enum DragMode {
|
||||
case vertical
|
||||
case horizontal
|
||||
}
|
||||
|
||||
private var currentOffset: CGSize {
|
||||
scale > 1.05 ? panOffset : dismissOffset
|
||||
@ -527,8 +533,21 @@ struct AvatarViewerView: View {
|
||||
height: storedPanOffset.height + value.translation.height
|
||||
)
|
||||
} else {
|
||||
let limitedWidth = min(max(value.translation.width, -80), 80)
|
||||
dismissOffset = CGSize(width: limitedWidth, height: value.translation.height)
|
||||
if dragMode == nil {
|
||||
if abs(value.translation.height) > abs(value.translation.width) {
|
||||
dragMode = .vertical
|
||||
} else {
|
||||
dragMode = .horizontal
|
||||
}
|
||||
}
|
||||
|
||||
switch dragMode {
|
||||
case .horizontal:
|
||||
let limitedWidth = min(max(value.translation.width, -80), 80)
|
||||
dismissOffset = CGSize(width: limitedWidth, height: 0)
|
||||
case .vertical, .none:
|
||||
dismissOffset = CGSize(width: 0, height: value.translation.height)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onEnded { value in
|
||||
@ -545,6 +564,7 @@ struct AvatarViewerView: View {
|
||||
dismissOffset = .zero
|
||||
}
|
||||
}
|
||||
dragMode = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user