Fix VisibleItemsProvider.correctedScrollToItemFrameForContentBoundaries #329
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Details
This fixes the behaviour of VisibleItemsProvider.correctedScrollToItemFrameForContentBoundaries during animated scroll to a date on calendars with scrollable content where all months can be visible at once, fully or partially.
The main issue is that the calendar scrolls to the very top, when requested to scroll to an arbitrary date of the first month using firstFullyVisiblePosition.
This is due to an incorrect assumption in VisibleItemsProvider.correctedScrollToItemFrameForContentBoundaries, that if context.contentEndBoundary is known, then content is smaller than
bounds. There certainly can be cases, when the first and the last months in the calendar are visible (i.e. context.contentStartBoundary and context.contentEndBoundary are known) and the content is still larger thanbounds. Therefore, we should explicitly check if the content is actually smaller thanbounds, before adjusting scroll towardsminimumScrollOffset.Related Issue
N/A
Motivation and Context
Bug fix / animation improvements
How Has This Been Tested
Example app. In SingleDaySelectionDemoViewController, update the endDate, so that the visibleDateRange has a span of three months:
let endDate = calendar.date(from: DateComponents(year: 2020, month: 03, day: 31))!and add a call to
scrollmethod at the end ofdaySelectionHandler:Build and run.
Types of changes
Checklist