Skip to content

Commit

Permalink
Fixed pulse button that would continue to pulse after task ended
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean151 committed Mar 23, 2024
1 parent b16ada4 commit dda1181
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/ButtonKit/AsyncStyle/AsyncStyle+Pulse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public struct PulseAsyncButtonStyle: AsyncButtonStyle {
configuration.button
.compositingGroup()
.opacity(configuration.isLoading ? 0.5 : 1)
.animation(.linear(duration: 1).repeatForever(), value: configuration.isLoading)
.animation(configuration.isLoading ? .linear(duration: 1).repeatForever() : nil, value: configuration.isLoading)
}
}

Expand All @@ -46,7 +46,7 @@ extension AsyncButtonStyle where Self == PulseAsyncButtonStyle {

#Preview {
AsyncButton {
try await Task.sleep(nanoseconds: 30_000_000_000)
try await Task.sleep(nanoseconds: 5_000_000_000)
} label: {
Text("Pulse")
}
Expand Down

0 comments on commit dda1181

Please sign in to comment.