Библиотека дизайна / Эффекты и анимации

Эффекты и анимацииСветлыйРетро и пиксельМинимализмБесплатно

Вход на сайт по посадочному талону

Посетитель опускает посадочный талон в ретро-ридер: «Чтение…», зелёный огонёк — и сайт раскрывается кругом, как вход на борт.

Вход на сайт по посадочному талону
Промпт
Добавь на мою страницу эффект «Вход на сайт по посадочному талону» (Сергей Дургалян, MIT). Ниже готовая страница: HTML, CSS и JS без библиотек. Сначала перенеси её как есть и проверь: талон парит над ридером, его можно перетащить, отпущенный над щелью он уходит внутрь, экран пишет «Чтение…» с мигающим жёлтым огоньком, затем «Доступ открыт» с зелёным, и страница раскрывается кругом в блок «Добро пожаловать на борт»; кнопка «выйти из салона» возвращает назад; без ввода сцена проигрывается сама. Потом меняй.

Как устроен код. `.stack` держит талон `.pass` (z-index 1) и ридер `.reader` (z-index 2): талон, уезжая вниз, прячется за верхним краем ридера — это и есть «щель». Позиция талона `P` (x, y, наклон) пишется в `transform` каждый кадр; в режиме `drag` она идёт за указателем, иначе плавно догоняет цель `P.tx/P.ty`. Режимы: `free` → `drag` → `insert` (цель — `slotDepth()`, наружу торчит пятая часть талона) → через `READ_MS` экран «Доступ открыт» → `.welcome` получает класс `open` (`clip-path: circle(0% → 150%)`), талон выезжает обратно. `release()` вставляет талон, если он отпущен рядом со щелью (`SNAP`), иначе возвращает. Двойной клик и Enter тоже вставляют, Escape выходит. Без ввода 6 секунд `demo()` проигрывает сценарий; `?auto=1` включает его сразу.

Что менять: надписи на талоне и экранчике, цвета ридера, блок `.welcome` (или переход на мою главную в `insert()`), время чтения.

Если проект на React: держи разметку в компоненте, а запуск анимации и подписки на события — в `useEffect` с очисткой (`cancelAnimationFrame`, снять слушатели, `clearTimeout` для таймеров).
Подскажи, какой «билет» и какое «устройство» подойдут для входа на мой сайт.

Код скопируется вместе с промптом

Вместо обычного первого экрана — бежевый ретро-ридер с тёмной щелью и экранчиком «Вставьте талон». Над ним парит посадочный талон «гостя сайта». Перетащите талон вниз и отпустите над щелью — он уходит внутрь, на экранчике «Чтение…», жёлтый огонёк мигает, потом «Доступ открыт», огонёк зелёный, и сайт раскрывается тёмным кругом: «Добро пожаловать на борт». Кнопка «выйти из салона» возвращает к ридеру.

Подходит как входная заставка для портфолио, сайта мероприятия, тревел-проекта, приглашения или закрытого раздела — там, где вход должен ощущаться событием.

Как это устроено

  • Ридер и талон — обычная вёрстка на CSS (градиенты, тени, штрихкод из repeating-linear-gradient), экранчик — пиксельный шрифт со свечением.
  • Ридер лежит над талоном по z-index, поэтому талон «входит в щель», просто уезжая за его верхний край — без масок и обрезки.
  • Талон тянется указателем, наклоняется от скорости, отпущенный рядом со щелью — вставляется, далеко — возвращается на место. Есть двойной клик и Enter.
  • Переход на «борт» — clip-path: circle() от 0 до 150%. Без ввода сцена проигрывается сама. При «уменьшении движения» переходы мгновенные.

Код наш (MIT), идея подсмотрена в рилсе с подборкой личных сайтов (вход в портфолио по посадочному талону): взят только приём, устройство, тексты и оформление свои.

Как получить такой же результат

  • Промпт содержит страницу одним файлом, она работает двойным щелчком.
  • Данные талона и надписи — в HTML. Что открывается после чтения — блок .welcome: замените его своим первым экраном или перенаправьте на страницу в функции insert().
  • Длительность чтения — READ_MS, «зона щели» — SNAP.
Код
<!-- MIT License. Copyright (c) 2026 Sergei Durgalian, learn.create-products.com/design. Free to use, copy and modify with this notice kept. -->
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Вход по посадочному талону</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500;700&family=Pixelify+Sans:wght@500&display=swap">
<style>
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #f2f1ee; color: #1c1c1c; font-family: "Inter", sans-serif; overflow: hidden; }
.scene { position: fixed; inset: 0; display: grid; place-items: center; }
.stack { position: relative; width: min(540px, 86vw); aspect-ratio: 430 / 330; }

/* reader: beige retro box */
.reader { position: absolute; left: 0; right: 0; bottom: 0; height: 44%; border-radius: 10px;
  background: linear-gradient(#e9dfc6, #d8ccae 55%, #c7b995); box-shadow: inset 0 2px 0 rgba(255,255,255,.7), inset 0 -4px 0 rgba(0,0,0,.08), 0 24px 40px rgba(60,50,20,.18); z-index: 2; }
.reader::before { content: ""; position: absolute; left: 6%; right: 6%; top: 8px; height: 8px; border-radius: 4px; background: linear-gradient(#2b2a26, #57534a); box-shadow: inset 0 2px 3px rgba(0,0,0,.6); }
.reader .grille { position: absolute; left: 6%; top: 28%; width: 22%; height: 18%; background: repeating-linear-gradient(90deg, #a99c7b 0 2px, transparent 2px 5px); opacity: .7; }
.lcd { position: absolute; left: 30%; right: 18%; top: 38%; height: 34%; border-radius: 4px; background: #111; box-shadow: inset 0 0 0 3px #3a3730; display: grid; place-items: center;
  font: 400 clamp(10px, 2.6vw, 15px) "Pixelify Sans", monospace; letter-spacing: .08em; color: #f6b73c; text-shadow: 0 0 6px currentColor; }
.lcd.ok { color: #5df08b; }
.led { position: absolute; right: 7%; top: 47%; width: 16px; height: 16px; border-radius: 50%; background: #6d6754; box-shadow: inset 0 1px 2px rgba(0,0,0,.6); }
.led.read { background: #ffd23e; box-shadow: 0 0 10px #ffd23e; animation: blink .25s steps(2) infinite; }
.led.ok { background: #44e27b; box-shadow: 0 0 12px #44e27b; }
@keyframes blink { 50% { opacity: .3; } }

/* boarding pass */
.pass { position: absolute; left: 13%; top: 0; width: 74%; aspect-ratio: 320 / 150; z-index: 1; touch-action: none; cursor: grab; will-change: transform;
  background: #fbfbf9; border-radius: 8px; box-shadow: 0 10px 24px rgba(0,0,0,.14), 0 1px 0 rgba(0,0,0,.05); padding: 4.5% 5%; font-family: "JetBrains Mono", monospace; color: #2b2b2b; }
.pass.drag { cursor: grabbing; }
.pass::after { content: ""; position: absolute; right: 26%; top: 8px; bottom: 8px; border-left: 2px dashed #d5d5d0; }
.pass .row { display: flex; justify-content: space-between; font-size: clamp(7px, 1.6vw, 10px); color: #8a8a85; letter-spacing: .06em; }
.pass .big { display: flex; gap: 14%; margin: 4% 0 3%; font: 700 clamp(14px, 3.6vw, 24px) "JetBrains Mono"; color: #1c1c1c; }
.pass .name { font: 600 clamp(9px, 2vw, 13px) "Inter"; color: #1c1c1c; letter-spacing: .04em; }
.pass .bar { position: absolute; right: 5%; top: 16%; bottom: 16%; width: 15%; background: repeating-linear-gradient(0deg, #222 0 2px, transparent 2px 4px, #222 4px 5px, transparent 5px 8px); }
.pass .logo { width: 22px; height: 6px; background: #2c5cd6; border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: middle; }

.caption { position: absolute; left: 0; right: 0; bottom: -40px; text-align: center; font-size: 12px; color: #8a8a85; }
.caption b { color: #1c1c1c; font-weight: 500; }

/* after access */
.welcome { position: fixed; inset: 0; display: grid; place-items: center; align-content: center; gap: 14px; text-align: center; background: #12141a; color: #f2f1ee;
  clip-path: circle(0% at 50% 70%); transition: clip-path .9s cubic-bezier(.7,0,.2,1); z-index: 5; }
.welcome.open { clip-path: circle(150% at 50% 70%); }
.welcome h1 { margin: 0; font: 600 clamp(32px, 6vw, 72px)/1 "Inter"; letter-spacing: -.03em; }
.welcome p { margin: 0; font: 500 13px "JetBrains Mono"; color: #9aa0ad; letter-spacing: .08em; }
.welcome button { margin-top: 18px; justify-self: center; font: 500 12px "JetBrains Mono"; color: #12141a; background: #f2f1ee; border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .welcome { transition: none; } .led.read { animation: none; } }
</style>
</head>
<body>
<div class="scene">
  <div class="stack" id="stack">
    <div class="pass" id="pass">
      <div class="row"><span><i class="logo"></i>АЭРО·ПОРТФОЛИО</span><span>РЕЙС CP 2026</span></div>
      <div class="big"><span>МОВ</span><span>→</span><span>РАБ</span></div>
      <div class="name">ГОСТЬ САЙТА</div>
      <div class="row" style="margin-top:6%"><span>ВЫХОД 7</span><span>МЕСТО 1A</span><span style="margin-right:30%">25 НОЯ</span></div>
      <div class="bar"></div>
    </div>
    <div class="reader">
      <div class="grille"></div>
      <div class="lcd" id="lcd">ВСТАВЬТЕ ТАЛОН</div>
      <div class="led" id="led"></div>
    </div>
    <div class="caption" id="cap">Опустите <b>посадочный талон</b> в щель, чтобы войти</div>
  </div>
</div>
<section class="welcome" id="welcome">
  <p>ДОСТУП РАЗРЕШЁН · МЕСТО 1A</p>
  <h1>Добро пожаловать на борт</h1>
  <p>12 проектов · 6 лет в продуктовом дизайне</p>
  <button id="exit">выйти из салона</button>
</section>

<script>
// ---- settings ----
const SNAP = 0.55;       // how close (in card heights) the card must be to the slot to be taken in
const READ_MS = 1300;    // reading time
const AUTO = new URLSearchParams(location.search).has('auto');
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;

const stack = document.getElementById('stack'), pass = document.getElementById('pass');
const lcd = document.getElementById('lcd'), led = document.getElementById('led');
const welcome = document.getElementById('welcome');

// card position in px relative to its home (top of the stack); y grows downward
const P = { x: 0, y: 0, vx: 0, vy: 0, rot: 0, tx: 0, ty: 0 };
let mode = 'free';       // free | drag | insert | read | ok | eject
let grab = null, lastInput = -1e9, timer = 0;

// The reader is drawn above the card, so the card simply slides behind its top edge.
function slotDepth() { // y where only the top fifth of the card still sticks out of the slot
  const reader = stack.querySelector('.reader');
  return reader.offsetTop + 10 - pass.offsetTop - pass.offsetHeight * 0.2;
}
function setScreen(text, cls) { lcd.textContent = text; lcd.className = 'lcd ' + (cls || ''); led.className = 'led ' + (cls || ''); }

pass.addEventListener('pointerdown', (e) => {
  if (mode !== 'free') return;
  mode = 'drag'; grab = { x: e.clientX - P.x, y: e.clientY - P.y };
  pass.setPointerCapture(e.pointerId); pass.classList.add('drag'); lastInput = performance.now();
});
pass.addEventListener('pointermove', (e) => {
  if (mode !== 'drag') return;
  const nx = e.clientX - grab.x, ny = e.clientY - grab.y;
  P.vx = nx - P.x; P.vy = ny - P.y; P.x = nx; P.y = Math.min(ny, slotDepth() * 0.45); lastInput = performance.now();
});
pass.addEventListener('pointerup', () => { if (mode !== 'drag') return; pass.classList.remove('drag'); release(); });
pass.addEventListener('dblclick', () => { if (mode === 'free') insert(); });
addEventListener('keydown', (e) => { if (e.key === 'Enter' && mode === 'free') insert(); if (e.key === 'Escape') exit(); });

function release() {
  const h = pass.offsetHeight;
  const near = Math.abs(P.x) < stack.offsetWidth * 0.2 && P.y > slotDepth() * 0.45 - h * SNAP;
  if (near) insert(); else { mode = 'free'; P.tx = 0; P.ty = 0; }
}
function insert() {
  mode = 'insert'; P.tx = 0; P.ty = slotDepth(); setScreen('ЧТЕНИЕ…', 'read');
  clearTimeout(timer);
  timer = setTimeout(() => {
    setScreen('ДОСТУП ОТКРЫТ', 'ok'); mode = 'ok';
    timer = setTimeout(() => { welcome.classList.add('open'); mode = 'eject'; P.ty = 0; }, 700);
  }, READ_MS);
}
function exit() {
  welcome.classList.remove('open'); mode = 'free'; P.tx = 0; P.ty = 0; setScreen('ВСТАВЬТЕ ТАЛОН');
}
document.getElementById('exit').addEventListener('click', exit);

// demo: card floats over, drops into the slot, then the page opens and closes again
let demoT0 = 0;
function demo(t) {
  if (!AUTO && (reduce || t - lastInput < 6000)) { demoT0 = 0; return; }
  if (!demoT0) { demoT0 = t; if (mode !== 'free') exit(); }
  const k = t - demoT0;
  if (mode === 'free' && k < 1800) { P.tx = Math.sin(k / 300) * 18; P.ty = -10 + (k / 1800) * 40; }
  if (mode === 'free' && k >= 1800 && k < 2500) insert();
  if (k > 5600) { exit(); demoT0 = 0; }
}

let prev = performance.now();
function frame(t) {
  demo(t);
  if (mode !== 'drag') {
    const ease = reduce ? 1 : mode === 'insert' ? 0.09 : 0.14;
    const nx = P.x + (P.tx - P.x) * ease, ny = P.y + (P.ty - P.y) * ease;
    P.vx = nx - P.x; P.vy = ny - P.y; P.x = nx; P.y = ny;
  }
  // tilt from horizontal speed; hide the part that went into the slot
  P.rot += (Math.max(-12, Math.min(12, P.vx * 0.6)) - P.rot) * 0.2;
  const float = mode === 'free' && !reduce ? Math.sin(t / 900) * 4 : 0;
  pass.style.transform = `translate(${P.x.toFixed(1)}px, ${(P.y + float).toFixed(1)}px) rotate(${P.rot.toFixed(2)}deg)`;
  prev = t;
  requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
</script>
</body>
</html>

Похожие