Magnetic
Magnetic copied to clipboard
Restart animation on viewWillAppear
Hi, is it possible to restart animation so that when the user comes back on the screen the bubbles will be animated from besides to center?
I can add a function to restart the animation. However in the meanwhile you can add this extension to adjust the node position.
extension Magnetic {
func restartAnimation() {
for (index, node) in children.enumerated() {
let x = (index % 2 == 0) ? -node.frame.width : frame.width + node.frame.width
let y = CGFloat.random(node.frame.height, frame.height - node.frame.height)
node.position = CGPoint(x: x, y: y)
}
}
}
@efremidze just FYI where i use it is upon device rotation when my container resizes - it seems out of the box this is not handled by Magnetic.