中文
PRO DISPLAY
Scroll · Vanilla JS + CSS

Scroll portal zoom

滚动视角穿越

Zoom a foreground frame seamlessly past the camera on scroll to reveal the scene behind.

Also searched as: 滚屏视角穿透, 放大钻进下一幕, 滚动穿门转场, Apple Portal Zoom

AI Markdown (.md)
Placement
Hero heading, Image
Mood
Dramatic, Refined
Trigger
Scroll
Site types
品牌官网, 作品集, 活动和宣传页

How it works & accessibility

Reads scroll progress inside a sticky runway and maps scale linearly up to maxScale while fading out after fadeAt%, keeping native scrolling responsive and restoring a clear static frame under reduced motion.

Best for: Hero heading, Image (Scroll).

Reduced motion: 关闭缩放穿越计算,清晰静态展示前景标题与内景画面

Mobile & touch: 用原生滚动推进进度,避免劫持触摸滑动;缩小放大倍率和字体占宽保证安全留白

Key parameters

ParameterKeyDefaultRangeNotes
最大放大maxScale2.8倍——
淡出起点fadeAt60%——

Ready-to-paste AI prompt

Add “Scroll portal zoom” to the hero heading in my project: Reads scroll progress inside a sticky runway and maps scale linearly up to maxScale while fading out after fadeAt%, keeping native scrolling responsive and restoring a clear static frame under reduced motion.
Parameters: maxScale: 2.8×, fadeAt: 60%.
Preserve existing content and layout. Respect prefers-reduced-motion by showing the final state. Content must remain visible if JavaScript fails or is disabled.
Reference: https://donglang.linter.top/effects/portal-zoom.md (canonical specification and reference code).

Dependency-free reference code

CSS
.pz-runway {
  position: relative;
  height: 220%;
}

.pz-sticky {
  position: sticky;
  top: 0;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.pz-portal {
  transform-origin: 50% 50%;
  will-change: scale, opacity;
}
JavaScript
// 滚动视角穿越(Scroll portal zoom)· 原生 JS,不依赖任何库。
// 用法:const ctl = portalZoom(scroller, { maxScale: 2.8, fadeAt: 60 });
// 滚动容器内部有 .pz-portal(前景框)与底层画面,返回 { update(), destroy() }。
export function portalZoom(scroller, {
  maxScale = 2.8,
  fadeAt = 60,
  ignoreReducedMotion = false,
} = {}) {
  if (!scroller) return null;
  const portal = scroller.querySelector('[data-portal]') || scroller.querySelector('.pz-portal');
  if (!portal) return null;
  const reduce = !ignoreReducedMotion && matchMedia('(prefers-reduced-motion: reduce)').matches;
  const threshold = Math.max(0.05, Math.min(0.95, fadeAt / 100));

  let raf = 0;
  const update = () => {
    raf = 0;
    if (reduce) {
      portal.style.scale = '1';
      portal.style.opacity = '1';
      return;
    }
    const max = Math.max(1, scroller.scrollHeight - scroller.clientHeight);
    const progress = Math.max(0, Math.min(1, scroller.scrollTop / max));
    const s = 1 + (maxScale - 1) * progress;
    const op = progress <= threshold ? 1 : Math.max(0, 1 - (progress - threshold) / (1 - threshold));
    portal.style.scale = s.toFixed(4);
    portal.style.opacity = op.toFixed(4);
  };

  const onScroll = () => {
    if (!raf) raf = requestAnimationFrame(update);
  };

  scroller.addEventListener('scroll', onScroll, { passive: true });
  update();

  return {
    update,
    destroy() {
      scroller.removeEventListener('scroll', onScroll);
      if (raf) cancelAnimationFrame(raf);
      portal.style.removeProperty('scale');
      portal.style.removeProperty('opacity');
    },
  };
}
HTML
<div class="pz-view">
  <div class="pz-runway">
    <div class="pz-sticky">
      <div class="pz-portal" data-portal>
        <b>2026 PRO</b>
      </div>
    </div>
  </div>
</div>

Shown once per release · Always available in changelog