         var offScreenCenter = popupView.center
 
         velocityX = velocityX >= 0 ?
-            (velocityX < constants.minVelocity ? constants.minVelocity : velocityX) :
-            (velocityX > -constants.minVelocity ? -constants.minVelocity : velocityX)
+            (velocityX < constants.minVelocity ? 0 : velocityX) :
+            (velocityX > -constants.minVelocity ? 0 : velocityX)
 
         velocityY = velocityY >= 0 ?
             (velocityY < constants.minVelocity ? constants.minVelocity : velocityY) :

                })
            }
        } else if recognizer.state == .cancelled {
            UIView.animate(withDuration: 1, animations: { 
                self.popupView.center = self.backgroundView.center
            })
        }


    func popupMoved(recognizer: UIPanGestureRecognizer) {
        let location = recognizer.location(in: backgroundView)
        UIView.animate(withDuration: 0, animations: {
            self.popupView.center = location
        })

        if recognizer.state == .ended {
            let location = recognizer.location(in: backgroundView)
            let origin = CGPoint(x: backgroundView.center.x - popupViewInitialFrame.size.width/2,
                                 y: backgroundView.center.y - popupViewInitialFrame.size.height/2)
            let velocity = recognizer.velocity(in: backgroundView)
            if !CGRect(origin: origin, size: popupViewInitialFrame.size).contains(location) ||
                (velocity.x > constants.activeVelocity || velocity.y > constants.activeVelocity) {
