Question presented to candidate:
"Design wants the notification panel to fade in and out, and items in the to-do list to slide when they are added, removed or reordered. Walk me through how Vue's <Transition> and <TransitionGroup> make that happen, and what you would check if an animation does not play."
What a strong answer should cover:
<Transition>animates one element or component entering or leaving (viav-if,v-show, a dynamic component or a changingkey).- The six classes
v-enter-from / -active / -toandv-leave-from / -active / -to, prefixed byname, and the timing:-fromis applied first and swapped for-toon the next frame. - Vue detects the end from the element's computed
transitionend/animationendtiming, or from an explicit:duration; JavaScript hooks (@enter,@leavewith adonecallback) are the alternative. mode="out-in"sequences two elements so they do not overlap.<TransitionGroup>handles lists: each child needs akey, it can render a wrapper withtag, and it animates moves with thev-moveclass using the FLIP technique.- The animation itself is CSS run by the browser; Vue only toggles classes and removes the element at the right time.
Clarifying questions expected:
- "Is this one element appearing and disappearing, or a list whose items reorder?"
- "Do we need to respect
prefers-reduced-motion?"
Code / implementation expected: Yes β a <Transition> with the CSS classes, and a <TransitionGroup> list with enter, leave and move styles.