Skip to content
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

Add floatingPanel(_:contentOffsetForPinning:) delegate method #314

Merged
merged 7 commits into from
Feb 24, 2020
Merged

Conversation

scenee
Copy link
Owner

@scenee scenee commented Feb 5, 2020

FloatingPanelController asks the delegate for the content offset of a tracked scroll view pinned when a panel moves.

If you do not implement this method, the controller uses a value of the content offset plus the content insets. This method will not be called if the controller doesn't track any scroll view.

The reason why it's added is because a visual content origin of a scroll view is not always equal to its content offset plus its content insets. One of the cases is issue #304.

You can fix #304 by returning a value for a navigation bar with a large title as below.

return CGPoint(x: 0.0, y: 0.0 - trackedScrollView.contentInset.top - 148.0)

See also "Show Navigation Controller" in the Samples app.

@scenee
Copy link
Owner Author

scenee commented Feb 5, 2020

I'm considering whether the delegate name is appropriate or not. Please give me your advice if you have any ideas.

The content offset preservation should be applied only when
`FloatingPanelController.contentInsetAdjustmentBehavior` is `.always`.
This is because the library user loses control of the initial offset.
@scenee scenee merged commit 65f67c9 into master Feb 24, 2020
@scenee scenee deleted the iss-304 branch February 24, 2020 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with prefersLargeTitles when scrollview bounce locked.
1 participant