Container Morph
A payment flow in a single morphing container: button, spinner, and result card are the same element reshaping. The switcher sets the outcome, receipt or decline; clicking the finished card runs it again.
Notes
- Technique
- One shell animates its measured width, height, radius and seat. The pill, the spinner and the card are layers centred inside it, each measured with a ResizeObserver, so the shell shrink-wraps whichever is active. It is the box that resizes, never a scale transform, so the text doesn’t stretch.
- Timing
- Springs, as stiffness / damping: collapse and slide 200 / 25, bloom into the card 400 / 30 at mass 0.9, return to the pill 440 / 34. Phases: 360ms collapse, 1.6s spin, 320ms seal. Layers fade in over 220ms and out over 160ms.
- Interruption
- The working phases ignore presses: a payment in flight shouldn’t restart. The finished card can be pressed at any point to run back to the pill, and switching the outcome reshapes an open card in place.
- Reduced motion
- The shell snaps to each shape and fades in over 240ms, the layers crossfade, and the spinner is a still ring. No shake on decline, no shimmer on the label.
- Accessibility
- The button’s name is always the action: Pay with card, Start over, Try again. A status region beside it announces each phase and the result, and describes the button, so the result is read again on focus.