Skip to content

Commit

Permalink
Use safer float comparison when checking if label should scroll (fixes
Browse files Browse the repository at this point in the history
…#151)[common]
  • Loading branch information
cbpowell committed Aug 5, 2016
1 parent 1f9eab2 commit b97ec74
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/ObjC/MarqueeLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ - (BOOL)labelShouldScroll {
return NO;
}

BOOL labelTooLarge = ([self subLabelSize].width + self.leadingBuffer > self.bounds.size.width);
BOOL labelTooLarge = ([self subLabelSize].width + self.leadingBuffer > self.bounds.size.width + FLT_EPSILON);
BOOL animationHasDuration = (self.scrollDuration > 0.0f || self.rate > 0.0f);
return (!self.labelize && labelTooLarge && animationHasDuration);
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Swift/MarqueeLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ public class MarqueeLabel: UILabel {
}

// Check if the label string fits
let labelTooLarge = (sublabelSize().width + leadingBuffer) > self.bounds.size.width
let labelTooLarge = (sublabelSize().width + leadingBuffer) > self.bounds.size.width + CGFloat(FLT_EPSILON)
let animationHasDuration = speed.value > 0.0
return (!labelize && labelTooLarge && animationHasDuration)
}
Expand Down

0 comments on commit b97ec74

Please sign in to comment.