Specification
- Catalogue
- No. 55 of 110
- Section
- Navigation
- Interaction
- Scroll
- Element
- Navigation
- Preview
- Live component
- Imports
- No packages
- Added
Notes
A sideways row fades at its right edge, and the fade goes once you reach the end.
Says there is more without an arrow, and stops saying it when there is not. Pure CSS.
48px fade until the last tenth of the scroll. animation-timeline: scroll(self inline) with @property.
Code
React and plain CSS"use client";
import type { LivePreviewProps } from "@/components/live/types";
import { PieceStage } from "@/components/pieces/stage/PieceStage";
import type { Tour } from "@/components/pieces/stage/tour";
import "@/components/pieces/kit/scroll-fade.css";
import "./edge-fade.css";
function EdgeFadeDemo() {
return (
<div className="dm">
<div className="dm-strip scroll-fade" tabIndex={0} aria-label="Service tags, scroll sideways">
{["Boiler repair", "Bathrooms", "Kitchens", "Emergency call-out", "Radiators", "Underfloor heating", "Annual service"].map((t) => (
<span key={t} className="dm-chip">
{t}
</span>
))}
</div>
<div className="dm-code scroll-fade" tabIndex={0} aria-label="Code sample, scroll sideways">
npm install @your-brand/widget --save && npx your-brand init --project my-site
</div>
<p className="dm-hint">Scroll each row sideways to the end</p>
</div>
);
}
// What a hovered card shows: the piece used the way a visitor would.
const TOUR: Tour = [
{ scroll: ".dm-strip", to: 1, ms: 1600, axis: "x", wait: 500 },
{ scroll: ".dm-code", to: 1, ms: 1600, axis: "x", wait: 800 },
{ scroll: ".dm-strip", to: 0, ms: 700, axis: "x", wait: 0 },
{ scroll: ".dm-code", to: 0, ms: 700, axis: "x", wait: 300 },
];
export default function EdgeFadeEntry(props: LivePreviewProps) {
return (
<PieceStage {...props} label="Strip that hints at more" tour={TOUR}>
<EdgeFadeDemo />
</PieceStage>
);
}