Commit e0e58244 authored by sczs's avatar sczs Committed by Chromium LUCI CQ

[ios] Sets the content suggestions offset after a delay

Since the Discover feed uses a diffable data source its not completely
loaded at this time, in order to make this work we need to add a short
delay before scrolling.

Bug: 1108403
Change-Id: Id40dcc0655fe3fe01fdd4966611c475dce44bcca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2587474Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836636}
parent 2e4ef53d
...@@ -60,6 +60,8 @@ const CGFloat kDiscoverFeedFeaderHeight = 30; ...@@ -60,6 +60,8 @@ const CGFloat kDiscoverFeedFeaderHeight = 30;
// Minimum height of the Discover feed content to indicate that the articles // Minimum height of the Discover feed content to indicate that the articles
// have loaded. // have loaded.
const CGFloat kDiscoverFeedLoadedHeight = 1000; const CGFloat kDiscoverFeedLoadedHeight = 1000;
// Delay before the CollectionView scrolls to the saved position.
const CGFloat kDelayBeforeScrollingToSavedOffset = 0.3;
} }
NSString* const kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix = NSString* const kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix =
...@@ -952,9 +954,25 @@ NSString* const kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix = ...@@ -952,9 +954,25 @@ NSString* const kContentSuggestionsMostVisitedAccessibilityIdentifierPrefix =
self.traitCollection.preferredContentSizeCategory) + self.traitCollection.preferredContentSizeCategory) +
collection.contentInset.bottom)); collection.contentInset.bottom));
if (collection.contentOffset.y != offset) { if (collection.contentOffset.y != offset) {
collection.contentOffset = CGPointMake(0, offset); // Since the Discover feed uses a diffable data source its not completely
// Update the constraints in case the omnibox needs to be moved. // loaded at this time, in order to make this work we need to add a short
[self updateConstraints]; // delay before scrolling.
if (IsDiscoverFeedEnabled()) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
static_cast<int64_t>(
kDelayBeforeScrollingToSavedOffset *
NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
collection.contentOffset = CGPointMake(0, offset);
// Update the constraints in case the omnibox needs to
// be moved.
[self updateConstraints];
});
} else {
collection.contentOffset = CGPointMake(0, offset);
// Update the constraints in case the omnibox needs to be moved.
[self updateConstraints];
}
} }
} }
_initialContentOffset = NAN; _initialContentOffset = NAN;
......
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