Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Changing component style at runtime and in animation #65

Closed
denislutz opened this issue Jun 23, 2014 · 5 comments
Closed

Changing component style at runtime and in animation #65

denislutz opened this issue Jun 23, 2014 · 5 comments

Comments

@denislutz
Copy link

Hi cloudkite,

I love classy, thank you for this awesome framework.

Changing a style class at runtime is very known from web applications. Like expand collapse cases for example.

Question:
Example use case.
I want to add some class on a button after it was clicked.
So in my View I do something like that:

[self.myButton cas_addStyleClass:@"expanded"];

Then I remove the style class if its clicked again.
[self.myButton cas_removeStyleClass:@"expanded"];

Is that a feasible way to use classy?
Do I need to call something else to update the view hierarchy?
While that in general works, it is not supporting any animations inside the animation block.
[UIView animateWithDuration:defaultAnimationDuration
animations:^{
So I dont know what exactly I need to do to perform this style class change as an animation.

@cloudkite
Copy link
Contributor

@denislutz Glad you like it :)

You may need to force an update of styles. Since classy tries to schedule updates in order to group styling updates into one call. to force the change to happen during your animation block try adding

[UIView animateWithDuration:defaultAnimationDuration animations:^{
    [self.myButton cas_updateStyling];
}];

@denislutz
Copy link
Author

Hey @cloudkite,

It worked out! It tried it before but it was only on the parent component, thats why overlooked.
I applied it now to each element that has a style change it and works.
I think this technique is so powerful you should mention it in the documentation.

Thanks for all your work.

@dnedrow
Copy link
Member

dnedrow commented Oct 7, 2017

@denislutz , can this issue be closed?

@denislutz
Copy link
Author

yes, thx.

@dnedrow
Copy link
Member

dnedrow commented Oct 14, 2017

@denislutz Added the animation information to a new how-to section of the wiki. Closing the issue per questioner.

@dnedrow dnedrow closed this as completed Oct 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants