paololeonardi / WaterfallGrid

A waterfall grid layout view for SwiftUI.
MIT License
2.39k stars 117 forks source link

How do I get the position while scrolling ? #23

Closed productdevbook closed 4 years ago

productdevbook commented 4 years ago

How do I get the position while scrolling? I will hide the search bar according to it.

paololeonardi commented 4 years ago

Hi @mkalayci35, that's more a SwiftUI ScrollViews question. At the moment, they don't have an official API to get the scroll position.

But you could obtain it anyway with the use of View Preferences. Have a look at this article https://swiftui-lab.com/scrollview-pull-to-refresh/, it's about the pull to refresh but you can adapt it to hide the search bar once you get the scrollOffset.

Unfortunatly, that also means you'll have to modify WaterfallGrid for your specific need.

Hope this helps, Thanks.