refactor CSS transition handling