File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ public struct HStackSnapCore<Content: View>: View {
3636 // TODO: Make this less... janky.
3737 . frame ( width: 10000 )
3838 . onPreferenceChange ( ContentPreferenceKey . self, perform: { preferences in
39-
39+ self . preferences = preferences
40+
4041 // Calculate all values once, on render. On-the-fly calculations with GeometryReader
4142 // proved occasionally unstable in testing.
4243 if !hasCalculatedFrames {
@@ -133,6 +134,15 @@ public struct HStackSnapCore<Content: View>: View {
133134 }
134135
135136 // MARK: Private
137+
138+ /// Used to check if children configuration (ids or sizes) have changed.
139+ @State private var preferences : [ ContentPreferenceData ] = [ ] {
140+ didSet {
141+ if oldValue. map ( \. id) != preferences. map ( \. id) || oldValue. map { $0. rect. size } != preferences. map { $0. rect. size } {
142+ hasCalculatedFrames = false
143+ }
144+ }
145+ }
136146
137147 @State private var hasCalculatedFrames : Bool = false
138148
You can’t perform that action at this time.
0 commit comments