Refactor handling view transitions
Adjust animation based on view index