Промпт Скопировать
Добавь на мою страницу эффект «Вход на сайт по посадочному талону» (Сергей Дургалян, MIT). Ниже готовая страница без библиотек: HTML, CSS и чистый JavaScript. Сначала перенеси её как есть и проверь: талон перетаскивается мышью и пальцем, после броска летит по инерции и отскакивает от краёв; у щели терминал сам затягивает талон, табло пишет «ЧИТАЮ», затем мигает «ДОБРО ПОЖАЛОВАТЬ», и шторка уезжает вверх; кнопка «Ещё раз» возвращает заставку; если 3 секунды ничего не трогать, рука-курсор сама проводит талон. Потом меняй.
Как устроен код. Заставка `#intro` — фиксированная шторка поверх сайта (`main`); класс `open` уводит её вверх через `transform`. Состояние талона хранится в объекте `T`: центр `x/y`, скорость `vx/vy` в пикселях за кадр, наклон `r` и режим `mode` (`idle` — лежит или летит, `feed` — терминал затягивает, `done` — прочитан). При перетаскивании скорость считается по последним движениям указателя, после отпускания талон летит с трением `FRICTION` и отскакивает от стен, наклон следует за горизонтальной скоростью. Если низ талона оказался ближе `MAGNET` пикселей к щели (а при перетаскивании ещё и движется вниз), включается `feed`: талон выравнивается над щелью и опускается, а всё ниже линии щели обрезается `clip-path: inset(...)`, поэтому кажется, что он уходит внутрь. Положение щели считается через `offsetTop`, а не `getBoundingClientRect`, чтобы не сбиваться, пока шторка едет. Автодемо: после `IDLE_DEMO` без ввода рука-курсор (SVG) подлетает к талону и ведёт его по дуге к щели; если после открытия сайта 5 секунд никто ничего не трогает, шторка закрывается сама, чтобы демо шло по кругу. На своём сайте убери эту ветку (`T.mode === "done"` в `frame`), иначе заставка будет возвращаться. Штрихкод — полоски случайной ширины, но генератор задаётся строкой рейса, так что рисунок всегда один и тот же. Доступность: талон — `role="button"` с `tabindex`, Enter или пробел сразу отправляют его в терминал; табло объявляется через `aria-live`. При `prefers-reduced-motion` нет наклона и мигания, талон уходит в щель мгновенно, шторка не едет, а растворяется.
Что менять: данные талона (пассажир, рейс, место, маршрут) — в разметке `.ticket`; надписи табло — в `startFeed` и `finish`; цвета терминала, табло и талона — в CSS; чувствительность — `MAGNET` (больше — проще попасть), `FRICTION` (ближе к 1 — дольше летит), `IDLE_DEMO`. Вместо шторки можно запускать любую анимацию открытия: всё начинается в функции `finish`. Если заставка должна показываться один раз, запоминай факт входа в `localStorage` и не рисуй `#intro` при повторном визите.
Если проект на React: вынеси заставку в компонент `BoardingIntro` с пропсом `onOpen`. Талон и щель — `useRef`, физику держи в обычном объекте внутри `useRef`, а не в состоянии (иначе рендер на каждом кадре); цикл `requestAnimationFrame` и слушатели заводи в `useEffect` и снимай в очистке. Режим (`idle`/`feed`/`done`) можно держать в `useState`, если от него зависит разметка (надпись табло, лампочки).
Покажи, где на моём сайте такая заставка уместна, и предложи свой «билет» под мой продукт: что написать в полях вместо рейса и места. Код скопируется вместе с промптом
Вместо обычной заставки на светлом экране лежит бумажный посадочный талон: пассажир «Гость», рейс, место, штрихкод. Ниже стоит ретро-терминал со щелью и зелёным табло «ГОТОВ». Талон берётся мышью или пальцем и летит с инерцией. Если подвести его к щели, терминал сам подхватывает талон и затягивает внутрь, табло пишет «ЧИТАЮ», потом мигает «ДОБРО ПОЖАЛОВАТЬ», загораются лампочки, и шторка уезжает вверх, открывая сайт. Если 3 секунды ничего не трогать, рука-курсор сама проводит талон. Приём подсмотрен на mikes.cv.
Библиотек нет: талон — обычный HTML-блок, который двигается через transform, штрихкод — сгенерированный SVG. Терминал «съедает» талон без масок и 3D: всё, что опустилось ниже линии щели, обрезается clip-path. Подходит для промо, портфолио, приглашения на событие, страницы «вы записаны» и любого места, где первый жест посетителя можно превратить в маленький ритуал.
Код Скопировать
<!-- 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>Boarding Pass Intro</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@500;700&family=Unbounded:wght@700&display=swap">
<style>
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overflow: hidden; font-family: "IBM Plex Mono", monospace; color: #1d1b18; background: #12110f; }
/* the page that opens after boarding */
main { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; gap: 18px; padding: 24px;
color: #f4efe4; background: radial-gradient(80% 70% at 50% 30%, #2b4cff 0%, #141a4a 60%, #0b0d22 100%); }
main h1 { margin: 0; font: 700 clamp(34px, 7vw, 84px)/1 "Unbounded", sans-serif; letter-spacing: -.02em; }
main p { margin: 0; opacity: .75; font-size: 15px; }
main button { justify-self: center; font: 700 14px "IBM Plex Mono", monospace; padding: 12px 20px; border-radius: 999px;
border: 1.5px solid #f4efe4; background: transparent; color: inherit; cursor: pointer; }
/* intro curtain */
#intro { position: fixed; inset: 0; overflow: hidden; background: #efe9dc;
background-image: radial-gradient(#00000010 1px, transparent 1px); background-size: 14px 14px;
transition: transform .9s cubic-bezier(.7, 0, .2, 1); }
#intro.open { transform: translateY(-100%); }
.hint { position: absolute; left: 0; right: 0; top: 22px; text-align: center; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; opacity: .55; }
/* ticket */
.ticket { position: absolute; left: 0; top: 0; width: min(320px, 82vw); aspect-ratio: 2 / 1; z-index: 3; touch-action: none;
display: grid; grid-template-columns: 1fr 26%; border-radius: 10px; background: #fffdf7; cursor: grab; user-select: none;
box-shadow: 0 1px 0 #0000000d, 0 14px 30px -12px #3b2a0a55; will-change: transform; }
.ticket.drag { cursor: grabbing; box-shadow: 0 30px 50px -18px #3b2a0a66; }
.ticket:focus-visible { outline: 3px solid #2b4cff; outline-offset: 4px; }
.t-main { padding: 12px 14px; display: grid; grid-template-rows: auto 1fr auto; gap: 6px; }
.t-head { display: flex; justify-content: space-between; font-size: 9px; letter-spacing: .14em; color: #e0502a; font-weight: 700; }
.t-route { font: 700 clamp(18px, 6vw, 24px)/1 "Unbounded", sans-serif; display: flex; align-items: center; gap: 8px; }
.t-route i { flex: 1; height: 0; border-top: 1.5px dashed #1d1b1855; }
.t-grid { display: grid; grid-template-columns: repeat(3, auto); gap: 2px 10px; font-size: 8px; text-transform: uppercase; color: #1d1b1888; }
.t-grid b { display: block; font-size: 11px; color: #1d1b18; }
.t-stub { border-left: 2px dashed #1d1b1830; padding: 10px 8px; display: grid; align-content: space-between; justify-items: center; }
.t-stub b { font: 700 18px "Unbounded", sans-serif; }
.t-stub svg { width: 100%; height: 46%; }
/* terminal */
.terminal { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: min(400px, 92vw); z-index: 2;
height: 44vh; min-height: 280px; border-radius: 26px 26px 0 0; padding: 26px 26px 0; background: linear-gradient(#d9d1bf, #c4baa4);
box-shadow: inset 0 2px 0 #fff8, inset 0 -6px 0 #0001, 0 -10px 40px -20px #0006; }
.slot { height: 14px; border-radius: 8px; margin: 0 4px; background: #191714; box-shadow: inset 0 3px 4px #000, 0 2px 0 #fff9; }
.screen { margin-top: 24px; height: 64px; border-radius: 10px; background: #1a2316; display: grid; place-items: center;
box-shadow: inset 0 0 0 3px #0006, inset 0 6px 16px #0008; color: #9cff6b; font-size: 22px; font-weight: 700; letter-spacing: .2em; text-shadow: 0 0 8px #9cff6b99; }
.screen.blink { animation: blink .18s steps(2) 5; }
@keyframes blink { 50% { opacity: .15; } }
.leds { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.leds span { width: 9px; height: 9px; border-radius: 50%; background: #8d8575; box-shadow: inset 0 1px 2px #0005; }
.leds span.on { background: #ff6a3d; box-shadow: 0 0 10px #ff6a3d; }
.keys { display: grid; grid-template-columns: repeat(3, 34px); gap: 8px; justify-content: center; margin-top: 18px; }
.keys i { height: 22px; border-radius: 6px; background: #e9e2d2; box-shadow: 0 3px 0 #a89e88; }
.brand { margin-top: 16px; text-align: center; font-size: 10px; letter-spacing: .3em; opacity: .5; }
/* demo hand */
.hand { position: absolute; left: 0; top: 0; width: 44px; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .3s; filter: drop-shadow(0 6px 8px #0004); }
.hand.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #intro { transition: opacity .4s; } #intro.open { transform: none; opacity: 0; pointer-events: none; } }
</style>
</head>
<body>
<main>
<h1>Вы на борту</h1>
<p>Тут начинается ваш сайт: первый экран, меню, всё остальное.</p>
<button id="again" type="button">Ещё раз</button>
</main>
<section id="intro" aria-label="Вход по посадочному талону">
<div class="hint" id="hint">Перетащите талон в щель терминала</div>
<div class="ticket" id="ticket" role="button" tabindex="0" aria-label="Посадочный талон. Нажмите Enter, чтобы приложить к терминалу">
<div class="t-main">
<div class="t-head"><span>ПОСАДОЧНЫЙ ТАЛОН</span><span>ЭКОНОМ+</span></div>
<div class="t-route">ВХД <i></i> ✈ <i></i> САЙТ</div>
<div class="t-grid">
<span>Пассажир<b>Гость</b></span><span>Рейс<b>КП 2611</b></span><span>Место<b>01А</b></span>
<span>Выход<b>7</b></span><span>Посадка<b>09:41</b></span><span>Класс<b>Y</b></span>
</div>
</div>
<div class="t-stub"><span>МЕСТО</span><b>01А</b><svg id="barcode" viewBox="0 0 60 40" preserveAspectRatio="none" aria-hidden="true"></svg></div>
</div>
<div class="terminal" id="terminal">
<div class="slot" id="slot"></div>
<div class="screen" id="screen" aria-live="polite">ГОТОВ</div>
<div class="leds"><span></span><span></span><span></span></div>
<div class="keys" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i><i></i></div>
<div class="brand">ТЕРМИНАЛ ПОСАДКИ</div>
</div>
<svg class="hand" id="hand" viewBox="0 0 24 24" aria-hidden="true"><path fill="#fff" stroke="#1d1b18" stroke-width="1.2" stroke-linejoin="round" d="M9 11V4.5a1.5 1.5 0 0 1 3 0V10l.1-1.4a1.5 1.5 0 0 1 3 .1V11l.1-.8a1.5 1.5 0 0 1 3 .2V12l.1-.4a1.4 1.4 0 0 1 2.7.6V16c0 3.6-2.6 6-6 6h-1.6c-2 0-3.4-.8-4.6-2.3L5 15.4a1.6 1.6 0 0 1 2.4-2.1L9 15z"/></svg>
</section>
<script>
const $ = (id) => document.getElementById(id);
const intro = $("intro"), ticket = $("ticket"), slot = $("slot"), screen = $("screen"), hand = $("hand"), hint = $("hint");
const leds = [...document.querySelectorAll(".leds span")];
const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
const IDLE_DEMO = 3000; // ms without input before the hand shows the gesture
const FRICTION = 0.9; // inertia per 16 ms frame
const MAGNET = 110; // px from the slot mouth where the terminal grabs the ticket
// barcode: pseudo-random bars seeded by the flight code
(function barcode(seed) {
let s = [...seed].reduce((a, c) => a * 31 + c.charCodeAt(0), 7) >>> 0, x = 1, out = "";
const rnd = () => ((s = (s * 1664525 + 1013904223) >>> 0) / 4294967296);
while (x < 59) { const w = rnd() < .5 ? 1 : rnd() < .7 ? 2 : 3; if (rnd() > .35) out += `<rect x="${x}" width="${w * .9}" height="40" fill="#1d1b18"/>`; x += w + .6; }
$("barcode").innerHTML = out;
})("КП2611");
// state: ticket centre in px, velocity in px/frame, rotation in deg
const T = { x: 0, y: 0, vx: 0, vy: 0, r: -6, w: 0, h: 0, drag: false, mode: "idle", feedT: 0 };
let lastInput = performance.now(), doneAt = 0, demo = null, grab = { dx: 0, dy: 0, px: 0, py: 0, t: 0 };
// slot mouth in curtain coordinates (offsets ignore the curtain's own slide transform)
const terminal = $("terminal");
function mouth() { return { x: innerWidth / 2, y: terminal.offsetTop + slot.offsetTop + slot.offsetHeight / 2 }; }
function home() {
T.w = ticket.offsetWidth; T.h = ticket.offsetHeight;
const m = mouth();
T.x = innerWidth / 2 + (innerWidth > 640 ? 70 : 0); T.y = Math.max(T.h / 2 + 60, (m.y - 40) / 2 + 20);
T.vx = T.vy = 0; T.r = -6; T.mode = "idle"; ticket.style.clipPath = ""; ticket.style.opacity = "";
}
function place() { ticket.style.transform = `translate(${T.x - T.w / 2}px, ${T.y - T.h / 2}px) rotate(${T.r}deg)`; }
function startFeed() {
if (T.mode === "feed" || T.mode === "done") return;
stopDemo(); T.mode = "feed"; T.feedT = 0; T.drag = false; ticket.classList.remove("drag");
screen.textContent = "ЧИТАЮ";
}
function finish() {
T.mode = "done"; doneAt = performance.now(); screen.textContent = "ДОБРО ПОЖАЛОВАТЬ"; screen.style.fontSize = "15px";
if (!reduced) screen.classList.add("blink");
leds.forEach((l, i) => setTimeout(() => l.classList.add("on"), reduced ? 0 : i * 160));
setTimeout(() => intro.classList.add("open"), reduced ? 300 : 1100);
setTimeout(() => $("again").focus({ preventScroll: true }), 1800);
}
function reset() {
intro.classList.remove("open"); screen.classList.remove("blink"); screen.textContent = "ГОТОВ"; screen.style.fontSize = "";
leds.forEach((l) => l.classList.remove("on")); home(); place(); lastInput = performance.now();
}
$("again").addEventListener("click", reset);
// pointer drag with velocity tracking (works for mouse, pen and touch)
ticket.addEventListener("pointerdown", (e) => {
if (T.mode !== "idle") return;
stopDemo(); lastInput = performance.now();
ticket.setPointerCapture(e.pointerId); T.drag = true; ticket.classList.add("drag");
grab = { dx: e.clientX - T.x, dy: e.clientY - T.y, px: e.clientX, py: e.clientY, t: performance.now() };
});
ticket.addEventListener("pointermove", (e) => {
if (!T.drag) return;
const now = performance.now(), k = 16 / Math.max(8, now - grab.t);
T.vx = T.vx * .5 + (e.clientX - grab.px) * k * .5; T.vy = T.vy * .5 + (e.clientY - grab.py) * k * .5;
grab.px = e.clientX; grab.py = e.clientY; grab.t = now;
T.x = e.clientX - grab.dx; T.y = e.clientY - grab.dy; lastInput = now;
});
const release = () => { if (!T.drag) return; T.drag = false; ticket.classList.remove("drag"); };
ticket.addEventListener("pointerup", release);
ticket.addEventListener("pointercancel", release);
ticket.addEventListener("keydown", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); stopDemo(); startFeed(); } });
addEventListener("pointermove", () => { lastInput = performance.now(); });
addEventListener("resize", () => { if (T.mode === "idle" && !T.drag) home(); });
// demo: a hand grabs the ticket and flicks it into the slot
function stopDemo() { demo = null; hand.classList.remove("show"); }
function runDemo(now) {
const m = mouth(), d = demo, t = (now - d.t0) / 1000;
const ease = (v) => v < .5 ? 2 * v * v : 1 - (-2 * v + 2) ** 2 / 2;
let hx, hy;
if (t < .7) { const k = ease(t / .7); hx = innerWidth + 40 + (T.x - innerWidth - 40) * k; hy = innerHeight * .3 + (T.y - innerHeight * .3) * k; }
else if (t < 1.9) {
if (!T.drag) { T.drag = true; ticket.classList.add("drag"); d.sx = T.x; d.sy = T.y; }
const k = ease((t - .7) / 1.2), px = T.x, py = T.y;
T.x = d.sx + (m.x - d.sx) * k + Math.sin(k * Math.PI) * -60; T.y = d.sy + (m.y - T.h / 2 - 30 - d.sy) * k;
T.vx = T.x - px; T.vy = T.y - py; hx = T.x; hy = T.y;
} else { release(); hand.classList.remove("show"); demo = null; return; }
hand.style.transform = `translate(${hx - 14}px, ${hy - 6}px) scale(${t > .6 && t < 1.9 ? .9 : 1})`;
}
let prev = performance.now();
function frame(now) {
const dt = Math.min(3, (now - prev) / 16.67); prev = now;
const m = mouth();
if (!demo && T.mode === "idle" && !T.drag && now - lastInput > IDLE_DEMO && !intro.classList.contains("open")) {
demo = { t0: now }; hand.classList.add("show");
}
if (demo) runDemo(now);
if (T.mode === "idle") {
if (!T.drag) {
T.x += T.vx * dt; T.y += T.vy * dt; const f = FRICTION ** dt; T.vx *= f; T.vy *= f;
// soft walls
if (T.x < T.w / 2) { T.x = T.w / 2; T.vx *= -.5; } if (T.x > innerWidth - T.w / 2) { T.x = innerWidth - T.w / 2; T.vx *= -.5; }
if (T.y < T.h / 2) { T.y = T.h / 2; T.vy *= -.5; } if (T.y > m.y - T.h / 2 - 4) { T.y = m.y - T.h / 2 - 4; T.vy *= -.3; }
}
// tilt follows the horizontal speed
T.r += ((reduced ? 0 : Math.max(-18, Math.min(18, T.vx * 1.4))) - 2 - T.r) * .15;
if (Math.hypot(T.x - m.x, T.y + T.h / 2 - m.y) < MAGNET && (!T.drag || T.vy > 2)) startFeed();
} else if (T.mode === "feed") {
T.feedT += dt;
if (T.feedT < 12 && !reduced) { // align above the slot
T.x += (m.x - T.x) * .25; T.y += (m.y - T.h / 2 - T.y) * .25; T.r *= .7;
} else { // terminal pulls the ticket in, behind its front panel
T.r = 0; T.x = m.x; T.y += reduced ? T.h : 7 * dt;
// everything below the slot line is "inside" the terminal
ticket.style.clipPath = `inset(0 0 ${Math.max(0, T.y + T.h / 2 - m.y)}px 0)`;
if (T.y - T.h / 2 > m.y + 4) { ticket.style.opacity = "0"; finish(); }
}
} else if (T.mode === "done" && intro.classList.contains("open") && now - doneAt > 5000 && now - lastInput > IDLE_DEMO) {
reset(); // demo loop: close the curtain again when nobody is around
}
place();
requestAnimationFrame(frame);
}
document.fonts.ready.then(() => { home(); place(); });
home(); place(); requestAnimationFrame(frame);
</script>
</body>
</html>