Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion KMReader/Features/Reader/Views/NativeCoverPageView_iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@
} else if !isAnimatingTransition {
syncCurrentItemFromViewModel()
if let navigationTarget = parent.viewModel.navigationTarget {
handleNavigationTarget(navigationTarget)
// While the user is actively panning, discard tap-initiated navigation.
// `isAnimatingTransition` only covers the post-pan commit/cancel animation;
// during the pan itself it is false, so an unguarded tap would call
// `commitTransition` mid-drag and override the user's gesture.
if isUserPanning {
parent.viewModel.clearNavigationTarget()
} else {
handleNavigationTarget(navigationTarget)
}
} else {
syncSlotContent()
updateSlotLayout()
Expand Down Expand Up @@ -223,6 +231,16 @@
deckState.currentItem
}

private var isUserPanning: Bool {
guard let panRecognizer else { return false }
switch panRecognizer.state {
case .began, .changed:
return true
default:
return false
}
}

private var pendingTargetItem: ReaderViewItem? {
guard let transitionDirection else { return nil }
return transitionDirection == 1 ? deckState.nextItem : deckState.previousItem
Expand Down
20 changes: 19 additions & 1 deletion KMReader/Features/Reader/Views/NativeCoverPageView_macOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,15 @@
} else if !isAnimatingTransition {
syncCurrentItemFromViewModel()
if let navigationTarget = parent.viewModel.navigationTarget {
handleNavigationTarget(navigationTarget)
// While the user is actively panning, discard tap-initiated navigation.
// `isAnimatingTransition` only covers the post-pan commit/cancel animation;
// during the pan itself it is false, so an unguarded tap would call
// `commitTransition` mid-drag and override the user's gesture.
if isUserPanning {
parent.viewModel.clearNavigationTarget()
} else {
handleNavigationTarget(navigationTarget)
}
} else {
syncSlotContent()
updateSlotLayout()
Expand Down Expand Up @@ -216,6 +224,16 @@
deckState.currentItem
}

private var isUserPanning: Bool {
guard let panRecognizer else { return false }
switch panRecognizer.state {
case .began, .changed:
return true
default:
return false
}
}

private var pendingTargetItem: ReaderViewItem? {
guard let transitionDirection else { return nil }
return transitionDirection == 1 ? deckState.nextItem : deckState.previousItem
Expand Down
10 changes: 10 additions & 0 deletions KMReader/Features/Reader/Views/ScrollPageView_iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,16 @@
_ navigationTarget: ReaderViewItem,
in collectionView: UICollectionView
) {
// While the user is in the middle of a swipe (drag or its deceleration), ignore
// tap-initiated navigation. The drag's intent dominates; layering a programmatic
// scroll over natural deceleration produces a double page advance. Mirrors the
// existing guard in `scrollViewWillBeginDragging` that lets a drag override an
// in-flight programmatic scroll.
if engine.isUserInteracting {
parent.viewModel.clearNavigationTarget()
return
}

guard let resolvedTarget = parent.viewModel.resolvedViewItem(for: navigationTarget),
let targetItem = engine.resolveItem(resolvedTarget)
else {
Expand Down
10 changes: 10 additions & 0 deletions KMReader/Features/Reader/Views/ScrollPageView_macOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,16 @@
in scrollView: NSScrollView,
collectionView: NSCollectionView
) {
// While the user is in the middle of a swipe (drag or its deceleration), ignore
// tap-initiated navigation. The drag's intent dominates; layering a programmatic
// scroll over natural deceleration produces a double page advance. Mirrors the
// existing guard in `scrollViewWillBeginDragging` that lets a drag override an
// in-flight programmatic scroll.
if engine.isUserInteracting {
parent.viewModel.clearNavigationTarget()
return
}

guard let resolvedTarget = parent.viewModel.resolvedViewItem(for: navigationTarget),
let targetItem = engine.resolveItem(resolvedTarget)
else {
Expand Down
Loading