Search in sources :

Example 1 with DecelerateAccelerateInterpolator

use of com.reactnativenavigation.options.interpolators.DecelerateAccelerateInterpolator in project react-native-navigation by wix.

the class InterpolationParser method parse.

public static TimeInterpolator parse(JSONObject json) {
    JSONObject interpolation = json.optJSONObject("interpolation");
    String type = interpolation == null ? "linear" : interpolation.optString("type", "linear");
    switch(type) {
        case "decelerate":
            {
                float factor = (float) interpolation.optDouble("factor", 1.0);
                return new DecelerateInterpolator(factor);
            }
        case "accelerateDecelerate":
            {
                return new AccelerateDecelerateInterpolator();
            }
        case "accelerate":
            {
                float factor = (float) interpolation.optDouble("factor", 1.0);
                return new AccelerateInterpolator(factor);
            }
        case "decelerateAccelerate":
            {
                return new DecelerateAccelerateInterpolator();
            }
        case "fastOutSlowIn":
            {
                return new FastOutSlowInInterpolator();
            }
        case "overshoot":
            {
                double tension = interpolation.optDouble("tension", 1.0);
                return new OvershootInterpolator((float) tension);
            }
        case "spring":
            {
                float mass = (float) interpolation.optDouble("mass", 3.0);
                float damping = (float) interpolation.optDouble("damping", 500.0);
                float stiffness = (float) interpolation.optDouble("stiffness", 200.0);
                boolean allowsOverdamping = interpolation.optBoolean("allowsOverdamping", false);
                float initialVelocity = (float) interpolation.optDouble("initialVelocity", 0);
                return new SpringInterpolator(mass, damping, stiffness, allowsOverdamping, initialVelocity);
            }
        case "linear":
        default:
            {
                return new LinearInterpolator();
            }
    }
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) JSONObject(org.json.JSONObject) DecelerateAccelerateInterpolator(com.reactnativenavigation.options.interpolators.DecelerateAccelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) LinearInterpolator(android.view.animation.LinearInterpolator) SpringInterpolator(com.reactnativenavigation.options.interpolators.SpringInterpolator) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) DecelerateAccelerateInterpolator(com.reactnativenavigation.options.interpolators.DecelerateAccelerateInterpolator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator)

Aggregations

AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)1 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)1 LinearInterpolator (android.view.animation.LinearInterpolator)1 OvershootInterpolator (android.view.animation.OvershootInterpolator)1 FastOutSlowInInterpolator (androidx.interpolator.view.animation.FastOutSlowInInterpolator)1 DecelerateAccelerateInterpolator (com.reactnativenavigation.options.interpolators.DecelerateAccelerateInterpolator)1 SpringInterpolator (com.reactnativenavigation.options.interpolators.SpringInterpolator)1 JSONObject (org.json.JSONObject)1