         // From Transform
         let transScaleX = (toFrame.size.height * fromFrameAspectRatio) / fromFrame.size.width
         let transScaleY = (toFrame.size.height) / fromFrame.size.height
-        let fromTransPanY = (toFrameCenter.y - fromFrameCenter.y) / transScaleY
-        let fromTransPanX = (toFrameCenter.x - fromFrameCenter.x) / transScaleX
+        let fromTransPanY = toFrameCenter.y - fromFrameCenter.y
+        let fromTransPanX = toFrameCenter.x - fromFrameCenter.x
         
         let fromTransScale = CGAffineTransform(scaleX: transScaleX, y: transScaleY)
         let fromTransPan = CGAffineTransform(translationX: fromTransPanX, y: fromTransPanY)
-        let fromTransform = fromTransPan.concatenating(fromTransScale)
+        let fromTransform = fromTransScale.concatenating(fromTransPan)
         
         // To Transform
-        let toTransPanY = (fromFrameCenter.y - toFrameCenter.y) * (type == .inward ? transScaleY : 1)
-        let toTransPanX = (fromFrameCenter.x - toFrameCenter.x) * (type == .inward ? transScaleX : 1)
+        let toTransPanY = fromFrameCenter.y - toFrameCenter.y
+        let toTransPanX = fromFrameCenter.x - toFrameCenter.x
     
         let toTransScale = CGAffineTransform(scaleX: 1 / transScaleX, y: 1 / transScaleY)
         let toTransPan = CGAffineTransform(translationX: toTransPanX, y: toTransPanY)
-        let toTransform = toTransPan.concatenating(toTransScale)
-        
+        let toTransform = toTransScale.concatenating(toTransPan)
+    
         return (fromTransform, toTransform)
     }
     
+    fileprivate func setAnchorPoint(_ anchorPoint:CGPoint, forView view:UIView) {
+        var newPoint = CGPoint(x:view.bounds.size.width * anchorPoint.x, y:view.bounds.size.height * anchorPoint.y)
+        var oldPoint = CGPoint(x:view.bounds.size.width * view.layer.anchorPoint.x, y:view.bounds.size.height * view.layer.anchorPoint.y)
+        
+        newPoint = newPoint.applying(view.transform)
+        oldPoint = oldPoint.applying(view.transform)
+        
+        var position = view.layer.position
+        
+        position.x -= oldPoint.x
+        position.x += newPoint.x
+        
+        position.y -= oldPoint.y
+        position.y += newPoint.y
+        
+        view.layer.position = position
+        view.layer.anchorPoint = anchorPoint
+    
+    }
+    
 }

            toVC = (toVC as! UITabBarController).selectedViewController!
        }
        
        guard let fromVCSnapshot = fromView.snapshotView(afterScreenUpdates: false) else {
            return
        }
        
        containerView.backgroundColor = backgroundColor
        containerView.addSubview(toView)
        containerView.addSubview(fromVCSnapshot)
        
        fromView.isHidden = true
        toView.setNeedsLayout()
        toView.layoutIfNeeded()
        

    var springDamping: CGFloat
    var type: JKHImageZoomType
    
    init(type: JKHImageZoomType, backgroundColor: UIColor = UIColor.white, viewContentMode: UIViewContentMode = .scaleAspectFill, duration: TimeInterval = 0.7, springVelocity: CGFloat = 1.5, springDamping: CGFloat = 1.0) {
        self.backgroundColor = backgroundColor
        self.viewContentMode = viewContentMode
        self.duration = duration
