blob: 6b78bdc1c8b528dc5bf3488f251e992ab1c4ffdc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import SwiftUI
struct ScrollPositionPreferenceKey: PreferenceKey {
typealias Value = ScrollPositionPreference?
static var defaultValue: Value = nil
static func reduce(value: inout Value, nextValue: () -> Value) {
guard let next = nextValue() else { return }
if let current = value {
if abs(next.yPosition) < abs(current.yPosition) {
value = next
}
} else {
value = next
}
}
}
|