全部效果滚动与入场

滚动等距组装

Scroll Isometric Assembly

分散的等距图层随滚动逐步收拢,靠近尾端时对齐成叠层。

在演示区域内滚动

适用场景

适合紧凑展示产品结构或服务分层。 不同层可以用不同颜色或标签区分,散开时也保留原本的层次顺序。组装完的画面应能说明各层如何连接。

应用示例

屋顶保温指南里,滚动让分开的基层、保温板和防水层滑到一起。合拢后能看清哪一层直接挨着屋面覆盖层。

AI 提示词

给【目标位置】添加滚动等距组装。给各层共用等距变换,分别插值各自的展开坐标。减少动态效果时显示已组装的构图。保留键盘操作,并提供减少动态效果时的状态。

示例代码

保存为 HTML 文件后,用浏览器打开即可运行。代码与页面里的演示一致。

查看 HTML
<!doctype html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>滚动等距组装</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .scroll-port {
      --frame: clamp(112px, 75vh, 242px);
      --p: 0;
      width: min(100%, 290px); height: var(--frame);
      overflow-y:auto; overflow-x:hidden; scroll-behavior:auto;
      overscroll-behavior:contain; scrollbar-width:thin;
      scrollbar-color:#a79bd5 #20223d; border-radius:12px;
      border:1px solid #a79bd567; background:#20233c; color:#f5f2ff;
    }
    .scroll-port:focus-visible { outline-offset: 3px; }
    .scroll-track { position:relative; min-height:calc(var(--frame) + 235px); }
    .scroll-pin { position:sticky; top:0; height:var(--frame); overflow:hidden; }
    .scroll-pin .tag { position:absolute; z-index:4; left:8px; bottom:9px; font-size:10px; color:#ecfcff; padding:4px 6px; background:#17152ce8; border-radius:4px; }
    .scroll-panel { min-height:62px; padding:9px; border:1px solid #adb2e345; border-radius:8px; background:linear-gradient(120deg,#314861,#3e346a); }


    .iso-stack { position:absolute; inset:0; display:grid; place-items:center; perspective:330px; transform-style:preserve-3d; }
    .iso-stack i { position:absolute; width:71px; height:62px; border:1.7px solid var(--tone); border-radius:7px; background:color-mix(in srgb,var(--tone) 35%,transparent); box-shadow:0 5px 0 #1d294a70;
      transform:translateY(calc(var(--offset) * (-21px + var(--p) * 15px))) translateX(calc(var(--offset) * (15px - var(--p) * 15px))) rotateX(58deg) rotateZ(-30deg); }
    .iso-stack i:nth-child(1) { --offset:-1.5; --tone:#67b9c8; }
    .iso-stack i:nth-child(2) { --offset:-.5; --tone:#9bd2d2; }
    .iso-stack i:nth-child(3) { --offset:.5; --tone:#d290e8; }
    .iso-stack i:nth-child(4) { --offset:1.5; --tone:#ffd6bf; }
    @media (prefers-reduced-motion:reduce) { .iso-stack { --p:1; } }

    @media (prefers-reduced-motion: reduce) {
      .lab, .lab *, .lab::before, .lab::after, .lab *::before, .lab *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
      }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="lab scroll-port" role="region" tabindex="0" aria-label="滚动组装等距图层"><div class="scroll-track"><div class="scroll-pin"><div class="iso-stack" aria-hidden="true"><i></i><i></i><i></i><i></i></div><span class="tag" aria-hidden="true">图层组装</span></div></div></div>
  </main>
  <script>
    const port = document.querySelector('.scroll-port');
    const reduced = matchMedia('(prefers-reduced-motion: reduce)');
    const listeners = [];
    let scheduled = 0;
    function sample() {
      const max = Math.max(1,port.scrollHeight - port.clientHeight);
      return Math.max(0,Math.min(1,port.scrollTop / max));
    }
    function update() {
      scheduled = 0;
      const progress = sample();
      port.style.setProperty('--p', progress.toFixed(4));
      for (const callback of listeners) callback(progress);
    }
    function schedule() { if (!scheduled) scheduled = requestAnimationFrame(update); }
    function onScroll(callback) { listeners.push(callback); callback(sample()); }
    port.addEventListener('scroll', schedule, {passive:true});
    new ResizeObserver(schedule).observe(port);
    reduced.addEventListener('change', schedule);
    update();
  </script>
</body>
</html>

UI Skills 原创示例

相关参考