Refactor transition animation code to avoid duplicates

Change-Id: Ib2ced3c9c5d9256c0ba5687c58d34ac03b2df94c