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 implicit animationg bug #262

Merged
merged 3 commits into from
Aug 30, 2023
Merged

Conversation

bryankeller
Copy link
Contributor

@bryankeller bryankeller commented Aug 30, 2023

Details

This fixes an issue that could cause the calendar to layout with an odd animation. Recently, we changed the way layoutSubviews works - we check if we're currently in an animation closure, and if we are, we layout a larger region than what's currently visible so that offscreen items animate in / away correctly.

This behavior change only makes sense if the reason we're in layoutSubviews is because of a call to setContent (which will do some animation preparation). If we end up in layoutSubviews in an animation closure without setContent getting called first, then we didn't do any animation preparation in setContent, and the new layoutSubviews behavior doesn't make sense anymore.

The solution is to set a flag in setContent to indicate that the next call to layoutSubviews should use the new behavior for animated updates, rather than checking if we're in an animation closure (which could happen if a random part of code calls layoutIfNeeded in an animation closure without also calling setContent first).

Related Issue

N/A

Motivation and Context

Found a bug in the Airbnb app

How Has This Been Tested

Example app, Airbnb app

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@bryankeller bryankeller added the bug Something isn't working label Aug 30, 2023
brynbodayle
brynbodayle previously approved these changes Aug 30, 2023
Copy link
Contributor

@brynbodayle brynbodayle left a comment

Choose a reason for hiding this comment

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

Makes sense!

@bryankeller
Copy link
Contributor Author

bryankeller commented Aug 30, 2023

@brynbodayle I fixed another (related) issue with pinned days of the week. I was drawing them at weird positions due to the whole 3x visible bounds thing that I added for animated layout passes. The 2 new commits fix that + add unit tests for it.

@@ -242,7 +248,7 @@ final class VisibleItemsProvider {

// Handle pinned day-of-week layout items
if case .vertical(let options) = content.monthsLayout, options.pinDaysOfWeekToTop {
handlePinnedDaysOfWeekIfNeeded(yContentOffset: bounds.minY, context: &context)
handlePinnedDaysOfWeekIfNeeded(yContentOffset: offset.y, context: &context)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't want to use the extended bounds for this, otherwise we'll render these pinned items off screen

@bryankeller bryankeller merged commit 937f2a9 into master Aug 30, 2023
2 checks passed
@bryankeller bryankeller deleted the bk/fix-implicit-animation-bug branch August 30, 2023 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants