triniwiz / nativescript-pager

Apache License 2.0
90 stars 48 forks source link

Android: weird issue when changing orientation #167

Open felixkrautschuk opened 4 years ago

felixkrautschuk commented 4 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it.

When changing the orientation from portrait to landscape and then back to portrait, the user sees 95% of the next page.... just have a look at the GIF:

pager_android_orienation_issue

This issue does not occur if the user has selected the first page in the pager. But as soon as he goes forward to the second page, then you can see this side effect.

pager_android_orienation_issue2

Is there any code involved?

NSPagerIssueOrientationAndroid.zip

It is also reproducable on the demo app of this repo.

felixkrautschuk commented 4 years ago

temporary workaround:

app.on(app.orientationChangedEvent, function(args) {
    setTimeout(function() {
        if(pager.selectedIndex > 0) {
            let temp = pager.selectedIndex;
            pager.scrollToIndexAnimated(temp-1, true);
            pager.scrollToIndexAnimated(temp, true);
         }
     }, 300);
});

but I hope there will be an official fix for this issue, because the workaround still has some optical side effects

triniwiz commented 4 years ago

Try forcing a layout e.g requestLayout

felixkrautschuk commented 4 years ago

@triniwiz I already tried pager.requestLayout(); and

pager.eachChild(function (view) {
    view.requestLayout();
});

but unfortunately that does not help