Searching Open Sourcery

Type to search Open Sourcery.

Motion & Scroll

Scroll Stack

A natively scrolling list whose items animate at the scrollport edges instead of clipping — the exiting one stops dead at the boundary and fades while the next slides over it.

v0.1.0@magic-spells/scroll-stack

$ npm i @magic-spells/scroll-stack

GitHubnpm

Live demo

Intro

Scroll natively

It is a real overflow container — wheel, touch, keyboard and scrollbars all work as usual.

Edges

Nothing clips

The card leaving the top stops at the edge and fades out instead of being cut off.

Overlap

The next slides over

The one behind it moves up and covers it as you keep scrolling.

Snap

Rest on a card

With snap on, a scroll settles with a whole card at the top.

Motion

Reduced motion

With prefers-reduced-motion set, the edge animations switch off.

Markup

Just items

Each child is a scroll-stack-item. There is no configuration beyond attributes.

Scroll the list: the leaving card stops at the edge and fades while the next slides over it.

About

A natively scrolling list web component whose items animate at the scrollport edges instead of clipping. The exiting item stops dead at the boundary, fades and shrinks in place, and the next item slides over it; entering items animate in from the far edge. Vertical or horizontal, with mandatory scroll snapping and responsive per-view item sizing, and every effect is plain CSS driven by one custom property. 3.5 kB JS gzip, 0.9 kB CSS gzip, zero dependencies, no Shadow DOM.

Usage

<scroll-stack style="height: 26rem">
	<scroll-stack-item>
		<article class="card">First</article>
	</scroll-stack-item>
	<scroll-stack-item>
		<article class="card">Second</article>
	</scroll-stack-item>
</scroll-stack>

Attributes

AttributeValuesDefaultNotes
directionvertical | horizontalverticalSets the scroll axis
effectstack-fade | fade-scale | fade | scale | nonestack-fadeSelects a block of CSS; none publishes the vars and nothing else
pinstart | end | both | nonesee belowWhich edges hold an item still while its flow position moves on
zoneitem | px | %itemDepth of the animation band; capped at 45% of the scrollport
edgesboth | start | endbothWhich edges animate at all
snapboolean | start | center | proximityoffScroll snapping; presence alone means mandatory start
per-viewpositive integer | autounsetHow many items fill the scrollport
item-minCSS length (px, rem, %)unsetFloor for the resolved item length
item-maxCSS length (px, rem, %)unsetCeiling for the resolved item length
easinglinear | ease-in | ease-out | ease-in-outlinearApplied to progress before it is written
reduced-motionauto | ignoreautoignore opts out of the reduced-motion override
disabledbooleanoffRemoves every var and state attribute, detaches all listeners

About, features, usage and options are taken from the package README.