exyte / Macaw

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

When setting the `scaleToFill` content mode, position of the opacity animation is wrong #712

Open WiiLin opened 4 years ago

WiiLin commented 4 years ago

testSVG.zip pod 'Macaw', :git => 'https://github.com/exyte/Macaw', :branch => 'master'

    @IBOutlet weak var macawView: MacawView! {
        didSet {
            macawView.node = try! SVGParser.parse(resource: "table", fromBundle: Bundle.main)
            macawView.contentMode = .scaleToFill
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        let  tap = UITapGestureRecognizer(target: self, action: #selector(ViewController.onClickBackground))
        macawView.addGestureRecognizer(tap)
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
    }

    @objc func onClickBackground(recognizer: UIGestureRecognizer) {
        let point = recognizer.location(in: recognizer.view)
        if let note = macawView.findNodeAt(location: point) {
            note.opacityVar.animation(from: 0.1, to: 1, during: 1, delay: 0).autoreversed().cycle().easing(.linear).play()
        }
    }

Simulator Screen Shot - iPhone 11 - 2020-07-08 at 21 04 21 Simulator Screen Shot - iPhone 11 - 2020-07-08 at 21 05 09