Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions ImageViewer/ImageViewerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public final class ImageViewerController: UIViewController {
return true
}

let iosDeviceVersion = (UIDevice.current.systemVersion as NSString).floatValue
var shouldDismissImageView = true

public init(configuration: ImageViewerConfiguration?) {
self.configuration = configuration
super.init(nibName: String(describing: type(of: self)), bundle: Bundle(for: type(of: self)))
Expand All @@ -34,6 +37,7 @@ public final class ImageViewerController: UIViewController {
setupGestureRecognizers()
setupTransitions()
setupActivityIndicator()
checkOverIosDeviceVersion()
}
}

Expand Down Expand Up @@ -108,7 +112,7 @@ private extension ImageViewerController {
zoomRect.origin.y = newCenter.y - (zoomRect.size.height / 2.0)
return zoomRect
}

if scrollView.zoomScale > scrollView.minimumZoomScale {
scrollView.setZoomScale(scrollView.minimumZoomScale, animated: true)
} else {
Expand All @@ -118,7 +122,7 @@ private extension ImageViewerController {

@objc func imageViewPanned(_ recognizer: UIPanGestureRecognizer) {
guard transitionHandler != nil else { return }

let translation = recognizer.translation(in: imageView)
let velocity = recognizer.velocity(in: imageView)

Expand All @@ -134,12 +138,24 @@ private extension ImageViewerController {
transitionHandler?.dismissInteractively = false
let percentage = abs(translation.y + velocity.y) / imageView.bounds.height
if percentage > 0.25 {
transitionHandler?.dismissalInteractor.finish()
if (shouldDismissImageView == true) {
transitionHandler?.dismissalInteractor.finish()
}else {
transitionHandler?.dismissalInteractor.cancel()
}
} else {
transitionHandler?.dismissalInteractor.cancel()
}
default: break
}
}

func checkOverIosDeviceVersion () {
if (iosDeviceVersion >= 13) {
shouldDismissImageView = false
}else {
print(iosDeviceVersion)
}
}
}