fix logic ordering in onAnimationEnd