Skip to content

Commit

Permalink
Merge pull request #20 from ast3150/main
Browse files Browse the repository at this point in the history
Prevent shimmer animation from affecting initial layout of the view
  • Loading branch information
markiv authored Jan 28, 2024
2 parents 2c632ed + 4290558 commit 5659a62
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/Shimmer/Shimmer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public struct Shimmer: ViewModifier {
.mask(LinearGradient(gradient: gradient, startPoint: startPoint, endPoint: endPoint))
.animation(animation, value: isInitialState)
.onAppear {
isInitialState = false
// Delay the animation until the initial layout is established
// to prevent animating the appearance of the view
DispatchQueue.main.asyncAfter(deadline: .now()) {
isInitialState = false
}
}
}
}
Expand Down

0 comments on commit 5659a62

Please sign in to comment.