Skip to content
This repository was archived by the owner on Sep 25, 2021. It is now read-only.
This repository was archived by the owner on Sep 25, 2021. It is now read-only.

iOS 12 initial scroll positions and scroll indicator insets #150

@domchristie

Description

@domchristie

These issues can be demonstrated using the turbolinks-ios demo app running the latest master version.

iOS 11.1 [GIF] works as expected

iOS 12.1 [GIF] scroll indicator is offset (by the height of the navigation bar) and the scroll position is not reset after loading a new page; it seemingly maintains the scroll position of the previous page:

I have looked into this a little, and my guess is that the scrollIndicatorInsets are relative to the content insets (or safe area?), and so are unnecessarily offset again. However, I have not been able to determine why the behaviour differs between iOS 11 and 12. adjustedContentInset and contentInsetAdjustmentBehavior were both introduced recently, but they were both added in iOS 11, and there doesn't seem to be any documentation that indicates a a change between 11 and 12. I'm not sure which behaviour is correct, so perhaps this is an iOS bug which was either fixed, or introduced in iOS 12?


Whilst looking into this, I came across this talk from WWDC 2018 about scroll views, which includes the following:

most of the time, if not all the time, you're really going to want to leave [contentInsetAdjustmentBehavior] at [.automatic,] its default value.

our last behavior: .never. Now with this one, as you expect, that means the scroll view is never going to adjust its content inset.
However, that has some side effects. For one, that means that the scroll view will end up propagating safe area insets on all of its edges just like a regular view. And as we talked about before, that might end up giving you some behavior you don't really want. For example, if you recall your layout margins are relative to the safe area, which means your layout margins might end up increasing or changing as a result of this. This is also going to disable some very helpful automatic behaviors that scroll view provides like automatic scroll indicator insets. And so if you do a search online and you see a favorite question and answer website suggesting that you set your scroll view's content inset adjustment behavior to .never, consider instead using additional safe area insets to increase the safe area insets. … Or you could consider just modifying the content inset directly

Tyler Fox: https://developer.apple.com/videos/play/wwdc2018/235/?time=1359

As well as Tyler's tweet and so I'm wondering if this is something that turbolinks-ios could adhere to? This wouldn't fix the initial scroll position issue, but I'm thinking it might help with scroll indicator issues in future versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions