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

Prevent unnecessary layout pass #254

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Sources/Public/CalendarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ public final class CalendarView: UIView {

public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)

// This can be called with a different trait collection instance, even if nothing in the trait
// collection has changed (noticed from SwiftUI). We guard against this to prevent and
// unnecessary layout pass.
guard traitCollection.layoutDirection != previousTraitCollection?.layoutDirection else {
return
}
setNeedsLayout()
}

Expand Down
Loading