Skip to content

Commit 108b2bf

Browse files
committed
Fix flashing pages when following the speech
1 parent 43580fc commit 108b2bf

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Sources/Navigator/Toolkit/PaginationView.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,16 @@ final class PaginationView: UIView, Loggable {
302302
guard 0..<pageCount ~= index else {
303303
return false
304304
}
305+
306+
if currentIndex == index {
307+
scrollToView(at: index, location: location, completion: completion)
308+
} else {
309+
fadeToView(at: index, location: location, animated: animated, completion: completion)
310+
}
311+
return true
312+
}
305313

314+
private func fadeToView(at index: Int, location: PageLocation, animated: Bool, completion: @escaping () -> Void) {
306315
func fade(to alpha: CGFloat, completion: @escaping () -> ()) {
307316
if animated {
308317
UIView.animate(withDuration: 0.15, animations: {
@@ -319,10 +328,8 @@ final class PaginationView: UIView, Loggable {
319328
fade(to: 1, completion: completion)
320329
}
321330
}
322-
323-
return true
324331
}
325-
332+
326333
private func scrollToView(at index: Int, location: PageLocation, completion: @escaping () -> Void) {
327334
guard currentIndex != index else {
328335
if let view = currentView {

0 commit comments

Comments
 (0)