         currLoadingLayer.zPosition = 1
 
         prevImageView.layer.zPosition = 2
-        currImageView.layer.zPosition = 2
+        currImageView.layer.zPosition = 3
         nextImageView.layer.zPosition = 2
 
         imagesContainer.layer.addSublayer(currLoadingLayer)

    }

    @objc
    func gestureMovement(gesture: UIPanGestureRecognizer) {
        let translation = gesture.translation(in: self)

        if gesture.state == .ended {
            let velocity = gesture.velocity(in: self)
            let delta: Delta?
            if translation.x < -20 && velocity.x < 0 && delegate?.imageURLsForScreen().next != nil {

        nextURL = newNextURL
    }

    private func normalizeImageTransform() {
        var adjusted = false
        if imageScale < 1 {
            imageScale = 1
            imageOffset = .zero
            adjusted = true
        }
        else {
            guard let imageSize = currImageView.image?.size else { return }

            let actualImageScale = min(currImageView.frame.width / imageSize.width, currImageView.frame.height / imageSize.height)
            let actualImageSize = CGSize(width: imageSize.width * actualImageScale, height: imageSize.height * actualImageScale)
            let adjustedActualFrame = CGRect(
                x: currImageView.frame.minX + (currImageView.frame.width - actualImageSize.width) / 2,
                y: currImageView.frame.minY + (currImageView.frame.height - actualImageSize.height) / 2,
                width: actualImageSize.width,
                height: actualImageSize.height
                )

            if adjustedActualFrame.width < currImageFrame.width {
                if adjustedActualFrame.minX < currImageFrame.minX {
                    let delta = currImageFrame.minX - adjustedActualFrame.minX
                    imageOffset.x += delta / imageScale
                    adjusted = true
                }
                else if adjustedActualFrame.maxX > currImageFrame.maxX {
                    let delta = adjustedActualFrame.maxX - currImageFrame.maxX
                    imageOffset.x -= delta / imageScale
                    adjusted = true
                }
            }
            else {
                if adjustedActualFrame.minX > currImageFrame.minX {
                    let delta = adjustedActualFrame.minX - currImageFrame.minX
                    imageOffset.x -= delta / imageScale
                    adjusted = true
                }
                else if adjustedActualFrame.maxX < currImageFrame.maxX {
                    let delta = currImageFrame.maxX - adjustedActualFrame.maxX
                    imageOffset.x += delta / imageScale
                    adjusted = true
                }
            }

            if adjustedActualFrame.height < currImageFrame.height {
                if adjustedActualFrame.minY < currImageFrame.minY {
                    let delta = currImageFrame.minY - adjustedActualFrame.minY
                    imageOffset.y += delta / imageScale
                    adjusted = true
                }
                else if adjustedActualFrame.maxY > currImageFrame.maxY {
                    let delta = adjustedActualFrame.maxY - currImageFrame.maxY
                    imageOffset.y -= delta / imageScale
                    adjusted = true
                }
            }
            else {
                if adjustedActualFrame.minY > currImageFrame.minY {
                    let delta = adjustedActualFrame.minY - currImageFrame.minY
                    imageOffset.y -= delta / imageScale
                    adjusted = true
                }
                else if adjustedActualFrame.maxY < currImageFrame.maxY {
                    let delta = currImageFrame.maxY - adjustedActualFrame.maxY
                    imageOffset.y += delta / imageScale
                    adjusted = true
                }
            }
        }

        if adjusted {
            updateImageTransform(animated: true)
        }
    }

    private func updateImageTransform(animated: Bool) {
        if imageScale > 1 {
            imagePanGesture.isEnabled = true
            scrollPanGesture.isEnabled = false
            doubleTapGesture.isEnabled = true
            singleTapGesture.isEnabled = false
        }
        else {
            imagePanGesture.isEnabled = false
            scrollPanGesture.isEnabled = true
            doubleTapGesture.isEnabled = false
            singleTapGesture.isEnabled = true
        }

        var transform = CATransform3DIdentity
        transform = CATransform3DScale(transform, imageScale, imageScale, 1.01)
        transform = CATransform3DTranslate(transform, imageOffset.x, imageOffset.y, 0)

        elloAnimate(animated: animated) {
            self.currImageView.layer.transform = transform
        }
    }

    @objc
    func imageDoubleTapped() {
        imageScale = 1
        imageOffset = .zero
        updateImageTransform(animated: true)
    }

    @objc
    func dismiss() {
        delegate?.dismiss()
