Skip to content

Commit

Permalink
Partial fix for ephread#218 - division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
ephread committed Oct 5, 2019
1 parent c543fbb commit 9e8979a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class CoachMarkLayoutHelper {
forLayoutDirection layoutDirection: UIUserInterfaceLayoutDirection,
inFrame frame: CGRect
) -> CoachMarkHorizontalAligment {
if let pointOfInterest = coachMark.pointOfInterest {
if let pointOfInterest = coachMark.pointOfInterest, frame.size.width > 0 {
let segmentIndex = Int(ceil(2 * pointOfInterest.x / frame.size.width))

switch (segmentIndex, layoutDirection) {
Expand All @@ -233,7 +233,12 @@ class CoachMarkLayoutHelper {
default: return .centered
}
} else {
print("[INFO] The point of interest is nil, alignment will fall back to .center.")
if coachMark.pointOfInterest == nil {
print("[INFO] The point of interest is nil, alignment will fall back to .center.")
} else {
print("[WARNING] frame has no width, alignment will fall back to .center.")
}

return .centered
}
}
Expand Down

0 comments on commit 9e8979a

Please sign in to comment.