mirror of
https://github.com/laosb/CropImage.git
synced 2025-04-30 23:51:08 +00:00
feat: Animation for targetSize change.
This commit is contained in:
parent
f34449d10a
commit
bbfe1e4636
2 changed files with 8 additions and 1 deletions
|
@ -151,6 +151,7 @@ public struct CropImageView<Controls: View>: View {
|
||||||
RectHoleShape(size: targetSize)
|
RectHoleShape(size: targetSize)
|
||||||
.fill(style: FillStyle(eoFill: true))
|
.fill(style: FillStyle(eoFill: true))
|
||||||
.foregroundColor(.black.opacity(0.6))
|
.foregroundColor(.black.opacity(0.6))
|
||||||
|
.animation(.default, value: targetSize)
|
||||||
.allowsHitTesting(false)
|
.allowsHitTesting(false)
|
||||||
controls {
|
controls {
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -8,7 +8,13 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct RectHoleShape: Shape {
|
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 {
|
func path(in rect: CGRect) -> Path {
|
||||||
let path = CGMutablePath()
|
let path = CGMutablePath()
|
||||||
path.move(to: rect.origin)
|
path.move(to: rect.origin)
|
||||||
|
|
Loading…
Add table
Reference in a new issue