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

fix(next/iOS): fix blinking during initial render when initialPage !=0 in non-fabric version #793

Closed
wants to merge 1 commit into from

Conversation

ku8ar
Copy link
Contributor

@ku8ar ku8ar commented Nov 17, 2023

Summary

Fabric has a trick with -1. Unfortunately here we can't use it. The only place that allows a valid goTo from the initial page is layoutSubviews.

Test Plan

  1. render pager with initialPage bigger than zero and many pages inside
  2. pager is blinking (for a brief moment)

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I updated the typed files (TS and Flow)

Copy link
Member

@krozniata krozniata left a comment

Choose a reason for hiding this comment

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

Hey @ku8ar!
Could you provide video showing blinking issue? I couldn't reproduce it
Also that change introduced a bug causing initial page not to be set correctly once every few render (initialPage set to e.g.7 with 100 pages in BasicPagerViewExample)

@ku8ar
Copy link
Contributor Author

ku8ar commented Nov 23, 2023

Thats weird what you say. Maybe you accidentally ran the fabric version? Here is video that demonstrates problem (full-screen video is rendered inside pager-view):

ddd.mov

After this patch, initial page is always rendered correctly when pager-view is loaded:

eee.mov

Screen/pager-view rendering code in our app has not been changed since version 6.x.

Comment on lines +51 to +59
- (void)layoutSubviews {
[super layoutSubviews];
if (!_scrolledToInitialPage) {
_scrolledToInitialPage = YES;
[self goTo:self.initialPage animated:false];
}
}


Copy link
Member

Choose a reason for hiding this comment

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

Looks like bug causing initialPage sometimes not to be set correctly can be easily fixed by adding check for contentSize like:

-(BOOL)isScrollViewContentSizePositive {
    return [self isHorizontal] ? _scrollView.contentSize.width > 0 : _scrollView.contentSize.height > 0;
}

and adding it to

-(void)layoutSubviews {
     [super layoutSubviews];
     if (self.isScrollViewContentSizePositive && !_scrolledToInitialPage) {
         _scrolledToInitialPage = YES;
         [self goTo:self.initialPage animated:false];
     }
 }

Could you please add it?

@troZee troZee deleted the branch callstack:next March 31, 2024 18:15
@troZee troZee closed this Mar 31, 2024
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