fix initial z-index
factorise fadeTransition function