Skip to content

Commit

Permalink
Fix for the issue found in #139, podspec update
Browse files Browse the repository at this point in the history
  • Loading branch information
amyleecodes committed Dec 15, 2017
1 parent 95ee8bd commit 3943cff
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Pulley.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'Pulley'
s.version = '2.2.2'
s.version = '2.2.3'
s.summary = 'A library to imitate the iOS 10 Maps UI.'

# This description is used to generate tags and improve search results.
Expand Down
52 changes: 29 additions & 23 deletions PulleyLib/PulleyViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1300,32 +1300,38 @@ extension PulleyViewController: UIScrollViewDelegate {

let distanceFromBottomOfView = lowestStop + lastDragTargetContentOffset.y

switch snapMode {

case .nearestPosition:

var currentClosestStop = lowestStop

for currentStop in drawerStops
var currentClosestStop = lowestStop

for currentStop in drawerStops
{
if abs(currentStop - distanceFromBottomOfView) < abs(currentClosestStop - distanceFromBottomOfView)
{
if abs(currentStop - distanceFromBottomOfView) < abs(currentClosestStop - distanceFromBottomOfView)
{
currentClosestStop = currentStop
}
currentClosestStop = currentStop
}
}

var closestValidDrawerPosition: PulleyPosition = drawerPosition

if abs(Float(currentClosestStop - (self.drawerScrollView.bounds.height))) <= Float.ulpOfOne && supportedPositions.contains(.open)
{
closestValidDrawerPosition = .open
}
else if abs(Float(currentClosestStop - collapsedHeight)) <= Float.ulpOfOne && supportedPositions.contains(.collapsed)
{
closestValidDrawerPosition = .collapsed
}
else if supportedPositions.contains(.partiallyRevealed)
{
closestValidDrawerPosition = .partiallyRevealed
}

let snapModeToUse: PulleySnapMode = closestValidDrawerPosition == drawerPosition ? snapMode : .nearestPosition

switch snapModeToUse {

if abs(Float(currentClosestStop - (self.drawerScrollView.bounds.height))) <= Float.ulpOfOne && supportedPositions.contains(.open)
{
setDrawerPosition(position: .open, animated: true)
}
else if abs(Float(currentClosestStop - collapsedHeight)) <= Float.ulpOfOne && supportedPositions.contains(.collapsed)
{
setDrawerPosition(position: .collapsed, animated: true)
}
else if supportedPositions.contains(.partiallyRevealed)
{
setDrawerPosition(position: .partiallyRevealed, animated: true)
}
case .nearestPosition:

setDrawerPosition(position: closestValidDrawerPosition, animated: true)

case .nearestPositionUnlessExceeded(let threshold):

Expand Down

0 comments on commit 3943cff

Please sign in to comment.