Skip to content

Instantly share code, notes, and snippets.

@muhammadabbas001
Created November 20, 2023 07:53
Show Gist options
  • Save muhammadabbas001/9bdf5e2bff0ec7b56eba5bee42f4dbda to your computer and use it in GitHub Desktop.
Save muhammadabbas001/9bdf5e2bff0ec7b56eba5bee42f4dbda to your computer and use it in GitHub Desktop.
func getOffset(_ i: Int) -> CGFloat {
if i == relativeLoc() {
return dragState.translation.width
} else if i == relativeLoc() + 1 || relativeLoc() == views.count - 1 && i == 0{
return dragState.translation.width + (300 + 20)
} else if i == relativeLoc() - 1 || relativeLoc() == 0 && i == views.count - 1 {
return dragState.translation.width - (300 + 20)
} else if i == relativeLoc() + 2 || (relativeLoc() == views.count - 1 && i == 1) || (relativeLoc() == views.count - 2 && i == 0) {
return dragState.translation.width + (2*(300 + 20))
} else if i == relativeLoc() - 2 || (relativeLoc() == 1 && i == views.count - 1) || (relativeLoc() == 0 && i == views.count - 2) {
return dragState.translation.width - (2*(300 + 20))
} else if i == relativeLoc() + 3 || (relativeLoc() == views.count - 1 && i == 2) || (relativeLoc() == views.count - 2 && i == 1) || (relativeLoc() == views.count - 3 && i == 0){
return dragState.translation.width + (3*(300 + 20))
} else if i == relativeLoc() - 3 || (relativeLoc() == 2 && i == views.count - 1) || (relativeLoc() == 1 && i == views.count - 2) || (relativeLoc() == 0 && i == views.count - 3) {
return dragState.translation.width - (3*(300 + 20))
} else {
return 10000
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment