Skip to content

Commit

Permalink
Fixing position update issue via the fix for issue #400
Browse files Browse the repository at this point in the history
  • Loading branch information
ulmentflam committed Oct 8, 2020
1 parent 1ee45b7 commit 186ae78
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions PulleyLib/PulleyViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,11 @@ open class PulleyViewController: UIViewController, PulleyDrawerViewControllerDel

fileprivate var isAnimatingDrawerPosition: Bool = false

fileprivate var isChangingDrawerPosition: Bool = false
fileprivate var isChangingDrawerPosition: Bool = false {
didSet {
print("Drawer Position Changing: \(isChangingDrawerPosition)")
}
}

/// The height of the open position for the drawer
private var heightOfOpenDrawer: CGFloat {
Expand Down Expand Up @@ -977,7 +981,7 @@ open class PulleyViewController: UIViewController, PulleyDrawerViewControllerDel
// and the view is being layed out. If the drawer position is changing and the view is layed out (i.e.
// a value or constraints are bing updated) the drawer is always set to the last position,
// and no longer scrolls properly.
if !isChangingDrawerPosition {
if self.isChangingDrawerPosition == false {
setDrawerPosition(position: drawerPosition, animated: false)
}
}
Expand Down Expand Up @@ -1672,7 +1676,12 @@ extension PulleyViewController: UIScrollViewDelegate {

setDrawerPosition(position: positionToSnapTo, animated: true)
}
self.isChangingDrawerPosition = false
}
}

public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
if scrollView == drawerScrollView {
self.isChangingDrawerPosition = true
}
}

Expand All @@ -1686,14 +1695,14 @@ extension PulleyViewController: UIScrollViewDelegate {

// Halt intertia
targetContentOffset.pointee = scrollView.contentOffset
self.isChangingDrawerPosition = false
}
}

public func scrollViewDidScroll(_ scrollView: UIScrollView) {

if scrollView == drawerScrollView
{
self.isChangingDrawerPosition = true
let partialRevealHeight: CGFloat = (drawerContentViewController as? PulleyDrawerViewControllerDelegate)?.partialRevealDrawerHeight?(bottomSafeArea: pulleySafeAreaInsets.bottom) ?? kPulleyDefaultPartialRevealHeight

let lowestStop = getStopList().min() ?? 0
Expand Down

0 comments on commit 186ae78

Please sign in to comment.