Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 96591ef

Browse files
author
Stephen Sowole
committed
Update PanModalPresentationController.swift
1 parent 1defbf2 commit 96591ef

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

PanModal/Controller/PanModalPresentationController.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public class PanModalPresentationController: UIPresentationController {
198198

199199
/**
200200
Drag indicator is drawn outside of view bounds
201-
so hiding it on view dismiss means avoids visual bugs
201+
so hiding it on view dismiss means avoiding visual bugs
202202
*/
203203
coordinator.animate(alongsideTransition: { [weak self] _ in
204204
self?.dragIndicatorView.alpha = 0.0
@@ -244,7 +244,7 @@ public extension PanModalPresentationController {
244244
Due to content offset observation, its not possible to programmatically
245245
set the content offset directly on the scroll view while in the short form.
246246

247-
This method pauses the content offset KVO, performs the content offset chnage
247+
This method pauses the content offset KVO, performs the content offset change
248248
and then resumes content offset observation.
249249
*/
250250
public func setContentOffset(offset: CGPoint) {
@@ -273,7 +273,7 @@ public extension PanModalPresentationController {
273273

274274
/**
275275
Updates the PanModalPresentationController layout
276-
based on values in the PanModalPresentabls
276+
based on values in the PanModalPresentable
277277

278278
- Note: This should be called whenever any
279279
pan modal presentable value changes after the initial presentation
@@ -443,7 +443,7 @@ private extension PanModalPresentationController {
443443
@objc func didPanOnPresentedView(_ recognizer: UIPanGestureRecognizer) {
444444

445445
guard
446-
shouldRespond(to: panGestureRecognizer),
446+
shouldRespond(to: recognizer),
447447
let containerView = containerView
448448
else {
449449
recognizer.setTranslation(.zero, in: recognizer.view)
@@ -484,7 +484,7 @@ private extension PanModalPresentationController {
484484
if velocity.y < 0 {
485485
transition(to: .longForm)
486486

487-
} else if (nearestDistance(to: presentedView.frame.minY, inDistances: [longFormYPosition, containerView.bounds.height]) == longFormYPosition
487+
} else if (nearest(to: presentedView.frame.minY, inValues: [longFormYPosition, containerView.bounds.height]) == longFormYPosition
488488
&& presentedView.frame.minY < shortFormYPosition) || presentable?.allowsDragToDismiss == false {
489489
transition(to: .shortForm)
490490

@@ -498,7 +498,7 @@ private extension PanModalPresentationController {
498498
The `containerView.bounds.height` is used to determine
499499
how close the presented view is to the bottom of the screen
500500
*/
501-
let position = nearestDistance(to: presentedView.frame.minY, inDistances: [containerView.bounds.height, shortFormYPosition, longFormYPosition])
501+
let position = nearest(to: presentedView.frame.minY, inValues: [containerView.bounds.height, shortFormYPosition, longFormYPosition])
502502

503503
if position == longFormYPosition {
504504
transition(to: .longForm)
@@ -635,16 +635,16 @@ private extension PanModalPresentationController {
635635
}
636636

637637
/**
638-
Finds the nearest distance to a given position out of a given array of distance values
638+
Finds the nearest value to a given number out of a given array of float values
639639

640640
- Parameters:
641-
- position: reference postion we are trying to find the closest distance to
642-
- distances: array of positions we would like to compare against
641+
- number: reference float we are trying to find the closest value to
642+
- values: array of floats we would like to compare against
643643
*/
644-
func nearestDistance(to position: CGFloat, inDistances distances: [CGFloat]) -> CGFloat {
645-
guard let nearestDistance = distances.min(by: { abs(position - $0) < abs(position - $1) })
646-
else { return position }
647-
return nearestDistance
644+
func nearest(to number: CGFloat, inValues values: [CGFloat]) -> CGFloat {
645+
guard let nearestVal = values.min(by: { abs(number - $0) < abs(number - $1) })
646+
else { return number }
647+
return nearestVal
648648
}
649649

650650
/**

0 commit comments

Comments
 (0)