Skip to content
motionprompts motionprompts

Infinite Horizontal Scroll

JavaScript animation component · Published 2026-07-27 · by vanguardia.dev

Open live demo ↗ Download source

What it does

A seamless looping horizontal scroll gallery driven by raw wheel and touch input. Vertical wheel/touch deltas are mapped to horizontal movement with a lerp-smoothed translateX, cloned section buffers on both sides create an endless loop, and a synced progress bar and percentage counter track position.

How it's built

Categoryscroll
Techvanilla JS
Complexitypage
Performance costlight
Mobile-safeyes

infinite-scroll horizontal-scroll marquee loop lerp vanilla-js requestanimationframe editorial bold

How it works

The page turns sideways and never ends. Each turn of the mouse wheel moves a row of full-height editorial panels horizontally, black title cards, a red studio block, an amber list, photographs between them, and when you reach the last panel the first one is already there again. Scroll backwards from the start and you land on the end with no jump. A thin bar across the top fills as you travel through one loop and a large counter in the corner reads the position from zero to a hundred, then wraps.

It needs no library at all. There is no GSAP and no Lenis: the whole effect is native wheel and touch events, a linear interpolation and one animation loop.

Turning vertical scroll into an endless strip

The document itself never scrolls. A fixed, viewport-sized container catches the wheel and turns its vertical movement into a horizontal target position. The strip of panels is then moved with a transform that eases towards that target a little on every frame, so the motion glides instead of stepping with each wheel event. On touch screens a horizontal drag moves the target directly, and the speed of the swipe at release becomes momentum that keeps the strip travelling and slows down on its own.

The loop is an illusion built from copies. When the page loads, the script measures the real width of the whole sequence of panels and appends several cloned copies of it, so the strip holds the sequence repeated on both sides of the original. It then starts in the middle copy. Whenever the position drifts more than half a sequence away from the middle, both the target and the current position are shifted back by exactly one sequence width in the same frame. Because the content at the new position is identical, the eye sees nothing.

Where it gets hard

The seam is the delicate part. The jump has to move the target and the rendered position together, or the easing would visibly travel the whole sequence in reverse. The progress bar has the same problem: at the moment the counter wraps from a hundred back to zero, an eased bar would sweep backwards across the screen, so the wrap is detected and the bar is snapped instead of animated for that one frame. Widths are measured from the rendered layout rather than assumed, so mixed panel widths in viewport units still loop exactly.

Performance, mobile and accessibility

Only one transform changes per frame, so it is cheap on any device, and it uses small viewport height units so mobile browser toolbars do not break the layout. The cost is in what it takes over. Hijacking the wheel removes native scrolling, keyboard scrolling and the scrollbar, and the cloned panels repeat their text for screen readers. If you use it on a real site, keep it to a contained experience, hide the clones from assistive technology and give keyboard users a way to move through the panels.

Rebuild it with AI

This component's prompt is part of the paid library. Below you can read how it starts; the full prompt, the exact structure, timing and easing an AI agent needs to rebuild the effect, unlocks with any paid plan, yearly or lifetime.

# Infinite Horizontal Scroll
## Goal
Build a full-page, seamlessly looping horizontal scroll experience: a row of 8 editorial panels that scrolls sideways forever in either direction. Vertical mouse-wheel deltas (and horizontal touch drags) are converted into smooth, lerp-eased horizontal movement of a giant flex strip. Cloned copies of the panel sequence on both sides make the loop invisible, and a fixed progress bar plus a percentage counter track the position within one loop (0–100).
## Tech
Vanilla HTML/CSS/JS with an ES module script (`<script type="module" src="./script.js">`). **No GSAP and no external libraries are needed** — the entire effect is a hand-rolled `lerp` + `requestAnimationFrame` loop with native `wheel` / `touch` event listeners. Do not import gsap or lenis.
## Layout / HTML
Everything lives inside a fixed, viewport-sized container that hides overflow:
```
.container                     (fixed wrapper)
├── .progress-bar              (empty div, fixed top bar)
├── .progress-counter          (fixed bottom-right) > h1 with initial text "0"
└── .scroller                  (the horizontal flex strip)
…

Premium prompt

Unlock this prompt, and every other one

From $99/year, or $139 once for lifetime access. Commercial license included.

See pricing Or start with the free set Already bought? Sign in

New components in your inbox

One email a week, only when new components ship, each with its live demo and prompt.