Skip to content

Commit 81baef3

Browse files
committed
Update package
1 parent 681ab42 commit 81baef3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Sources/Intramodular/Animation/PredicatedAnimation.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ private struct PredicatedAnimateOnChange<Value: Equatable>: ViewModifier {
1111
let predicate: ((oldValue: Value, newValue: Value)) -> Bool
1212

1313
@ViewStorage private var lastValue: Value?
14-
14+
1515
func body(content: Content) -> some View {
16-
content.transaction { view in
17-
if let oldValue = lastValue {
18-
if predicate((oldValue, value)) {
19-
view.animation = animation
16+
content
17+
.transaction { view in
18+
if let oldValue = lastValue {
19+
if predicate((oldValue, value)) {
20+
view.animation = animation
21+
}
2022
}
2123
}
22-
}
24+
.onChange(of: value) { value in
25+
self.lastValue = value
26+
}
2327
}
2428
}
2529

0 commit comments

Comments
 (0)