-
-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve the scroll view position while moving between states #587
Comments
Thanks for your report. I'm fixing this problem now. |
what is the status of this, please? @scenee |
Oh no! I had forgotten to continue working on this branch. Thank you for reminding me. Indeed, while that commit certainly resolves the issue, I was thinking I couldn't merge it alone because the library also needs to consider other cases. I'll review the branch again and work towards merging it. |
Thanks for your reply, I appreciate it. |
Previously, the panel might not consistently keep its scroll content offset when moving from its most expanded state to another. Changes made in this commit: * Removed the need for an offset reset when users manually move the panel outside of the tracking scroll view. * Stopped the scroll offset reset of the `stopScrollDeceleration` flag in the `panningEnd` method when the panel transitions from its most expanded state because there is no issue without the reset.
Previously, the panel might not consistently keep its scroll content offset when moving from its most expanded state to another. Changes made in this commit: * Keep the content offset of tracking scroll view in the following cases. A panel is moved... 1. Outside of the tracking scroll view. 2. Inside of a navigation bar/toolbar over the tracking scroll view. * Stopped the scroll offset reset of the `stopScrollDeceleration` flag in the `panningEnd` method when the panel transitions from its most expanded state because there is no issue without the reset.
This fix broke a piece of code of mine. I wonder if anybody could help me adjust it to work well with more modern versions of FloatingPanel. Here's what I want to achieve: If the user expands the panel to .full state and scrolls down to the bottom of the panel, and then drags the handle down to move it to .half state, the content should scroll to top. Otherwise the user has to expand the panel again, manually scroll to top, and then pull it down to .half again, which is tedious. Here's what I used to do: func floatingPanelDidChangeState(_ fpc: FloatingPanelController) {
// If the content is scrolled down, restore it to the top when the state of the panel
// changes, to prevent an awkward state where you have to move the panel up to full
// in order to be able to scroll the content up again
if fpc.state == .tip || fpc.state == .half {
DispatchQueue.main.async {
fpc.trackedScrollView?.setContentOffset(CGPoint.zero, animated: fpc.state == .half)
}
}
} The new pinning of the scroll position immediately sets the content offset back to the original position. I can make it work by delaying the async call an arbitrary amount of time, but that feels very hacky. Given this new functionality, how can I achieve the behavior I'm after? Can I prevent the pinning, or make my contentOffset adjustment in a more suitable callback? |
…ing state transitions In scenee#587 the behavior of the panel was changed so that the content of the tracked scroll view is always locked during state transitions. In some cases it's useful to be able to adjust the scroll offset during these transitions, so a delegate method has been introduced letting the user of the library decide on this behavior.
Description
In the Maps example, while changing the search panel states the scroll view moves to the top.
Expected behavior
The scroll view position should be preserved while changing states like in Apple Maps.
Actual behavior
While changing states the scroll view moves to the top.
Steps to reproduce
Move the Search panel to the full state, scroll to the bottom of the scroll view, then move the panel to the half state.
Code example that reproduces the issue
I am using the code in the Maps example.
How do you display panel(s)?
Added as a child view controller.
How many panels do you displays?
1
Environment
Library version
2.6.1
Installation method
I am using the example included in the library.
iOS version(s)
16.4.1
Xcode version
14.3
The text was updated successfully, but these errors were encountered: