Trip itinerary

A trip plan as a stack of cards. Scroll, drag or use the arrow keys to walk the itinerary from the flight up to the cover photo.

Scroll or drag on the stack, click a card, or use ↑ ↓ on it.

Sample itinerary. The dates, places and prices are made up.

Key CSS & implementation tricks

// model.js: signed cyclic distance, (-3, 3]
export function offset(index, focus) {
  let d = (index - focus) % N;
  if (d > N / 2) d -= N;
  if (d <= -N / 2) d += N;
  return d;
}

// card j's top edge when focus is centred
const top0 = (appH - HEIGHTS[ORDER[focus]]) / 2;
if (d === 0) return top0;
if (d < 0)  return top0 - GAP - COLLAPSED - (-d - 1) * 70;
return top0 + HEIGHTS[ORDER[focus]] + GAP + (d - 1) * 70;

el.style.transform = `translateY(${cardTop(j, focus)}px)`;

.card {
  height: 62px;                       /* collapsed: header only */
  transition: height .54s var(--ease),
              transform .54s var(--ease);
}
.card.on { /* focused card grows to its content height */ }

el.style.height = d === 0 ? `${HEIGHTS[key]}px` : '62px';
// positions for the neighbours are computed from the
// *target* height, so they land flush as the card grows

// The deck wrapper carries the live drag offset…
deck.style.transform = `translate3d(0, ${dragY}px)`;
// …so each card keeps its snapped translateY.
// On release: past one card-height, or a fast flick, steps.
if (dragY > 64 || vel > .4) advance(-1);
else if (dragY < -64 || vel < -.4) advance(1);
setDeck(0);   // eases back through the same transition

.card-trip .inner {
  background: linear-gradient(180deg,
    #2e4a7d, #4a6fa5 42%, #7fa6cf 74%, #b8cde6);
}
.card-trip .cap {
  position: absolute; top: 0; height: 62px;
  /* title lives in the same band every header uses */
}

.rt-map circle, .rt-map text { opacity: 0;
  transform: translateY(6px); }
.card.on .rt-map circle, .card.on .rt-map text {
  opacity: 1; transform: none; }   /* replays on refocus */

/* pathLength makes the dash math viewport-independent */
.rt-map .rt-path { stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .9s var(--ease) .12s; }
.card.on .rt-map .rt-path { stroke-dashoffset: 0; }

.bg-bars .bar { height: 0; }       /* planted at zero */
.card.on .bg-bars .bar { height: calc(var(--h) * 1%); }