bufferapp / buffer-ios-image-viewer

The BFRImageViewer is a turnkey solution to present images within your iOS app 🎉!
MIT License
398 stars 55 forks source link

Custom presentation transition doesn't animate as intended #81

Closed akaralar closed 5 years ago

akaralar commented 5 years ago

I'm trying to implement custom transition as it's mentioned on the readme, where imageView passed to the function is an imageView from a table view cell:

    private func showImageViewer(for imageView: UIImageView) {
        guard let image = imageView.image else { return }
        imageAnimator.animatedImageContainer = imageView
        imageAnimator.animatedImage = image
        let frame = view.convert(imageView.bounds, from: imageView)

        imageAnimator.imageOriginFrame = frame
        imageAnimator.desiredContentMode = imageView.contentMode

        let imageVC = BFRImageViewController(imageSource: [image])
        imageVC!.transitioningDelegate = imageAnimator

        present(imageVC!, animated: true, completion: nil)
    }

The dismiss animation looks and works as intended, but the entrance to the animation looks off. Any idea why that might be happening? I recorded 2 gifs to illustrate the problem.

Content mode is set to aspect fit. I put logs in the library and the frames are calculated correctly. I'm at a loss why this is happening.

bug1 bug2

DreamingInBinary commented 5 years ago

Try changing this let frame = view.convert(imageView.bounds, from: imageView) to this let frame = view.convert(imageView.frame, to: nil) and let me know if that works.

akaralar commented 5 years ago

Thanks for the suggestion but I can't reproduce the issue above again. I wonder whether it was related to the image itself. I'll reopen if this happens again and your solution doesn't fix it. Thanks for taking the time!