Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
chore: handle user interaction when user swipes quickly in page view …
Browse files Browse the repository at this point in the history
…controller (#1766)
  • Loading branch information
Muhammad Umer authored Jun 23, 2023
1 parent e9f5823 commit 6235591
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Source/CourseContentPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public class CourseContentPageViewController : UIPageViewController, UIPageViewC
// Filed http://www.openradar.appspot.com/radar?id=6188034965897216 against Apple to better expose
// this API.
// Verified on iOS9 and iOS 8
if let scrollView = (view.subviews.compactMap { return $0 as? UIScrollView }).first {
if let scrollView = view.subviews.compactMap({ return $0 as? UIScrollView }).first {
scrollView.delegate = self
scrollView.delaysContentTouches = false
}
addObservers()
Expand Down Expand Up @@ -515,6 +516,19 @@ public class CourseContentPageViewController : UIPageViewController, UIPageViewC
}
}

// There is a bug with UIPageViewController, if user tries to quickly scroll between controllers,
// the UIPageViewControllerDelegate is not being called appropriately,
// to handle this, listen to UISsrollViewDelegate and handle the user interaction.
extension CourseContentPageViewController: UIScrollViewDelegate {
public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
updateTransitionState(is: false)
}

public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
updateTransitionState(is: false)
}
}

// MARK: Testing
extension CourseContentPageViewController {
public func t_blockIDForCurrentViewController() -> OEXStream<CourseBlockID> {
Expand Down

0 comments on commit 6235591

Please sign in to comment.