Skip to content

Commit

Permalink
fix: drag ended -> drag onchange debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
Jihyun247 committed Aug 13, 2024
1 parent c31bff6 commit a27d210
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public struct OnboardingCore {
case setIndex(Int)
case calculateOffset(CGFloat, OnboardingItem)
case dragStart
case dragEnd
case _timerStart
case _timerEnd
case _timerTicked
Expand Down Expand Up @@ -57,7 +56,6 @@ public struct OnboardingCore {
last.id = .init()
state.fakedData.elements.append(first)
state.fakedData.elements.insert(last, at: 0)
print(state.fakedData.map { $0.id.uuidString })
return .run { send in
await send(._timerStart)
}
Expand Down Expand Up @@ -87,14 +85,13 @@ public struct OnboardingCore {
return .none

case .dragStart:
return .run { send in
await send(._timerEnd)
}

case .dragEnd:
return .run { send in
await send(._timerStart)
}
let timerEndAction: Effect<Action> = .send(._timerEnd)
let timerStartAction: Effect<Action> = .send(._timerStart)
.debounce(id: "timerStart", for: .seconds(2), scheduler: DispatchQueue.main)
return .merge(
timerEndAction,
timerStartAction
)

case ._timerStart:
return .run { send in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public struct OnboardingView: View {
.gesture(
DragGesture()
.onChanged { _ in store.send(.dragStart) }
.onEnded { _ in store.send(.dragEnd) }
)
.frame(width: store.width, height: 350)

Expand Down

0 comments on commit a27d210

Please sign in to comment.