Scrollview starts too low, then bounces up


#1

When I load a page that has a scrollview, the scrollview appears first lower on the page, and then bounces up after just under a second. So, if the scrollview is the only layout on the page, the page starts with white at the top, and then only after that the scrollview goes up to its proper position at the top of the page. This is on iOS (I have not tested android).

For a visual, see this discussion: https://stackoverflow.com/questions/47273004/why-is-the-scrollview-jumping-up-and-down-when-returning-to-main-view-on-ios?rq=1

Is there a solution for this?

(The stack overflow answer is to play around with the margin top of the page, but I am wondering if there is some other way of addressing this, or if is in fact a bug)


#2

I think thats a bug in NativeScript, hopefully fixed in 4.x. Can you confirm which version you are using?

This is a patch fix for 3.4 I’m using, in the loaded event of ScrollView

if (isIOS && iosUtils.MajorVersion > 10) {
            scrollView.nativeViewProtected.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Never;
 }

#3

I am using nativescript v 3.10.10 (with Angular). If version 4.x fixes stuff like this, I might upgrade.

Thanks for your code.

Can you share the imports you use for that code?


#4
import { isIOS } from "platform";
import { ios as iosUtils } from "utils//utils";

#5

Thank you. And also it looks like you are correct–I have upgraded to Nativescript v4.1, and the problem is no longer present.

FYI for others, I followed the upgrade steps here: https://docs.nativescript.org/angular/releases/upgrade-instructions