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

Transition animation #41

Open
ANGOmarcello opened this issue Oct 20, 2015 · 5 comments
Open

Transition animation #41

ANGOmarcello opened this issue Oct 20, 2015 · 5 comments

Comments

@ANGOmarcello
Copy link
Contributor

Hey folks what do you think about this?
I worked on a little method to transition between gamma values.

// This method creates a transistion from one gamma value to another
+ (void)setGammaWithTransitionFrom:(float)oldPercentOrange to:(float)newPercentOrange {

    float delay = 0.02; // The animation delay

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        if (newPercentOrange > oldPercentOrange) {
            for (float i = oldPercentOrange; i <= newPercentOrange; i = i + 0.01) {
                [NSThread sleepForTimeInterval:delay];
                [self setGammaWithOrangeness:i];
                NSLog(@"%f",i);
            }
        } else {
            for (float i = oldPercentOrange; i >= newPercentOrange; i = i - 0.01) {
                [NSThread sleepForTimeInterval:delay];
                [self setGammaWithOrangeness:i];
                NSLog(@"%f",i);
            }
        }
    });
}
@ANGOmarcello
Copy link
Contributor Author

So far I have implemented this into my branch successfully. Now I'm trying to improve it in a way wich makes it im possible to have two transition running at the same time. Handling these transitions with a NSTimer could be the solution.

@CasperCL
Copy link
Contributor

Looks great, but why do you want to be able to play multiple transitions at the same time?

@ANGOmarcello
Copy link
Contributor Author

No I don’t want to do that. :D

It’s more like that:
If you hammer the enabled button it will play multiple transitions at once. Just thinking about a way to cancel the last transition so that this does not happen. :)

Am 23.10.2015 um 11:04 schrieb Casper notifications@github.com:

Looks great, but why do you want to be able to play multiple transitions at the same time?


Reply to this email directly or view it on GitHub #41 (comment).

@arthurhammer
Copy link
Contributor

I'm currently playing with a Today Widget and this is indeed an issue there. The widget has an enable/disable toggle, an increase (orangeness) and a decrease button. When you hit "enable" but do "increase/decrease" before the transition is finished, it flickers badly and it ends in an inconsistent state at the end. It's not that bad in the main app, but in the widget it's very noticeable.

@ANGOmarcello
Copy link
Contributor Author

I understand well for now you should stick with that because we could implement a better transition logic in the ganma controller later. I will do that but at the moment time is rare.

If you want to improve it yourself:
Using an NSTimer to trigger the transition and invalidating it if another animation is triggered should do the job. Also it would be smart to have a variable wich saves the last state of your animation so that if you have to abort an animation you can use the last current value to transition in the new direction.

Am 27.10.2015 um 19:01 schrieb Arthur Hammer notifications@github.com:

I'm currently playing with a Today Widget and this is indeed an issue there. The widget has an enable/disable toggle, an increase (orangeness) and a decrease button. When you hit "enable" but do "increase/decrease" before the transition is finished, it flickers badly and it ends in an inconsistent state at the end. It's not that bad in the main app, but in the widget it's very noticeable.


Reply to this email directly or view it on GitHub.

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