Hello. When the LazyVGrid display area is expanded by hiding the View while animating it, the additional View is drawn without animation. Below is a sample code. When the orange color is hidden by pressing a button, the blue and green colors that appear from the bottom of the screen are drawn without animation. This phenomenon does not occur in Canvas. It occurs in the simulator. Is there any way to avoid this phenomenon? Thanks.
import SwiftUI
struct PlaygroundView: View {
@State var isOrangeHidden = false
let columns = [
GridItem(.fixed(100), spacing: 16),
GridItem(.fixed(100), spacing: 16)
]
var body: some View {
ScrollView {
Button {
isOrangeHidden.toggle()
} label: {
Text("toggle isOrangeHidden")
}
VStack {
Color.red
.frame(height: 100)
if !isOrangeHidden {
Color.orange
.frame(height: 100)
}
}
LazyVGrid(columns: columns) {
ForEach(0..<100, id: \.self) { index in
if index % 4 == 0 || index % 4 == 3 {
Color.green
.frame(height: 100)
} else {
Color.blue
.frame(height: 100)
}
}
}
}
.padding()
.animation(.easeInOut(duration: 0.2), value: isOrangeHidden)
}
}
struct PlaygroundView_Previews: PreviewProvider {
static var previews: some View {
PlaygroundView()
}
}