exyte / Macaw

Powerful and easy-to-use vector graphics Swift library with SVG support
MIT License
6.01k stars 554 forks source link

Unexpected animation when changing Shape's fill color #692

Closed devpolant closed 4 years ago

devpolant commented 4 years ago

Precondition

guard let node = svgView.node.nodeBy(tag: nodeId) as? Shape else {
    return
}
node.onTap { [weak self] _ in
    guard let self = self, let node = self.svgView.node.nodeBy(tag: nodeId) as? Shape else {
        return
    }
    let color = node.fill != self.selectedColor ? self.selectedColor : self.normalColor
    node.fillVar.animate(to: color, during: 0.3)
}

Problem

Demo project

f3dm76 commented 4 years ago

Hello @AntonPoltoratskyi , thank you very much for your report, and a working example. Just wanted to let you know we started working on this issue, and will let you know once it's fixed. Have a great day!

f3dm76 commented 4 years ago

Greetings @AntonPoltoratskyi ! Glad to let you know the issue is resolved, the fix will be included in future release, but for now please kindly check out the master Macaw branch. Could I also ask you a favour - may I please use your svg file (and basically the idea to highlight pieces on tap) to add a new example to Macaw?

devpolant commented 4 years ago

Thanks a lot! Sure, you can use it - it is downloaded from open source https://www.amcharts.com/svg-maps/?map=argentina. Original idea is from this tutorial https://medium.com/@fede_nieto/interactive-svg-images-in-swift-with-macaw-1b0d7875511f but color was updated without animation there.