andkulikov / Transitions-Everywhere

Set of extra Transitions on top of Jetpack Transitions Library
Apache License 2.0
4.83k stars 486 forks source link

TranslationTransition #65

Closed mariuspena closed 7 years ago

mariuspena commented 7 years ago

Hi

It appears that setTranslationY in TranslationTransition is applied immediately and then the animation is triggered correctly. Do you have any info on this?

PS: I also wrote on your blog before thinking of this place..

andkulikov commented 7 years ago

Hi!

Could you please try modify your createAnimator

@Nullable
@Override
public Animator createAnimator(@NonNull ViewGroup sceneRoot, @Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
    Float startValue = Float.parseFloat(startValues.values.get(PROPNAME_TRANSLATIONY).toString());
    Float endValue = Float.parseFloat(endValues.values.get(PROPNAME_TRANSLATIONY).toString());

    startValues.view.setTranslationY(startValue);

    ObjectAnimator mover = ObjectAnimator.ofFloat(startValues.view, "translationY", startValue, endValue);
    return mover;
}

We are doing it in such way in all other transitions, looks like a forgot about it in TranslationTransition. So we are manually applying proper initial state.

mariuspena commented 7 years ago

thanks a lot! worked like a charm