working better still needs tweaks

fix_swipe
saint 2024-06-08 19:41:44 -04:00
parent f23cff87ab
commit 56b32c39ab
1 changed files with 35 additions and 6 deletions

View File

@ -383,21 +383,50 @@ struct ContentView: View {
} }
print("start swipe meow: \(startSwipeState)") print("start swipe meow: \(startSwipeState)")
}
if newOffset > 0 { if newOffset > 0 {
startSwipeDir = .right startSwipeDir = .right
} else { } else {
startSwipeDir = .left startSwipeDir = .left
} }
}
// Apply resistance if out of bounds // Apply resistance if out of bounds
let maxOffsetRight: CGFloat = 150 var maxOffsetRight: CGFloat = 110
let maxOffsetLeft: CGFloat = 200 var maxOffsetLeft: CGFloat = 200
if newOffset < -maxOffsetLeft {
if startSwipeState == .right {
if startSwipeDir == .right {
maxOffsetRight = .zero
maxOffsetLeft = .zero
} else if startSwipeDir == .left {
maxOffsetRight = CGFloat(110)
maxOffsetLeft = CGFloat(-30)
}
} else if startSwipeState == .left {
if startSwipeDir == .left {
maxOffsetLeft = .zero
maxOffsetRight = .zero
} else {
maxOffsetLeft = CGFloat(200)
maxOffsetRight = .zero
}
}
if newOffset + pulledOut.width < -maxOffsetLeft {
if startSwipeState == .right && startSwipeDir == .left {
print("meow here")
newOffset = -maxOffsetLeft + rubberBandEffect(newOffset + maxOffsetLeft) - pulledOut.width
} else {
print("meow here")
newOffset = -maxOffsetLeft + rubberBandEffect(newOffset + maxOffsetLeft) newOffset = -maxOffsetLeft + rubberBandEffect(newOffset + maxOffsetLeft)
} else if newOffset > maxOffsetRight { }
} else if newOffset + pulledOut.width > maxOffsetRight {
newOffset = maxOffsetRight + rubberBandEffect(newOffset - maxOffsetRight) newOffset = maxOffsetRight + rubberBandEffect(newOffset - maxOffsetRight)
} }