feat: Animation for targetSize change.

This commit is contained in:
Shibo Lyu 2023-08-10 14:47:57 +08:00
parent f34449d10a
commit bbfe1e4636
2 changed files with 8 additions and 1 deletions

View file

@ -151,6 +151,7 @@ public struct CropImageView<Controls: View>: View {
RectHoleShape(size: targetSize)
.fill(style: FillStyle(eoFill: true))
.foregroundColor(.black.opacity(0.6))
.animation(.default, value: targetSize)
.allowsHitTesting(false)
controls {
do {

View file

@ -8,7 +8,13 @@
import SwiftUI
struct RectHoleShape: Shape {
let size: CGSize
var size: CGSize
var animatableData: AnimatablePair<CGFloat, CGFloat> {
get { .init(size.width, size.height) }
set { size = .init(width: newValue.first, height: newValue.second) }
}
func path(in rect: CGRect) -> Path {
let path = CGMutablePath()
path.move(to: rect.origin)