Skip to content

Commit

Permalink
Fix lineDashPhase not set for Stroke.offset bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fangpenlin authored Oct 29, 2018
1 parent a0b0fee commit 10e58b8
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func addShapeAnimation(_ animation: BasicAnimation, sceneLayer: CALayer, animati
layer.lineCap = MCAShapeLayerLineCap.mapToGraphics(model: stroke.cap)
layer.lineJoin = MCAShapeLayerLineJoin.mapToGraphics(model: stroke.join)
layer.lineDashPattern = stroke.dashes.map { NSNumber(value: $0) }
layer.lineDashPhase = CGFloat(stroke.offset)
} else if shape.fill == nil {
layer.strokeColor = MColor.black.cgColor
layer.lineWidth = 1.0
Expand Down Expand Up @@ -201,6 +202,16 @@ fileprivate func generateShapeAnimation(from: Shape, to: Shape, duration: Double

group.animations?.append(dashPatternAnimation)
}

// Dash offset
if fromStroke.offset != toStroke.offset{
let dashOffsetAnimation = CABasicAnimation(keyPath: "lineDashPhase")
dashOffsetAnimation.fromValue = fromStroke.offset
dashOffsetAnimation.toValue = toStroke.offset
dashOffsetAnimation.duration = duration

group.animations?.append(dashOffsetAnimation)
}

// Group
group.duration = duration
Expand Down

0 comments on commit 10e58b8

Please sign in to comment.