-2

How can I check if the drag value is increasing or decrease when dragging up or down. I want to know the direction someone is dragging in. Can anyone help with this??

1 Answers1

0

I found a method for getting the direction of the scroll: https://medium.com/@Mos6yCanSwift/swift-ios-determine-scroll-direction-d48a2327a004

let currentVelocityY = scrollView.panGestureRecognizer.velocity(in: scrollView.superview).y
let currentVelocityYSign = Int(currentVelocityY).signum()
        
if currentVelocityYSign != lastVelocityYSign && currentVelocityYSign != 0 {
            lastVelocityYSign = currentVelocityYSign
}
        
if lastVelocityYSign < 0 {
            
//CODE HERE
            
} else if lastVelocityYSign > 0 {
            
//CODE HERE

 }
sigma1510
  • 1,165
  • 1
  • 11
  • 26