Skip to content

Instantly share code, notes, and snippets.

@archieedwards
Created June 9, 2020 20:34
Show Gist options
  • Save archieedwards/5932c7bd76dc6c1d7f377a52ade492aa to your computer and use it in GitHub Desktop.
Save archieedwards/5932c7bd76dc6c1d7f377a52ade492aa to your computer and use it in GitHub Desktop.
.simultaneousGesture(DragGesture().onChanged({value in
/// catch moving to category
if self.allowSubCategoryDragging {
let movingCategoryRight = self.page == 0 && self.nestedPages[self.page] == 2 && value.translation.width < 0
let movingCategoryLeft = self.page == 1 && self.nestedPages[self.page] == 0 && value.translation.width > 0
if movingCategoryRight || movingCategoryLeft{
self.allowSubCategoryDragging = false
}
else{
let westAsCanBe = self.nestedPages[self.page] == 0 && self.page == 0 && value.translation.width > 0
let eastAsCanBe = self.nestedPages[self.page] == 2 && self.page == 1 && value.translation.width < 0
if !westAsCanBe && !eastAsCanBe{
/// we must be moving sub categorys move the offset for the indicator
self.indicatorOffsets[self.page] = -value.translation.width/10
}
}
}
}).onEnded({ _ in
self.indicatorOffsets[self.page] = 0
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment