mirror of
https://github.com/laosb/CropImage.git
synced 2025-04-30 15:41:08 +00:00
Allow zoom using scroll wheel
This commit is contained in:
parent
304a4c8e7e
commit
ea5a5354fb
1 changed files with 12 additions and 0 deletions
|
@ -81,6 +81,15 @@ struct UnderlyingImageView: View {
|
|||
scale = min(widthScale, heightScale)
|
||||
}
|
||||
|
||||
private func setupScrollMonitor() {
|
||||
#if os(macOS)
|
||||
NSEvent.addLocalMonitorForEvents(matching: .scrollWheel) {event in
|
||||
scale = scale + event.scrollingDeltaY/1000
|
||||
return event
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
var imageView: Image {
|
||||
#if os(macOS)
|
||||
Image(nsImage: image)
|
||||
|
@ -94,6 +103,9 @@ struct UnderlyingImageView: View {
|
|||
.gesture(dragGesture)
|
||||
.gesture(magnificationgesture)
|
||||
.gesture(rotationGesture)
|
||||
.onAppear {
|
||||
setupScrollMonitor()
|
||||
}
|
||||
}
|
||||
|
||||
var dragGesture: some Gesture {
|
||||
|
|
Loading…
Add table
Reference in a new issue