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

Scroll content a bit after hiding #86

Open
denis-obukhov opened this issue Feb 9, 2021 · 1 comment
Open

Scroll content a bit after hiding #86

denis-obukhov opened this issue Feb 9, 2021 · 1 comment

Comments

@denis-obukhov
Copy link

Is it possible to show that new content is being loaded? For now, it's quite unclear to the user until they manually scroll to the bottom. For instance, it could be scrolling a bit to the bottom to show a part of the new cell that appeared.

@pronebird
Copy link
Owner

pronebird commented Feb 14, 2021

The library is implemented as a non-intrusive infinite scroll control. The new rows replace the activity indicator if user remains at the bottom of the scroll view, however in all other cases it never takes user to the new content.

You can probably try implementing what you suggest outside of the library & see how it works. This is something that came to my mind:

class MyTableViewController: UITableViewController {
    var restoreOffset: CGPoint?

    override func viewDidLoad() {
        tableView.addInfiniteScroll { [weak self] (tableView) -> Void in
            // update table view

            tableView.finishInfiniteScroll { (tableView) in
                self?.restoreOffset = tableView.contentOffset

                // scroll to first added row
                tableView.scrollToRow(indexPath: /* indexPath of the first added row */, at: .middle, animated: true)
            }
        }
    }

    override func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        // restore scroll position after deceleration
        if let restoreOffset = restoreOffset {
            scrollView.setContentOffset(restoreOffset, animated: true)
            self.restoreOffset = nil
        }
    }
}

But I am not very enthusiastic about such complex scrolling behaviors as I think that, more often than not, it interferes with the user making the overall user experience worse.

Please elaborate more on your idea if I misunderstood you.

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

No branches or pull requests

2 participants