fermoya / SwiftUIPager

Native Pager in SwiftUI
MIT License
1.29k stars 172 forks source link

[FEAT] Scroll to Top functionality, similar to ScrollView #117

Closed JetPlaneJJ closed 4 years ago

JetPlaneJJ commented 4 years ago

Is your feature request related to a problem? Please describe. This feature is not related to a problem I currently have, but it would be nice to have a "scroll to top" animation similar to the way ScrollView scrolls to the top upon tapping the status bar/notch.

Describe the solution you'd like Ability to scroll back or go back to the top page after tapping the notch/status bar/top if currently not at the top page. Ideally there could be an animation of "scrolling" like ScrollView's scrollToTop.

Describe alternatives you've considered I have looked online at how other people are doing "scroll to top", but they are all ScrollViews or UITableViews. My current workaround is to have people tap a button on the bottom to return to the top page instantly (no animation, just setting current page index to 0).

fermoya commented 4 years ago

Hi @JetPlaneJJ . I don't think that's possible, I don't know how I could possibly detect a status bar tap. Especially because Pager might not cover that area of the screen (the area of interaction is limited to the space it covers). That functionality that you describe is reserved for the system only. Also, I don't think it makes sense unless it's a vertical scroll (or vertical Pager in this case).

As a workaround, I'm thinking you could have a transparent Button covering the top of the screen, with a fixed height and making sure you extend the edges. Wouldn't that work?

fermoya commented 4 years ago

I’m going to close this as I don’t think it could be implemented in the way it’s described. Feel free to reopen if any new ideas