Skip to content

Commit

Permalink
feat: Animation for targetSize change.
Browse files Browse the repository at this point in the history
  • Loading branch information
laosb committed Aug 10, 2023
1 parent f34449d commit bbfe1e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Sources/CropImage/CropImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion Sources/CropImage/RectHoleShape.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bbfe1e4

Please sign in to comment.