Skip to content

Commit 09eb539

Browse files
committed
Fix laggy dragging
1 parent ff4a269 commit 09eb539

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Sources/ImageViewer/ImageViewer.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ public struct ImageViewer: View {
8888

8989
return
9090
}
91-
self.dragOffset = .zero
91+
withAnimation(.interactiveSpring()) {
92+
self.dragOffset = .zero
93+
}
9294
}
9395
)
9496

@@ -273,7 +275,6 @@ struct PinchToZoom: ViewModifier {
273275
content
274276
.scaleEffect(scale, anchor: anchor)
275277
.offset(offset)
276-
.animation(isPinching ? .none : .spring())
277278
.overlay(PinchZoom(scale: $scale, anchor: $anchor, offset: $offset, isPinching: $isPinching))
278279
}
279280
}

Sources/ImageViewerRemote/ImageViewerRemote.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ public struct ImageViewerRemote: View {
7979
self.viewerShown = false
8080
return
8181
}
82-
self.dragOffset = .zero
82+
withAnimation(.interactiveSpring()) {
83+
self.dragOffset = .zero
84+
}
8385
}
8486
)
8587
})
@@ -102,7 +104,9 @@ public struct ImageViewerRemote: View {
102104
self.viewerShown = false
103105
return
104106
}
105-
self.dragOffset = .zero
107+
withAnimation(.interactiveSpring()) {
108+
self.dragOffset = .zero
109+
}
106110
}
107111
)
108112
}
@@ -291,7 +295,6 @@ struct PinchToZoom: ViewModifier {
291295
content
292296
.scaleEffect(scale, anchor: anchor)
293297
.offset(offset)
294-
.animation(isPinching ? .none : .spring())
295298
.overlay(PinchZoom(scale: $scale, anchor: $anchor, offset: $offset, isPinching: $isPinching))
296299
}
297300
}

0 commit comments

Comments
 (0)