Refined afterTransition and beforeTransition callbacks