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

Bug: .BackgroundColor doesn't work for nil #19

Closed
markuswinkler opened this issue Apr 30, 2016 · 2 comments
Closed

Bug: .BackgroundColor doesn't work for nil #19

markuswinkler opened this issue Apr 30, 2016 · 2 comments

Comments

@markuswinkler
Copy link

This had me scratching my head for a bit.
The following code never triggers the onComplete handler:

let v = UIView()
view.addSubview(v)

Kinetic.to(v, duration: 0.1, options: [.BackgroundColor(UIColor.whiteColor())]).play().onComplete { anim in
      print("complete")
}

reason: backgroundColor property of the UIView is nil. Maybe add some check for that?

@u10int
Copy link
Owner

u10int commented May 1, 2016

That wouldn't animate since you're trying to animate a property whose initial value is nil, so the tween property isn't being created and added to the tween since there's no initial condition/value to tween from. Technically this is the correct functionality but it should ideally be throwing an exception when creating the tween so it's not failing silently and the user knows there's no initial value.

At first I considered just using UIColor.clearColor() when the property's value is nil, but not sure if this is the best assumption even if it's the easiest to use. An alternative would be to use Kinetic.fromTo where you'd set the from color value to UIColor.clearColor().

I'll add in some assertions when setting up the tween properties to help in these cases.

@u10int u10int closed this as completed May 1, 2016
@markuswinkler
Copy link
Author

Thanks!

Yeah, I know it's not an ideal case. I was just wondering for the longest time why the complete handler only (seemingly) randomly executes (because in some cases there was actually a background color set before somewhere else in the code).
Just want to avoid that others run into the same issue and waste time.

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