                 }
             }
             let initFriction: CGFloat = 50
-            next(0, velocityX: velocityX / initFriction, velocityY: velocityY / initFriction)
+            next(0, velocityX: finalDeltaX / initFriction, velocityY: finalDeltaY / initFriction)
             
         case .Cancelled: break;
         case .Failed: break;

    weak var chart: Chart?
    
    private var lastPanTranslation: CGPoint?
    
    private var pinchRecognizer: UIPinchGestureRecognizer?
    private var panRecognizer: UIPanGestureRecognizer?

    @objc func onPinch(sender: UIPinchGestureRecognizer) {
        
        guard sender.numberOfTouches() > 1 else {return}
        guard let chartSettings = chart?.settings else {return}
        
        let center = sender.locationInView(self)
        
        let x = abs(sender.locationInView(self).x - sender.locationOfTouch(1, inView: self).x)
        let y = abs(sender.locationInView(self).y - sender.locationOfTouch(1, inView: self).y)
        
        let (deltaX, deltaY): (CGFloat, CGFloat) = {
            switch chartSettings.zoomPanGestureMode {
            case .OnlyX: return (sender.scale, 1)
            case .OnlyY: return (1, sender.scale)
            case .Max: return x > y ? (sender.scale, 1) : (1, sender.scale)
            case .Both:
                // calculate scale x and scale y
                let (absMax, absMin) = x > y ? (abs(x), abs(y)) : (abs(y), abs(x))
                let minScale = (absMin * (sender.scale - 1) / absMax) + 1
                return x > y ? (sender.scale, minScale) : (minScale, sender.scale)
            }
        }()
        
        chart?.zoom(deltaX: deltaX, deltaY: deltaY, centerX: center.x, centerY: center.y, isGesture: true)
        
