#1666 (toggling fullscreen loses story position)

- The story scroll position is now maintained (as best as possible) when toggling fullscreen.
This commit is contained in:
David Sinclair 2022-04-01 21:18:54 -07:00 committed by Samuel Clay
parent b8453fe985
commit d812bfdfdd
4 changed files with 17 additions and 7 deletions

View file

@ -4246,6 +4246,11 @@
- (void)markScrollPosition:(NSInteger)position inStory:(NSDictionary *)story {
if (position < 0) return;
if (position == 0) {
position = 1;
}
__block NSNumber *positionNum = @(position);
__block NSDictionary *storyDict = story;

View file

@ -68,6 +68,7 @@ UIActionSheetDelegate, WKNavigationDelegate> {
- (void)tryScrollingDown:(BOOL)down;
- (void)scrollPageDown:(id)sender;
- (void)scrollPageUp:(id)sender;
- (void)realignScroll;
- (void)changeWebViewWidth;
- (void)showUserProfile:(NSString *)userId xCoordinate:(int)x yCoordinate:(int)y width:(int)width height:(int)height;
- (void)checkTryFeedStory;

View file

@ -1495,6 +1495,11 @@
}
}
- (void)realignScroll {
hasScrolled = NO;
[self scrollToLastPosition:YES];
}
- (void)scrollToLastPosition:(BOOL)animated {
if (hasScrolled) return;
hasScrolled = YES;

View file

@ -638,18 +638,15 @@
}
- (void)reorientPages {
[self applyNewIndex:currentPage.pageIndex-1 pageController:previousPage supressRedraw:YES];
[self applyNewIndex:currentPage.pageIndex+1 pageController:nextPage supressRedraw:YES];
[self applyNewIndex:currentPage.pageIndex pageController:currentPage supressRedraw:YES];
NSInteger currentIndex = currentPage.pageIndex;
[self resizeScrollView]; // Will change currentIndex, so preserve
[self applyNewIndex:currentPage.pageIndex-1 pageController:previousPage supressRedraw:YES];
[self applyNewIndex:currentPage.pageIndex+1 pageController:nextPage supressRedraw:YES];
[self applyNewIndex:currentPage.pageIndex pageController:currentPage supressRedraw:YES];
// Scroll back to preserved index
CGRect frame = self.scrollView.bounds;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
frame = self.scrollView.bounds;
}
if (self.isHorizontal) {
frame.origin.x = frame.size.width * currentIndex;
@ -663,6 +660,8 @@
// NSLog(@"---> Scrolling to story at: %@ %d-%d", NSStringFromCGRect(frame), currentPage.pageIndex, currentIndex);
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self hideNotifier];
[currentPage realignScroll];
}
- (void)refreshHeaders {