Светящийся шов

Тонкая светящаяся линия горизонта в 1px, которая локально прогибается к курсору как натянутая мембрана. Прокрутите или потяните шов вверх, чтобы приоткрыть верхний слой с живой тенью на нижнем.

Подведите курсор к светящейся линии чтобы согнуть её, затем потяните вверх или прокрутите страницу.

Скачать

Что можно поменять

Поменяйте число, сохраните файл и обновите страницу, разница будет видна сразу.

NODES36

Количество контрольных точек вдоль SVG-сплайна шва.

PULL_RADIUS210

Дистанция курсора в px, с которой шов начинает прогибаться.

PULL_MAX64

Максимальное локальное смещение к курсору в пикселях.

SPRING0.15

Жёсткость пружины, возвращающей шов к целевой форме.

Как поставить на свой сайт

Подходит для первого экрана, сравнения до/после или интерактивного перехода к тарифам и кейсам.

Комментарии в коде на английском, так файл понятен любому разработчику.

  1. CSS

    Вставьте в свой файл стилей или в тег <style> внутри <head>.

    /* Seam Reveal by @codinvisual - t.me/CodinVisual - page shell, only while this file is the whole page */
  2. HTML

    Поставьте в то место страницы, где должен быть эффект.

    <!-- stage start -->
    <div class="smr">
      <div class="smr-stage">
        <!-- Lower recessed layer unveiled as the upper sheet peels away -->
        <section class="smr-under" id="smr-under-layer" aria-label="Revealed layer">
          <div class="smr-under-inner" id="smr-under-inner">
            <div class="smr-meta">02 / BENEATH THE SEAM</div>
            <h2 class="smr-h">Two layers of depth, one living edge</h2>
            <p class="smr-p">
              The upper sheet stays pinned until you scroll or pull the horizon upward, casting a soft shadow across the recessed surface below.
            </p>
            <div class="smr-specs">
              <div class="smr-spec"><span>Membrane</span><b>36-node spline</b></div>
              <div class="smr-spec"><span>Physics</span><b>Spring + momentum</b></div>
              <div class="smr-spec"><span>Lighting</span><b>Pointer-tracked rim</b></div>
            </div>
            <button type="button" class="smr-btn" id="smr-reset">Close horizon</button>
          </div>
        </section>
    
        <!-- Upper Hero sheet clipped cleanly to the living SVG seam -->
        <section class="smr-hero" id="smr-hero-layer" aria-label="Surface layer">
          <div class="smr-hero-content" id="smr-hero-content">
            <div class="smr-hero-inner">
              <div class="smr-hero-bar">
                <div class="smr-meta" style="margin:0">01 / SURFACE</div>
                <div class="smr-readout">OPTICAL MEMBRANE</div>
              </div>
              <h1 class="smr-h">Pull back the horizon</h1>
              <p class="smr-p">
                Move near the glowing line to bend it like a taut membrane, or drag it upward to peel away the surface layer.
              </p>
            </div>
          </div>
        </section>
    
        <!-- SVG layer: deep cast shadow under the lip + unbroken 1px specular seam rim -->
        <svg class="smr-svg" viewBox="0 0 1440 900" preserveAspectRatio="none" aria-hidden="true">
          <defs>
            <linearGradient id="smr-rim-grad" x1="0%" y1="0%" x2="100%" y2="0%">
              <stop offset="0%" stop-color="#5eead4" stop-opacity="0.20"></stop>
              <stop offset="32%" stop-color="#5eead4" stop-opacity="0.76" id="smr-stop-a"></stop>
              <stop offset="50%" stop-color="#ededef" stop-opacity="1" id="smr-stop-b"></stop>
              <stop offset="68%" stop-color="#5eead4" stop-opacity="0.76" id="smr-stop-c"></stop>
              <stop offset="100%" stop-color="#5eead4" stop-opacity="0.20"></stop>
            </linearGradient>
            <clipPath id="smr-hero-clip" clipPathUnits="userSpaceOnUse">
              <path id="smr-clip-path" d="M0,0 L1440,0 L1440,648 L0,648 Z"></path>
            </clipPath>
          </defs>
          <path id="smr-shadow-far" d="M0,648 L1440,648" fill="none" stroke="#020306" stroke-opacity="0.60" stroke-width="58" transform="translate(0, 26)" vector-effect="non-scaling-stroke"></path>
          <path id="smr-shadow-mid" d="M0,648 L1440,648" fill="none" stroke="#020408" stroke-opacity="0.72" stroke-width="26" transform="translate(0, 11)" vector-effect="non-scaling-stroke"></path>
          <path id="smr-shadow-lip" d="M0,648 L1440,648" fill="none" stroke="#010204" stroke-opacity="0.86" stroke-width="7" transform="translate(0, 3)" vector-effect="non-scaling-stroke"></path>
          <path id="smr-glow-wide" d="M0,648 L1440,648" fill="none" stroke="#5eead4" stroke-opacity="0.11" stroke-width="22" vector-effect="non-scaling-stroke"></path>
          <path id="smr-glow-mid" d="M0,648 L1440,648" fill="none" stroke="#5eead4" stroke-opacity="0.26" stroke-width="3.5" vector-effect="non-scaling-stroke"></path>
          <path id="smr-rim" d="M0,648 L1440,648" fill="none" stroke="url(#smr-rim-grad)" stroke-width="1.25" vector-effect="non-scaling-stroke"></path>
        </svg>
    
        <!-- Invisible full-width grip strip along the seam + delicate floating cue below -->
        <button type="button" class="smr-hit" id="smr-hit" aria-label="Drag or click horizon seam to reveal layer" aria-expanded="false"></button>
        <div class="smr-cue" id="smr-cue" aria-hidden="true">
          <span class="smr-cue-bar"></span>
          <span class="smr-cue-label">Scroll or pull horizon</span>
        </div>
      </div>
    </div>
    <!-- stage end -->
  3. JavaScript

    Вставьте перед закрывающим тегом </body>, внутри <script></script>.

    /* Seam Reveal by @codinvisual - t.me/CodinVisual - free for your own site, don't resell this file */
    const NODES = 36;
    const PULL_RADIUS = 210;
    const PULL_MAX = 64;
    const SPRING = 0.15;
    const DAMPING = 0.76;
    const REST_Y = 0.72;
    const OPEN_Y = 0.12;
    
    const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
    const root = document.querySelector('.smr');
    const stage = document.querySelector('.smr-stage');
    const svg = document.querySelector('.smr-svg');
    const clipPath = document.getElementById('smr-clip-path');
    const shadowFar = document.getElementById('smr-shadow-far');
    const shadowMid = document.getElementById('smr-shadow-mid');
    const shadowLip = document.getElementById('smr-shadow-lip');
    const glowWide = document.getElementById('smr-glow-wide');
    const glowMid = document.getElementById('smr-glow-mid');
    const rimPath = document.getElementById('smr-rim');
    const stopA = document.getElementById('smr-stop-a');
    const stopB = document.getElementById('smr-stop-b');
    const stopC = document.getElementById('smr-stop-c');
    const heroLayer = document.getElementById('smr-hero-layer');
    const underLayer = document.getElementById('smr-under-layer');
    const heroContent = document.getElementById('smr-hero-content');
    const underInner = document.getElementById('smr-under-inner');
    const hitBtn = document.getElementById('smr-hit');
    const cueEl = document.getElementById('smr-cue');
    const resetBtn = document.getElementById('smr-reset');
    
    let vw = window.innerWidth || 1440;
    let vh = window.innerHeight || 900;
    let openTarget = 0;
    let openPos = 0;
    let openVel = 0;
    let lightX = 0.5;
    let lightTargetX = 0.5;
    let pointer = null;
    let dragPid = 0;
    let dragStartY = 0;
    let dragStartOpen = 0;
    let dragMoved = false;
    let raf = 0;
    const hist = [];
    
    const ptsX = new Float32Array(NODES);
    const ys = new Float32Array(NODES);
    const vys = new Float32Array(NODES);
    
    function clamp(v, a, b) { return v < a ? a : v > b ? b : v; }
    
    function baseSeamY(progress) {
    return vh * (REST_Y - (REST_Y - OPEN_Y) * progress);
    }
    
    function initNodes() {
    vw = stage.clientWidth || window.innerWidth || 1440;
    vh = stage.clientHeight || window.innerHeight || 900;
    svg.setAttribute('viewBox', '0 0 ' + vw + ' ' + vh);
    heroLayer.style.clipPath = 'url(#smr-hero-clip)';
    heroLayer.style.webkitClipPath = 'url(#smr-hero-clip)';
    const by = baseSeamY(openPos);
    for (let i = 0; i < NODES; i++) {
      const u = i / (NODES - 1);
      ptsX[i] = u * vw;
      const arch = Math.sin(u * Math.PI) * -18 * (1 - openPos * 0.5);
      ys[i] = by + arch;
      vys[i] = 0;
    }
    }
    
    function wake() {
    if (!raf) raf = requestAnimationFrame(frame);
    }
    
    function buildSpline(xs, py) {
    let d = 'M ' + xs[0].toFixed(1) + ' ' + py[0].toFixed(1);
    for (let i = 0; i < NODES - 1; i++) {
      const x0 = i > 0 ? xs[i - 1] : xs[0];
      const y0 = i > 0 ? py[i - 1] : py[0];
      const x1 = xs[i];
      const y1 = py[i];
      const x2 = xs[i + 1];
      const y2 = py[i + 1];
      const x3 = i < NODES - 2 ? xs[i + 2] : x2;
      const y3 = i < NODES - 2 ? py[i + 2] : y2;
    
      const cp1x = x1 + (x2 - x0) / 6;
      const cp1y = y1 + (y2 - y0) / 6;
      const cp2x = x2 - (x3 - x1) / 6;
      const cp2y = y2 - (y3 - y1) / 6;
      d += ' C ' + cp1x.toFixed(1) + ' ' + cp1y.toFixed(1) + ', ' + cp2x.toFixed(1) + ' ' + cp2y.toFixed(1) + ', ' + x2.toFixed(1) + ' ' + y2.toFixed(1);
    }
    return d;
    }
    
    function syncScrollToOpen(p) {
    if (reduce) return;
    const maxScroll = Math.max(1, root.offsetHeight - vh);
    const targetScroll = p * maxScroll;
    if (Math.abs(window.scrollY - targetScroll) > 2) {
      window.scrollTo(0, targetScroll);
    }
    }
    
    function frame() {
    raf = 0;
    
    if (reduce) {
      openPos = openTarget;
      openVel = 0;
    } else {
      openVel += (openTarget - openPos) * 0.14;
      openVel *= 0.74;
      openPos += openVel;
      if (Math.abs(openTarget - openPos) < 0.0004 && Math.abs(openVel) < 0.0004) {
        openPos = openTarget;
        openVel = 0;
      }
    }
    
    const by = baseSeamY(openPos);
    let energy = Math.abs(openVel) * 100 + Math.abs(openTarget - openPos) * 100;
    
    if (pointer) {
      lightTargetX = clamp(pointer.x / vw, 0.08, 0.92);
    } else {
      lightTargetX = 0.5;
    }
    lightX += (lightTargetX - lightX) * (reduce ? 1 : 0.16);
    
    for (let i = 0; i < NODES; i++) {
      const u = i / (NODES - 1);
      const nx = u * vw;
      ptsX[i] = nx;
    
      /* Natural horizon arch + scroll velocity bow */
      const arch = Math.sin(u * Math.PI) * -18 * (1 - openPos * 0.5);
      const scrollBow = Math.sin(u * Math.PI) * clamp(openVel * -950, -52, 52);
      let targetY = by + arch + scrollBow;
    
      /* Local elastic pull toward pointer anywhere along the seam */
      if (pointer && !reduce) {
        const dx = nx - pointer.x;
        const dy = (by + arch) - pointer.y;
        const dist = Math.hypot(dx * 0.68, dy);
        if (dist < PULL_RADIUS) {
          const falloff = 1 - dist / PULL_RADIUS;
          const w = falloff * falloff;
          const pull = clamp(pointer.y - (by + arch), -PULL_MAX, PULL_MAX) * w;
          targetY += pull;
        }
      }
    
      if (reduce) {
        ys[i] = targetY;
        vys[i] = 0;
      } else {
        const force = (targetY - ys[i]) * SPRING;
        vys[i] = (vys[i] + force) * DAMPING;
        ys[i] += vys[i];
      }
    
      energy += Math.abs(vys[i]) + Math.abs(targetY - ys[i]);
    }
    
    /* Neighbor coupling pass so the seam behaves like a continuous tensioned membrane */
    if (!reduce) {
      for (let i = 1; i < NODES - 1; i++) {
        const avg = 0.5 * (ys[i - 1] + ys[i + 1]);
        vys[i] += (avg - ys[i]) * 0.09;
      }
    }
    
    const seamD = buildSpline(ptsX, ys);
    const curtainD = seamD + ' L ' + vw.toFixed(1) + ' 0 L 0 0 Z';
    
    clipPath.setAttribute('d', curtainD);
    shadowFar.setAttribute('d', seamD);
    shadowMid.setAttribute('d', seamD);
    shadowLip.setAttribute('d', seamD);
    glowWide.setAttribute('d', seamD);
    glowMid.setAttribute('d', seamD);
    rimPath.setAttribute('d', seamD);
    
    const lxPct = (lightX * 100).toFixed(1);
    const leftStop = Math.max(4, lightX * 100 - 18).toFixed(1);
    const rightStop = Math.min(96, lightX * 100 + 18).toFixed(1);
    stopA.setAttribute('offset', leftStop + '%');
    stopB.setAttribute('offset', lxPct + '%');
    stopC.setAttribute('offset', rightStop + '%');
    heroLayer.style.setProperty('--lx', lxPct + '%');
    underLayer.style.setProperty('--lx', lxPct + '%');
    
    /* Keep the invisible drag strip and subtle cue aligned with the seam center */
    const mid = Math.floor(NODES / 2);
    const midY = ys[mid];
    hitBtn.style.transform = 'translate3d(0, ' + (midY - 36).toFixed(1) + 'px, 0)';
    
    const cueAlpha = clamp(1 - openPos * 2.8, 0, 1);
    cueEl.style.transform = 'translate3d(-50%, ' + (midY + 22).toFixed(1) + 'px, 0)';
    cueEl.style.opacity = cueAlpha.toFixed(3);
    
    /* Physical peel parallax: upper sheet lifts away while recessed lower layer rises into focus */
    const heroLift = -openPos * 68;
    const heroAlpha = clamp(1 - openPos * 1.38, 0, 1);
    heroContent.style.transform = 'translate3d(0, ' + heroLift.toFixed(1) + 'px, 0)';
    heroContent.style.opacity = heroAlpha.toFixed(3);
    
    const underShift = (1 - openPos) * 42;
    const underScale = 0.965 + openPos * 0.035;
    const underAlpha = clamp((openPos - 0.06) / 0.55, 0, 1);
    underInner.style.transform = 'translate3d(0, ' + underShift.toFixed(1) + 'px, 0) scale(' + underScale.toFixed(4) + ')';
    underInner.style.opacity = underAlpha.toFixed(3);
    
    const isOpen = openPos > 0.55;
    root.classList.toggle('smr-open', isOpen);
    hitBtn.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
    
    if (energy > 0.08 || Math.abs(lightTargetX - lightX) > 0.003) {
      raf = requestAnimationFrame(frame);
    }
    }
    
    /* Native scroll drives openTarget unless the user is actively dragging the seam */
    window.addEventListener('scroll', () => {
    if (dragPid || reduce) return;
    const maxScroll = Math.max(1, root.offsetHeight - vh);
    openTarget = clamp(window.scrollY / maxScroll, 0, 1);
    wake();
    }, { passive: true });
    
    window.addEventListener('pointermove', (e) => {
    const rect = stage.getBoundingClientRect();
    pointer = { x: e.clientX - rect.left, y: e.clientY - rect.top };
    if (dragPid && e.pointerId === dragPid) {
      const dy = dragStartY - e.clientY;
      if (Math.abs(dy) > 4) dragMoved = true;
      const span = vh * (REST_Y - OPEN_Y);
      openTarget = clamp(dragStartOpen + dy / span, 0, 1);
      hist.push({ y: e.clientY, t: performance.now() });
      if (hist.length > 5) hist.shift();
    }
    wake();
    });
    
    document.documentElement.addEventListener('pointerleave', () => {
    pointer = null;
    wake();
    });
    
    hitBtn.addEventListener('pointerdown', (e) => {
    if (e.button > 0 || dragPid) return;
    const rect = stage.getBoundingClientRect();
    pointer = { x: e.clientX - rect.left, y: e.clientY - rect.top };
    dragPid = e.pointerId;
    dragStartY = e.clientY;
    dragStartOpen = openPos;
    dragMoved = false;
    hist.length = 0;
    hist.push({ y: e.clientY, t: performance.now() });
    root.classList.add('smr-dragging');
    hitBtn.setPointerCapture(e.pointerId);
    wake();
    });
    
    function endDrag(e) {
    if (e.pointerId !== dragPid) return;
    dragPid = 0;
    root.classList.remove('smr-dragging');
    
    if (!dragMoved) {
      openTarget = openPos > 0.5 ? 0 : 1;
      syncScrollToOpen(openTarget);
      wake();
      return;
    }
    
    /* Project release momentum using Apple's fluid projection formula */
    let vyPxPerMs = 0;
    if (hist.length >= 2) {
      const a = hist[0];
      const b = hist[hist.length - 1];
      const dt = Math.max(16, b.t - a.t);
      vyPxPerMs = (a.y - b.y) / dt;
    }
    const span = vh * (REST_Y - OPEN_Y);
    const projected = openTarget + (vyPxPerMs * 180) / span;
    openTarget = projected > 0.45 ? 1 : 0;
    openVel += (vyPxPerMs * 16.67) / span;
    syncScrollToOpen(openTarget);
    wake();
    }
    
    window.addEventListener('pointerup', endDrag);
    window.addEventListener('pointercancel', endDrag);
    
    hitBtn.addEventListener('keydown', (e) => {
    if (e.key === 'Enter' || e.key === ' ') {
      e.preventDefault();
      openTarget = openTarget > 0.5 ? 0 : 1;
      syncScrollToOpen(openTarget);
      wake();
    } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
      e.preventDefault();
      openTarget = e.key === 'ArrowUp' ? 1 : 0;
      syncScrollToOpen(openTarget);
      wake();
    }
    });
    
    resetBtn.addEventListener('click', () => {
    openTarget = 0;
    syncScrollToOpen(0);
    wake();
    });
    
    window.addEventListener('resize', () => {
    initNodes();
    wake();
    });
    
    initNodes();
    wake();

Подключение к серверу

Чистый фронтенд без привязки к серверу.

Полезно знать

Tilda, Webflow, WordPress

Нажмите «Скопировать весь код» вверху и вставьте его в один HTML-блок.

Tilda

Добавить блок, Другое, T123 HTML-код. Вставьте и сохраните. Проверяйте на опубликованной странице, в редакторе скрипты не запускаются.

Webflow

Панель Add, Embed. Вставьте и нажмите Save & Close. Свой код работает на опубликованном сайте.

WordPress

Добавить блок, Произвольный HTML. Вставьте и нажмите «Обновить».

Ещё в разделе «Первый экран»

Все
Скопировано