Commit 28bff279 authored by Maxime Charland's avatar Maxime Charland Committed by Commit Bot

Add handler for scrollToTop behaviour in NTP

Previously, scrollToTop while the omnibox is focused would scroll to the top and 2 omnibox would be visible.

Now, first unfocus omnibox, then allow scrollToTop.

Before: https://drive.google.com/file/d/1zn69R672sRTRe6GG3s4Mc7WVo2Q6G4xo/view?usp=sharing
After (Patchset 1-6) : https://drive.google.com/file/d/1fiiZZBwWfXb7gb66dCfOwW6yGSBemayi/view?usp=sharing
After stuttering fix (Patchset 7+) : https://drive.google.com/file/d/1A2FavkilxFqFVFjh2A5wN0SATsrMENGx/view?usp=sharing

Change-Id: I3c026bb800a243ef0bab150cfac4f696bbb14c40
Bug: 965473
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2201896
Commit-Queue: Maxime Charland <mcharland@google.com>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarTommy Martino <tmartino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770853}
parent f8f7214c
......@@ -214,6 +214,10 @@ initWithCollectionController:
[self.headerController updateConstraints];
}
- (void)resetPreFocusOffset {
self.collectionShiftingOffset = 0;
}
- (void)unfocusOmnibox {
[self.headerController unfocusOmnibox];
}
......
......@@ -22,6 +22,9 @@
// Updates the fake omnibox to adapt to the current orientation.
- (void)updateFakeOmniboxOnNewWidth:(CGFloat)width;
// Sets the amount of scrolling needed when unfocusing the omnibox to 0.
- (void)resetPreFocusOffset;
// Unfocuses the omnibox.
- (void)unfocusOmnibox;
......
......@@ -564,6 +564,16 @@ NSString* const kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix =
scrollView.contentOffset.y >= [self.headerSynchronizer pinnedOffsetY];
}
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView*)scrollView {
// User has tapped the status bar to scroll to the top.
// Prevent scrolling back to pre-focus state, making sure we don't have
// two scrolling animations running at the same time.
[self.headerSynchronizer resetPreFocusOffset];
// Unfocus omnibox without scrolling back.
[self.headerSynchronizer unfocusOmnibox];
return YES;
}
- (void)scrollViewWillBeginDragging:(UIScrollView*)scrollView {
[self.overscrollActionsController scrollViewWillBeginDragging:scrollView];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment