diff options
| author | Fuwn <[email protected]> | 2025-08-05 21:44:18 +0200 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-08-05 21:44:18 +0200 |
| commit | aca046f9c36a87317fdbb76fee336e3b5920f9ac (patch) | |
| tree | f78eeb9b9fe9d08eeff89ff3d3cc722188544e55 /Sora/Views/Post/Grid | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-aca046f9c36a87317fdbb76fee336e3b5920f9ac.tar.xz sora-testing-aca046f9c36a87317fdbb76fee336e3b5920f9ac.zip | |
feat: Development commit
Diffstat (limited to 'Sora/Views/Post/Grid')
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridView.swift | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index a63bf97..955abd4 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -19,6 +19,21 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length @State private var scrollID: String? @State private var cachedColumnsData: ColumnsDataCache? @State private var scrollDebounceTask: Task<Void, Never>? + @State private var lastScrollCaptureTime: CFTimeInterval = CFAbsoluteTimeGetCurrent() + + private var throttledScrollID: Binding<String?> { + Binding( + get: { scrollID }, + set: { newValue in + let now = CFAbsoluteTimeGetCurrent() + + if now - lastScrollCaptureTime > 0.5 { + lastScrollCaptureTime = now + scrollID = newValue + } + } + ) + } @Environment(\.isSearching) private var isSearching @@ -145,8 +160,7 @@ struct PostGridView: View { // swiftlint:disable:this type_body_length .id(queryID) .transition(.opacity) } - .scrollPosition(id: $scrollID, anchor: .top) - .scrollTargetBehavior(.viewAligned) + .scrollPosition(id: throttledScrollID, anchor: .top) #if os(iOS) .searchable( text: $manager.searchText, |