File tree 1 file changed +11
-1
lines changed
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 {
36
36
// TODO: Make this less... janky.
37
37
. frame ( width: 10000 )
38
38
. onPreferenceChange ( ContentPreferenceKey . self, perform: { preferences in
39
-
39
+ self . preferences = preferences
40
+
40
41
// Calculate all values once, on render. On-the-fly calculations with GeometryReader
41
42
// proved occasionally unstable in testing.
42
43
if !hasCalculatedFrames {
@@ -133,6 +134,15 @@ public struct HStackSnapCore<Content: View>: View {
133
134
}
134
135
135
136
// 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
+ }
136
146
137
147
@State private var hasCalculatedFrames : Bool = false
138
148
You can’t perform that action at this time.
0 commit comments