From a18b8db23a7295751269299080386febb2b63a16 Mon Sep 17 00:00:00 2001 From: Bryan Keller Date: Tue, 12 May 2026 18:39:18 +0100 Subject: [PATCH] Add flag to test reducing unnecessary layout invalidations --- .../Public/MagazineLayoutInvalidationContext.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/MagazineLayout/Public/MagazineLayoutInvalidationContext.swift b/MagazineLayout/Public/MagazineLayoutInvalidationContext.swift index f688a09..4119ca6 100644 --- a/MagazineLayout/Public/MagazineLayoutInvalidationContext.swift +++ b/MagazineLayout/Public/MagazineLayoutInvalidationContext.swift @@ -20,8 +20,15 @@ import UIKit /// Used to indicate that collection view properties and/or delegate layout metrics changed. public final class MagazineLayoutInvalidationContext: UICollectionViewLayoutInvalidationContext { - /// Indicates whether to recompute the positions and sizes of elements based on the current - /// collection view and delegate layout metrics. - public var invalidateLayoutMetrics = true + /// A temporary flag to enable safely testing a change to how layout invalidation works. + public static var _invalidateLayoutMetricsDefaultValue = true + + /// Indicates whether to recompute the positions and sizes of elements based on the current collection view and delegate layout + /// metrics. + /// + /// Defaults to `false`. Set to `true` when delegate-provided layout values (e.g. item size + /// modes, header/footer visibility, section metrics) have changed and the layout needs to + /// re-query the delegate. + public var invalidateLayoutMetrics = _invalidateLayoutMetricsDefaultValue }