Skip to content

Commit

Permalink
Fix scaleGesture using progressing var
Browse files Browse the repository at this point in the history
  • Loading branch information
djeni98 committed Jan 17, 2024
1 parent 869886b commit c12b52c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Virtual Crop/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ struct ContentView: View {
@State private var scale: CGFloat = 1.0
@State private var offset = CGSize.zero

@State private var progressingScale: CGFloat = 1.0
@State private var progressingOffset = CGSize.zero

var dragGesture: some Gesture {
Expand All @@ -21,14 +22,18 @@ struct ContentView: View {
var scaleGesture: some Gesture {
MagnificationGesture()
.onChanged { value in
self.scale = value.magnitude
progressingScale = value.magnitude
}
.onEnded { value in
scale *= value
progressingScale = 1.0
}
}

var body: some View {
ZStack {
Image(uiImage: uiimage)
.scaleEffect(scale)
.scaleEffect(scale * progressingScale)
.offset(sum(offset, progressingOffset))
}
.gesture(dragGesture)
Expand Down

0 comments on commit c12b52c

Please sign in to comment.