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

Provide generic Interpolator #30

Open
huan-nguyen opened this issue May 6, 2017 · 0 comments
Open

Provide generic Interpolator #30

huan-nguyen opened this issue May 6, 2017 · 0 comments

Comments

@huan-nguyen
Copy link

First of all, nice library and great animation. However, I think the interpolators at the moment is created based on some pre-calculated constants. For example, in ActionBarInterpolator:

   private static final float FIRST_BOUNCE_PART = 0.375f;
   private static final float SECOND_BOUNCE_PART = 0.625f;
   @Override
   public float getInterpolation(float t) {
       if (t < FIRST_BOUNCE_PART) {
           return (-28.4444f) * t * t + 10.66667f * t;
       } else if (t < SECOND_BOUNCE_PART) {
           return (21.33312f) * t * t - 21.33312f * t + 4.999950f;
       } else {
           return (-9.481481f) * t * t + 15.40741f * t - 5.925926f;
       }
   }

The constants used in getInterpolation (e.g., -28.4444f) are pre-calculated based on the values of FIRST_BOUNCE_PART and SECOND_BOUNCE_PART. If either or both of these values are changed, the constant values need to be recalculated.

This limit users of this library from changing the value of FIRST_BOUNCE_PART and/or SECOND_BOUNCE_PART to whatever they want because if they change these values, they have to do their own math to work out formulas for the interpolators.

So I think it would be nicer to provide generic formulas for interpolators with perhaps FIRST_BOUNCE_PART and SECOND_BOUNCE_PART are variables to avoid users being worrying about the formulas themselves.

What do you think?

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

1 participant