Skip to content

Commit 13259e7

Browse files
author
mac
committed
add scroll restore delay time config
1 parent d5c6cf0 commit 13259e7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Sources/SwiftUIX/Intramodular/List/CocoaList-UIKit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public struct CocoaList<
9494
uiViewController.reloadData()
9595
if scrollPosition.wrappedValue.activate {
9696
uiViewController.scroll(scrollPosition: scrollPosition.wrappedValue)
97-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
97+
DispatchQueue.main.asyncAfter(deadline: .now() + scrollPosition.wrappedValue.restoreDelay, execute: {
9898
var scrollPosition = scrollPosition.wrappedValue
9999
scrollPosition.activate = false
100100
self.scrollPosition.wrappedValue = scrollPosition

Sources/SwiftUIX/Intramodular/List/ListScrollPosition.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ public struct ListScrollPosition {
1313
var animated: Bool
1414

1515
var activate: Bool
16+
var restoreDelay: Double
1617

17-
public init(indexPath: IndexPath = IndexPath(row: 0, section: 0), anchor: UITableView.ScrollPosition = .none, animated: Bool = false, activate: Bool = false) {
18+
public init(indexPath: IndexPath = IndexPath(row: 0, section: 0), anchor: UITableView.ScrollPosition = .none, animated: Bool = false, activate: Bool = false, restoreDelay: Double = 0.1) {
1819
self.indexPath = indexPath
1920
self.anchor = anchor
2021
self.animated = animated
2122
self.activate = activate
23+
self.restoreDelay = restoreDelay
2224
}
2325
}
2426

0 commit comments

Comments
 (0)