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

Calling layoutsubviews should not interrupt an existing transition #16

Open
nick-potts opened this issue Apr 19, 2017 · 3 comments
Open

Comments

@nick-potts
Copy link

Currently, if you call layoutsubviews while the button is animating, setStyle(buttonStyle, animated: false) will be called and hence the animation will complete instantly.

Since my button animates the view it is in, layoutsubviews is called several times during the transition and hence the button doesn't work.

@yannickl
Copy link
Owner

@email4nickp when you tell you call the layoutsubviews you mean the setNeedsLayout() method?

It works fine with the example project. Can you send me an example?

@nick-potts
Copy link
Author

nick-potts commented Apr 27, 2017

func styleDidSelected(style: DynamicButton.Style) {
    dynamicButton.setStyle(style, animated: true)
    animating = true
    _ = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(self.animationOver),userInfo: nil, repeats: false)
    _ = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(self.layoutView),userInfo: nil, repeats: false)
}
var animating = false
func animationOver() {
    animating = false
}
func layoutView() {
    self.dynamicButton.layoutSubviews()
    if (animating) {
        _ = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(self.layoutView),userInfo: nil, repeats: false)
    }
}

I know this is very hackish code, but it emulates what is occurring with my issue. Copy it into the example project's viewcontroller.

I'm using the SWRevealViewController in my project and this button animates the reveal of the rear controller. During this animation, the view containing the dynamic button has layoutSubviews() called multiple times during the animation.

@nick-potts
Copy link
Author

Any update on this?

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

2 participants