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 to new position if swipe container size chages (ex: orientatio… #1137

Merged

Conversation

trexpert
Copy link
Contributor

The scrollTo method should not be called only on initial render. onLayout invoke can be caused by an orientation change or swipe container resize. So whenever we have got slides inside we should consider to call scrollTo

Is it a bugfix ?

Yes (No ticket # yet)
Bug can be tested on Android tablet (Galaxy tab A). Just make a fullscreen swiper fill with some colored boxes and move to a slideindex more then 0. Then change the orientation. The slider will stack in between 2 slides and not adjust it's scroll position.

Is it a new feature ?

No

Describe what you've done:

Just moved the scrollTo method outside the initialRender method. I think there is no need for the initialRender flag anymore

How to test it ?

See Bugfix

@Rotemy
Copy link

Rotemy commented Jul 30, 2020

This is working perfectly, I just tested it on Android and iOS and it should be merged.

@Rotemy
Copy link

Rotemy commented Jul 31, 2020

@trexpert
Btw, i'm working with old Android devices and for them I had to surround the scrollTo with setTimeout 0. Like that:

setTimeout(() => {
        this.scrollView.scrollTo({ ...offset, animated: false })
      }, 0);

Copy link
Contributor Author

@trexpert trexpert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just fine

@trexpert
Copy link
Contributor Author

);

i guess the project maintainer is not interested in pull requests.... staying open for half a year now...

@Rotemy
Copy link

Rotemy commented Jul 31, 2020

@trexpert yeah.. now I'll need to do a patch in order to get this fix.

@ArrayZoneYour ArrayZoneYour merged commit 5827a80 into leecade:master Jul 31, 2020
@Rotemy
Copy link

Rotemy commented Jul 31, 2020

@ArrayZoneYour @trexpert you need to surround it with setTimeout 0 to make it work in slow old devices

@trexpert trexpert deleted the FixScrollPositionOnLayoutChange branch August 12, 2020 12:20
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

Successfully merging this pull request may close these issues.

3 participants