Skip to content

Commit

Permalink
Fix issue where stroke wouldn't render if dashLengths was zero (#1691)
Browse files Browse the repository at this point in the history
  • Loading branch information
takeshi-1000 authored Aug 3, 2022
1 parent d5b3027 commit 938002d
Show file tree
Hide file tree
Showing 4 changed files with 518 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ extension CAShapeLayer {
try KeyframeGroup(keyframes: $0)
.exactlyOneKeyframe(context: context, description: "stroke dashPattern").value.cgFloatValue as NSNumber
}
if lineDashPattern?.allSatisfy({ $0.floatValue.isZero }) == true {
lineDashPattern = nil
}

try addAnimation(
for: .lineDashPhase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final class GradientStrokeNode: AnimatorNode, RenderNode {

/// Get dash lengths
let dashLengths = strokeProperties.dashPattern.value.map { $0.cgFloatValue }
if dashLengths.count > 0 {
if dashLengths.count > 0, !dashLengths.allSatisfy({ $0.isZero }) {
strokeRender.strokeRender.dashPhase = strokeProperties.dashPhase.value.cgFloatValue
strokeRender.strokeRender.dashLengths = dashLengths
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final class StrokeNode: AnimatorNode, RenderNode {

/// Get dash lengths
let dashLengths = strokeProperties.dashPattern.value.map { $0.cgFloatValue }
if dashLengths.count > 0 {
if dashLengths.count > 0, !dashLengths.allSatisfy({ $0.isZero }) {
strokeRender.dashPhase = strokeProperties.dashPhase.value.cgFloatValue
strokeRender.dashLengths = dashLengths
} else {
Expand Down
Loading

0 comments on commit 938002d

Please sign in to comment.