lvnkmn / Zoomy

Adds seamless scrollView and instagram like zooming to UIImageViews in any view hierarchy.
MIT License
206 stars 25 forks source link

Image is jump/scrolled to top after zooming #72

Closed eldhoseelias closed 5 years ago

eldhoseelias commented 5 years ago

`` import UIKit import Zoomy

class DZImageViewerViewController: UIViewController {

@IBOutlet weak var imageView: UIImageView!
var imageData : UIImage? = nil
override func viewDidLoad() {
    super.viewDidLoad()
    imageView.image = imageData
    imageView.isUserInteractionEnabled = true
    guard let parentView = parent?.view else { return }

    addZoombehavior(for: imageView, in:parentView)
    //addZoombehavior(for: imageView)
   // addZoombehavior(for: imageView, settings: Settings().with(actionOnTapOverlay: Action.dismissOverlay))
}
override func viewWillDisappear(_ animated: Bool) {
    imageZoomControllers.values.forEach{ $0.dismissOverlay() }
}

@IBAction func backButtonAction(_ sender: Any) {
    self.navigationController?.popViewController(animated: true)
}

}

//MARK: - ZoomDelegate extension DZImageViewerViewController: Zoomy.Delegate {

func didBeginPresentingOverlay(for imageView: UIImageView) {
    //        print("did begin presenting overlay for imageView: \(imageView)")
}

func didEndPresentingOverlay(for imageView: UIImageView) {
    //        print("did end presenting overlay for imageView: \(imageView)")
}

func contentStateDidChange(from fromState: ImageZoomControllerContentState, to toState: ImageZoomControllerContentState) {
    //        print("contentState did change from state: \(fromState) to state: \(toState)")
    //You might want to show/hide statusbar here
}

}

lvnkmn commented 5 years ago

Hmm, thats not suposed to happen.

Two questions, to be able to better help you:

lvnkmn commented 5 years ago

also, did you have the same issues when you didn't specify the parent view? This should normally only bee needed when you want the zoom overlay to appear above elements outside of current view controller hierarchy. When the image to be zoomed is not part of the hierarchy that it will be zoomed in, problems like these may occur. This has to do with the way Absolute coordinates are currently calculated.

tldr; if this only happens when specifying 'in: parentView' we might have to improve the absolute coordinate calculation for these cases.

Let me know 🙂

lvnkmn commented 5 years ago

Closing this due to inactivity, feel free to open it if help is needed.