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??
Asked
Active
Viewed 116 times
-2
-
How did you try? – Asperi Jun 24 '22 at 03:03
-
I honestly don't know how to start. Sorry. Haven't been writing code for too long. @Asperi – TheManOfSteell Jun 24 '22 at 04:24
1 Answers
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

TheManOfSteell
- 105
- 9