Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lineDashPhase not set for Stroke.offset bug #497

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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