From a43bdd31d3e053de100773dfaa34e7225dcf49a8 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 8 Jul 2025 09:47:39 -0700 Subject: feat: Development commit --- Sora/Data/Scroll/ScrollPositionPreferenceKey.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Sora/Data/Scroll/ScrollPositionPreferenceKey.swift (limited to 'Sora/Data/Scroll/ScrollPositionPreferenceKey.swift') diff --git a/Sora/Data/Scroll/ScrollPositionPreferenceKey.swift b/Sora/Data/Scroll/ScrollPositionPreferenceKey.swift new file mode 100644 index 0000000..6b78bdc --- /dev/null +++ b/Sora/Data/Scroll/ScrollPositionPreferenceKey.swift @@ -0,0 +1,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 + } + } +} -- cgit v1.2.3