transition function to wait for css tranisitions