danielsaidi / ScrollKit

ScrollKit is a SwiftUI SDK that adds powerful scroll features, like offset tracking and a header view that stretches & transforms as you pull down, and sticks to the top when you scroll.
MIT License
722 stars 26 forks source link

Can i detect when ScrollView has finished scrolling? #18

Closed gzlboy closed 3 weeks ago

gzlboy commented 5 months ago

I want to do something when scroll was finished.How can I do this? Thanks!

danielsaidi commented 5 months ago

Do you mean that when a scroll event ends and the offset stops updating?

gzlboy commented 4 months ago

Yes!I find a repository that implemented this feature: https://github.com/fatbobman/IsScrolling

In addition to the scrolling state, it will be better if i can get the scrolling direction:)

danielsaidi commented 4 months ago

Would be cool to support! I'll take a look when I get around to this project, and can meanwhile approve and merge any PR that fixes this.

gzlboy commented 4 months ago

Thanks! Look forward to this feature:)

danielsaidi commented 3 weeks ago

@gzlboy If you have the possibility to use iOS 18 and macOS 15, it has a new .onScrollPhaseChange modifier:

.onScrollPhaseChange { _, newPhase in
     ...
}

Since the SDKs scroll views use regular ScrollView underneath, you should be able to add this modifier to its content.

Since there is a native way to do this now, I will not add this to the SDK, and will thus close this issue. If you miss some feature in the SDK to be able to use it, please let me know.