Skip to content

Commit

Permalink
rename after -> until
Browse files Browse the repository at this point in the history
  • Loading branch information
gh123man committed Jul 12, 2023
1 parent c87cb00 commit 2473bf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Set the absolute offset to a fixed value:
It may be desirable for `shouldLoadMore` to be called whenever the user scrolls - even if the scroll view content didn't change. You can change this behavior with `waitForHeightChange`:
```swift
.shouldLoadMore(waitForHeightChange: .never) {
// Will be called regardless of if the height changed from a previous update
// Will be called regardless of if the content height changed from a previous update
}
```

Expand All @@ -79,7 +79,7 @@ It may be desirable for `shouldLoadMore` to be called whenever the user scrolls
```

```swift
.shouldLoadMore(waitForHeightChange: .after(2)) {
.shouldLoadMore(waitForHeightChange: .until(2)) {
// Will only be called if the content height changed since last time or after 2 seconds of no change
}
```
Expand Down
8 changes: 4 additions & 4 deletions Sources/ScrollViewLoader/ScrollViewLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Introspect

public enum HeightChangeConfig {
case always
case after(TimeInterval)
case until(TimeInterval)
case never
}

Expand All @@ -16,7 +16,7 @@ public enum OffsetTrigger {

extension View {
public func shouldLoadMore(bottomDistance offsetTrigger: OffsetTrigger = .relative(0.5),
waitForHeightChange: HeightChangeConfig = .after(2),
waitForHeightChange: HeightChangeConfig = .until(2),
shouldLoadMore: @escaping () async -> ()) -> some View {
return DelegateHolder(offsetNotifier: ScrollOffsetNotifier(offsetTrigger: offsetTrigger,
waitForHeightChange: waitForHeightChange,
Expand All @@ -25,7 +25,7 @@ extension View {
}

public func shouldLoadMore(bottomDistance offsetTrigger: OffsetTrigger = .relative(0.5),
waitForHeightChange: HeightChangeConfig = .after(2),
waitForHeightChange: HeightChangeConfig = .until(2),
shouldLoadMore: @escaping (_ done: @escaping () -> ()) -> ()) -> some View {
return DelegateHolder(offsetNotifier: ScrollOffsetNotifier(offsetTrigger: offsetTrigger,
waitForHeightChange: waitForHeightChange,
Expand Down Expand Up @@ -104,7 +104,7 @@ class ScrollOffsetNotifier: NSObject, UIScrollViewDelegate, ObservableObject {
switch waitForHeightChange {
case .always:
heightChanged = oldContentHeight != scrollView.contentSize.height
case .after(let timeInterval):
case .until(let timeInterval):
heightChanged = oldContentHeight != scrollView.contentSize.height
if !isTimerRunning {
isTimerRunning = true
Expand Down

0 comments on commit 2473bf8

Please sign in to comment.