2 Commits

Author SHA1 Message Date
Eude Lesperance dab02d34c0 Correct some docs typos (#11) 2019-03-24 20:58:33 -07:00
Stephen Sowole 96591ef52c Update PanModalPresentationController.swift 2019-03-22 14:10:06 -04:00
3 changed files with 18 additions and 18 deletions
@@ -124,7 +124,7 @@ extension PanModalPresentationAnimator: UIViewControllerAnimatedTransitioning {
}
/**
Perfroms the appropriate animation based on the transition style
Performs the appropriate animation based on the transition style
*/
public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
switch transitionStyle {
@@ -198,7 +198,7 @@ public class PanModalPresentationController: UIPresentationController {
/**
Drag indicator is drawn outside of view bounds
so hiding it on view dismiss means avoids visual bugs
so hiding it on view dismiss means avoiding visual bugs
*/
coordinator.animate(alongsideTransition: { [weak self] _ in
self?.dragIndicatorView.alpha = 0.0
@@ -220,7 +220,7 @@ public class PanModalPresentationController: UIPresentationController {
public extension PanModalPresentationController {
/**
Tranisition the PanModalPresentationController
Transition the PanModalPresentationController
to the given presentation state
*/
public func transition(to state: PresentationState) {
@@ -244,7 +244,7 @@ public extension PanModalPresentationController {
Due to content offset observation, its not possible to programmatically
set the content offset directly on the scroll view while in the short form.
This method pauses the content offset KVO, performs the content offset chnage
This method pauses the content offset KVO, performs the content offset change
and then resumes content offset observation.
*/
public func setContentOffset(offset: CGPoint) {
@@ -273,7 +273,7 @@ public extension PanModalPresentationController {
/**
Updates the PanModalPresentationController layout
based on values in the PanModalPresentabls
based on values in the PanModalPresentable
- Note: This should be called whenever any
pan modal presentable value changes after the initial presentation
@@ -384,7 +384,7 @@ private extension PanModalPresentationController {
}
/**
Caluclates & stores the layout anchor points & options
Calculates & stores the layout anchor points & options
*/
func configureViewLayout() {
@@ -443,7 +443,7 @@ private extension PanModalPresentationController {
@objc func didPanOnPresentedView(_ recognizer: UIPanGestureRecognizer) {
guard
shouldRespond(to: panGestureRecognizer),
shouldRespond(to: recognizer),
let containerView = containerView
else {
recognizer.setTranslation(.zero, in: recognizer.view)
@@ -484,7 +484,7 @@ private extension PanModalPresentationController {
if velocity.y < 0 {
transition(to: .longForm)
} else if (nearestDistance(to: presentedView.frame.minY, inDistances: [longFormYPosition, containerView.bounds.height]) == longFormYPosition
} else if (nearest(to: presentedView.frame.minY, inValues: [longFormYPosition, containerView.bounds.height]) == longFormYPosition
&& presentedView.frame.minY < shortFormYPosition) || presentable?.allowsDragToDismiss == false {
transition(to: .shortForm)
@@ -498,7 +498,7 @@ private extension PanModalPresentationController {
The `containerView.bounds.height` is used to determine
how close the presented view is to the bottom of the screen
*/
let position = nearestDistance(to: presentedView.frame.minY, inDistances: [containerView.bounds.height, shortFormYPosition, longFormYPosition])
let position = nearest(to: presentedView.frame.minY, inValues: [containerView.bounds.height, shortFormYPosition, longFormYPosition])
if position == longFormYPosition {
transition(to: .longForm)
@@ -635,16 +635,16 @@ private extension PanModalPresentationController {
}
/**
Finds the nearest distance to a given position out of a given array of distance values
Finds the nearest value to a given number out of a given array of float values
- Parameters:
- position: reference postion we are trying to find the closest distance to
- distances: array of positions we would like to compare against
- number: reference float we are trying to find the closest value to
- values: array of floats we would like to compare against
*/
func nearestDistance(to position: CGFloat, inDistances distances: [CGFloat]) -> CGFloat {
guard let nearestDistance = distances.min(by: { abs(position - $0) < abs(position - $1) })
else { return position }
return nearestDistance
func nearest(to number: CGFloat, inValues values: [CGFloat]) -> CGFloat {
guard let nearestVal = values.min(by: { abs(number - $0) < abs(number - $1) })
else { return number }
return nearestVal
}
/**
@@ -38,7 +38,7 @@ extension PanModalPresentable where Self: UIViewController {
}
/**
Returns the short form Y postion
Returns the short form Y position
- Note: If voiceover is on, the `longFormYPos` is returned.
We do not support short form when voiceover is on as it would make it difficult for user to navigate.
@@ -55,7 +55,7 @@ extension PanModalPresentable where Self: UIViewController {
}
/**
Returns the long form Y postion
Returns the long form Y position
- Note: We cap this value to the max possible height
to ensure content is not rendered outside of the view bounds