Skip to content

Commit 5659a62

Browse files
authored
Merge pull request #20 from ast3150/main
Prevent shimmer animation from affecting initial layout of the view
2 parents 2c632ed + 4290558 commit 5659a62

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/Shimmer/Shimmer.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ public struct Shimmer: ViewModifier {
8585
.mask(LinearGradient(gradient: gradient, startPoint: startPoint, endPoint: endPoint))
8686
.animation(animation, value: isInitialState)
8787
.onAppear {
88-
isInitialState = false
88+
// Delay the animation until the initial layout is established
89+
// to prevent animating the appearance of the view
90+
DispatchQueue.main.asyncAfter(deadline: .now()) {
91+
isInitialState = false
92+
}
8993
}
9094
}
9195
}

0 commit comments

Comments
 (0)