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

Restart animation on viewWillAppear #71

Open
lumo2707 opened this issue Jan 2, 2019 · 2 comments
Open

Restart animation on viewWillAppear #71

lumo2707 opened this issue Jan 2, 2019 · 2 comments

Comments

@lumo2707
Copy link

lumo2707 commented Jan 2, 2019

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?

@efremidze
Copy link
Owner

efremidze commented Jan 3, 2019

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)
        }
    }
}

@az-oolloow
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants