diff --git a/gloss/ContentView.swift b/gloss/ContentView.swift index 9eccaa9..d384062 100644 --- a/gloss/ContentView.swift +++ b/gloss/ContentView.swift @@ -399,7 +399,7 @@ struct ContentView: View { .offset(x: pulledOut.width) .offset(x: mainSwipe.width) .highPriorityGesture( - DragGesture(minimumDistance: 30) + DragGesture(minimumDistance: 20) .updating($dragGestureActive) { value, state, _ in print("pop here") state = value.translation @@ -430,35 +430,18 @@ struct ContentView: View { } // Apply resistance if out of bounds - var maxOffsetRight: CGFloat = 150 + let maxRight: CGFloat = 140 + let finalRight: CGFloat = 110 + let rightDiff = maxRight - finalRight var maxOffsetLeft: CGFloat = -200 - // 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 if startSwipeDir == .right { - // maxOffsetLeft = CGFloat(200) - // maxOffsetRight = CGFloat(10) - // } - // } - - if newOffset > maxOffsetRight, pulledOut.width == 0 { - // newOffset = maxOffsetRight + rubberBandEffect(newOffset) - newOffset = maxOffsetRight + rubberBandEffect(newOffset - maxOffsetRight) + if newOffset > maxRight , pulledOut.width == 0 { + // newOffset = maxRight + rubberBandEffect(newOffset) + newOffset = maxRight + rubberBandEffect(newOffset - maxRight) } - if newOffset > 0, pulledOut.width > 0 { - newOffset = rubberBandEffect(newOffset) + if newOffset > rightDiff, pulledOut.width > 0 { + newOffset = rightDiff + rubberBandEffect(newOffset - rightDiff) } if newOffset < maxOffsetLeft, pulledOut.width == 0 { @@ -584,9 +567,10 @@ struct ContentView: View { func handleVisibilityChanged2(_: String, change _: VisibilityChange, tracker _: VisibilityTracker) {} + func rubberBandEffect(_ offset: CGFloat) -> CGFloat { let resistance: CGFloat = 0.05 - return 4 * log(offset + 1) + return 6 * log(offset + 1) // return resistance * pow(abs(offset), 1) * (offset < 0 ? -1 : 1) }