Skip to content

#BUG# initialScrollOffset causes incorrect scrollView behavior since version 2.8.0 #658

@MrPans

Description

@MrPans

Description

Since version 2.8.0, the Core records the initialScrollOffset in the panningBegan(at:) method. However, panningBegan(at:) is only called when the user scrolls the scrollView manually, not when setContentOffset is used programmatically. This causes an issue when developers try to reset the scrollView using setContentOffset while changing the floating panel state from .full to .half. The floating panel incorrectly uses the previously recorded initialScrollOffset to set the scrollView’s contentOffset, which is not the expected behavior.

Expected behavior

The Core should correctly record the contentOffset of the scrollView when setContentOffset is called programmatically.

Actual behavior

The Core only updates based on pan gesture changes and does not handle programmatic changes to the contentOffset.

Steps to reproduce

  1. Scroll the scrollView to the middle.
  2. Reset the scrollView’s contentOffset to .zero.
  3. Change the floating panel state to .half.

Code example that reproduces the issue

    func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
        resetSearchBar()
        panelController?.move(to: .half, animated: true, completion: nil)
        scrollView?.scrollRectToVisible(CGRect(x: 0, y: 0, width: 100, height: 10), animated: true)
    }

How do you display panel(s)?

  • Add as child view controllers

How many panels do you displays?

  • 1

Environment

Library version
latest

Installation method

  • CocoaPods

iOS version(s)
iOS 18

Xcode version
16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions