Skip to content

Running animation ignoring the view's contentMode #374

@asarmiento13315

Description

@asarmiento13315

/*
Hi there,
Before anything, excellent library!

Getting started and making some tests. I haven't been able to find out what I am missing in this case.
Just tried to setup a simple scene interested only on the relative positions, expecting that the SVGView would apply the selected contentMode, scalling and filling in my view.
And all is rendered as expected while the animation is stopped, but, when it begins my animated rect looks like if it hasn't been transformed by the View and its contentMode.

Thank you !
*/

let backg = Rect(x: 0, y: 0, w: 60, h: 60).fill(with: Color.black)
let rect = Group(
contents: [
Line(x1: 0, y1: 0, x2: 20, y2: 0).stroke(fill: Color.blue, width: 3, cap: .round),
Line(x1: 0, y1: 20, x2: 20, y2: 20).stroke(fill: Color.red, width: 3, cap: .round),
Line(x1: 0, y1: 0, x2: 0, y2: 20).stroke(fill: Color.green, width: 3, cap: .round),
Line(x1: 20, y1: 0, x2: 20, y2: 20).stroke(fill: Color.yellow, width: 3, cap: .round)
],
place: Transform.move(dx: 10, dy: 10).scale(sx: 2, sy: 2)
)

let ani = rect.placeVar.animation(angle: 1.99999 * .pi, x: 10, y: 10).cycle().easing(.linear)

let n = [backg, rect].group()
var r = false
n.onTap(f: { _ in
if r { ani.stop() } else { ani.play() }
r = !r
})

let svgView = SVGView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
svgView.node = n

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions