Gallery & Media
Carousel, lightbox, zoom, before/after comparison and marquee.
Updated
Do you need a JavaScript library for a carousel or an image gallery?
Usually not. Modern CSS covers most galleries: scroll-snap for swipeable sliders, CSS Grid for masonry-style layouts, keyframed marquees for logo strips and simple lightboxes. A few lines of vanilla JavaScript add autoplay, thumbnails, zoom or before/after comparison without shipping a dependency.
How to choose, performance and accessibility
- Choose CSS-Only Carousel or Basic Slider for product or portfolio images, a lightbox when people need the full-size photo, and Velocity Marquee for logo or testimonial bands.
- Lazy-load images and give them explicit width and height, keep arrows and dots reachable by keyboard, and stop autoplay as soon as the user interacts or asks for reduced motion.
- Basic Slider, Basic Lightbox, Hover Zoom, Basic Marquee, CSS-Only Carousel and Velocity Marquee are free with their code; the rest come with Premium.
View source code
<div class="fx-0161-root">
<div class="bsld-carousel" role="region" aria-roledescription="carousel" aria-label="Slideshow" data-slide="slide" data-of="of">
<div class="bsld-track">
<div class="bsld-slide"><span class="bsld-caption">Slide 1</span></div>
<div class="bsld-slide"><span class="bsld-caption">Slide 2</span></div>
<div class="bsld-slide"><span class="bsld-caption">Slide 3</span></div>
<div class="bsld-slide"><span class="bsld-caption">Slide 4</span></div>
<div class="bsld-slide"><span class="bsld-caption">Slide 5</span></div>
</div>
<button type="button" class="bsld-arrow bsld-prev" aria-label="Previous slide">
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M15 18l-6-6 6-6"/></svg>
</button>
<button type="button" class="bsld-arrow bsld-next" aria-label="Next slide">
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 18l6-6-6-6"/></svg>
</button>
</div>
</div>.fx-0161-root,
.fx-0161-root *,
.fx-0161-root *::before,
.fx-0161-root *::after {
box-sizing: border-box;
}
/* Demo frame: background, padding and minimum height are adjustable */
.fx-0161-root {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: var(--bsld-stage-min-height, 250px);
padding: var(--bsld-stage-padding, 25px 16px);
background: var(--bsld-stage-bg, #1a1a24);
color: #fff;
font-family: sans-serif;
}
/* The carousel takes its container's width, up to --bsld-width; height = width × ratio */
.bsld-carousel {
position: relative;
width: 100%;
max-width: var(--bsld-width, 640px);
height: var(--bsld-height, auto);
aspect-ratio: var(--bsld-ratio, 16 / 10);
overflow: hidden;
overflow: clip; /* the frame cannot scroll by itself (focus, scrollIntoView) */
border-radius: var(--bsld-radius, 1rem);
background: #12121a;
}
.bsld-track {
display: flex;
height: 100%;
transition: transform var(--bsld-duration, 0.5s) ease-out;
touch-action: pan-y; /* a vertical finger move scrolls the page, a horizontal one moves the carousel */
user-select: none;
-webkit-user-select: none;
}
.bsld-slide {
position: relative;
flex: 0 0 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
/* Your photos: an <img> inside the slide, cropped to fill it */
.bsld-slide > img {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
-webkit-user-drag: none;
}
.bsld-caption {
position: relative;
font-weight: 600;
font-size: 1.2rem;
color: #fff;
text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}
/* Demo backgrounds (covered by your images) */
.bsld-slide:nth-child(1) { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.bsld-slide:nth-child(2) { background: linear-gradient(135deg, #8b5cf6, #d946ef); }
.bsld-slide:nth-child(3) { background: linear-gradient(135deg, #d946ef, #f43f5e); }
.bsld-slide:nth-child(4) { background: linear-gradient(135deg, #f43f5e, #f97316); }
.bsld-slide:nth-child(5) { background: linear-gradient(135deg, #f97316, #eab308); }
.bsld-arrow {
position: absolute;
top: 50%;
z-index: 10;
width: 36px;
height: 36px;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
transform: translateY(-50%);
background: var(--bsld-arrow-bg, rgba(255, 255, 255, 0.2));
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
cursor: pointer;
transition: background 0.3s ease, transform 0.3s ease;
}
.bsld-arrow:hover {
background: rgba(255, 255, 255, 0.4);
transform: translateY(-50%) scale(1.1);
}
.bsld-arrow:focus-visible {
outline: 2px solid #fff;
outline-offset: 2px;
}
.bsld-arrow svg {
width: 18px;
height: 18px;
stroke: #fff;
stroke-width: 2;
fill: none;
}
.bsld-prev { left: 10px; }
.bsld-next { right: 10px; }
/* Text read by screen readers only */
.bsld-status {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rect(0 0 0 0);
white-space: nowrap;
border: 0;
}
/* Reduced motion: the slide still changes, without the sliding */
@media (prefers-reduced-motion: reduce) {
.bsld-track,
.bsld-arrow {
transition: none;
}
}(function () {
// Basic Slider: the track slides from one slide to the next (arrows, ← → keys, finger or mouse drag).
// Each .bsld-carousel on the page gets its own instance; nothing is declared on window.
function init(car) {
if (car.hasAttribute('data-bsld-ready')) return; // script pasted twice: nothing is wired twice
var track = car.querySelector('.bsld-track');
var slides = track ? track.querySelectorAll('.bsld-slide') : [];
if (!slides.length) return;
car.setAttribute('data-bsld-ready', '');
var prev = car.querySelector('.bsld-prev');
var next = car.querySelector('.bsld-next');
var word = car.getAttribute('data-slide') || 'slide';
var of = car.getAttribute('data-of') || 'of';
var n = slides.length;
var index = 0;
// announces "slide 2 of 5" to screen readers after each change
var status = document.createElement('p');
status.className = 'bsld-status';
status.setAttribute('aria-live', 'polite');
car.appendChild(status);
for (var i = 0; i < n; i++) {
slides[i].setAttribute('role', 'group');
slides[i].setAttribute('aria-roledescription', word);
slides[i].setAttribute('aria-label', (i + 1) + ' ' + of + ' ' + n);
}
function go(k, announce) {
index = ((k % n) + n) % n; // loops: after the last slide comes the first
track.style.transform = 'translateX(' + (-100 * index) + '%)';
for (var i = 0; i < n; i++) {
// hidden slides: out of the Tab order and of screen readers
if (i === index) {
slides[i].removeAttribute('inert');
slides[i].removeAttribute('aria-hidden');
} else {
slides[i].setAttribute('inert', '');
slides[i].setAttribute('aria-hidden', 'true');
}
}
if (announce) status.textContent = (car.getAttribute('data-slide') || word) + ' ' + (index + 1) + ' ' + (car.getAttribute('data-of') || of) + ' ' + n;
}
if (prev) prev.addEventListener('click', function () { go(index - 1, true); });
if (next) next.addEventListener('click', function () { go(index + 1, true); });
car.addEventListener('keydown', function (e) {
if (/^(INPUT|TEXTAREA|SELECT)$/.test(e.target.tagName) || e.target.isContentEditable) return;
if (e.key === 'ArrowLeft') { e.preventDefault(); go(index - 1, true); }
if (e.key === 'ArrowRight') { e.preventDefault(); go(index + 1, true); }
});
// Drag (Pointer Events: finger, mouse, pen): more than 50 px horizontally changes the slide
var x0 = null, y0 = 0, dragged = false;
track.addEventListener('pointerdown', function (e) {
if (e.pointerType === 'mouse' && e.button !== 0) return;
x0 = e.clientX; y0 = e.clientY; dragged = false;
});
track.addEventListener('pointerup', function (e) {
if (x0 === null) return;
var dx = e.clientX - x0, dy = e.clientY - y0;
x0 = null;
if (Math.abs(dx) > 50 && Math.abs(dx) > Math.abs(dy)) {
dragged = true;
go(index + (dx < 0 ? 1 : -1), true);
}
});
track.addEventListener('pointercancel', function () { x0 = null; });
// a mouse drag must not open a link placed on the slide
track.addEventListener('click', function (e) {
if (dragged) { e.preventDefault(); e.stopPropagation(); dragged = false; }
}, true);
track.addEventListener('dragstart', function (e) { e.preventDefault(); });
go(0, false);
}
Array.prototype.forEach.call(document.querySelectorAll('.bsld-carousel'), init);
})();Vertical Slider
Slides move up and down: top and bottom arrows, ↑ ↓ keys or a vertical swipe.
Effect page →View source code
<div class="fx-0171-root">
<div class="blb-grid">
<button type="button" class="blb-thumb" aria-haspopup="dialog"><img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='400' viewBox='0 0 600 400'%3E%3ClinearGradient id='g' x2='1' y2='1'%3E%3Cstop stop-color='%236366f1'/%3E%3Cstop offset='1' stop-color='%238b5cf6'/%3E%3C/linearGradient%3E%3Crect width='600' height='400' fill='url(%23g)'/%3E%3C/svg%3E" alt="Indigo to violet gradient" width="600" height="400"></button>
<button type="button" class="blb-thumb" aria-haspopup="dialog"><img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='400' viewBox='0 0 600 400'%3E%3ClinearGradient id='g' x2='1' y2='1'%3E%3Cstop stop-color='%23d946ef'/%3E%3Cstop offset='1' stop-color='%23f43f5e'/%3E%3C/linearGradient%3E%3Crect width='600' height='400' fill='url(%23g)'/%3E%3C/svg%3E" alt="Fuchsia to rose gradient" width="600" height="400"></button>
<button type="button" class="blb-thumb" aria-haspopup="dialog"><img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='400' viewBox='0 0 600 400'%3E%3ClinearGradient id='g' x2='1' y2='1'%3E%3Cstop stop-color='%2306b6d4'/%3E%3Cstop offset='1' stop-color='%2310b981'/%3E%3C/linearGradient%3E%3Crect width='600' height='400' fill='url(%23g)'/%3E%3C/svg%3E" alt="Cyan to emerald gradient" width="600" height="400"></button>
<button type="button" class="blb-thumb" aria-haspopup="dialog"><img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='400' viewBox='0 0 600 400'%3E%3ClinearGradient id='g' x2='1' y2='1'%3E%3Cstop stop-color='%23f59e0b'/%3E%3Cstop offset='1' stop-color='%23ef4444'/%3E%3C/linearGradient%3E%3Crect width='600' height='400' fill='url(%23g)'/%3E%3C/svg%3E" alt="Amber to red gradient" width="600" height="400"></button>
</div>
<dialog class="blb-viewer" aria-label="Image viewer">
<div class="blb-content">
<button type="button" class="blb-close" aria-label="Close"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M18 6L6 18M6 6l12 12"/></svg></button>
<img class="blb-image" alt="">
</div>
</dialog>
</div>/* fx-0171 — scoped to .fx-0171-root and the blb- prefix: two copies on one page stay independent */
.fx-0171-root,
.fx-0171-root *,
.fx-0171-root *::before,
.fx-0171-root *::after {
box-sizing: border-box;
}
.fx-0171-root {
--blb-thumb: 120px; /* thumbnail width */
--blb-gap: 10px; /* space between thumbnails */
--blb-radius: 0.5rem; /* thumbnail corners */
--blb-radius-lg: 1rem; /* large image corners */
--blb-backdrop: rgba(0, 0, 0, 0.9); /* viewer background */
--blb-accent: rgba(99, 102, 241, 0.3);
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 300px;
padding: 16px;
position: relative;
background: #0a0a0f;
color: #fff;
font-family: sans-serif;
}
/* Thumbnails: real buttons wrapping real images */
.blb-grid {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: var(--blb-gap);
width: 100%;
}
.blb-thumb {
display: block;
width: var(--blb-thumb);
max-width: 100%;
aspect-ratio: 3 / 2;
padding: 0;
border: 0;
border-radius: var(--blb-radius);
overflow: hidden;
background: #1a1a24;
cursor: pointer;
transition: transform 0.3s, box-shadow 0.3s;
}
.blb-thumb img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.blb-thumb:hover,
.blb-thumb:focus-visible {
transform: scale(1.05);
box-shadow: var(--blb-accent) 0 10px 30px;
}
.blb-thumb:focus-visible {
outline: 2px solid #fff;
outline-offset: 3px;
}
/* Viewer: native modal <dialog> (top layer, focus kept inside, Escape) */
.blb-viewer {
width: 100%;
height: 100%;
max-width: none;
max-height: none;
margin: 0;
padding: 0;
border: 0;
overflow: hidden;
background: var(--blb-backdrop);
color: #fff;
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
opacity: 0;
transition: opacity 0.4s ease;
}
.blb-viewer[open] {
display: flex;
align-items: center;
justify-content: center;
}
.blb-viewer.is-open {
opacity: 1;
}
.blb-viewer::backdrop {
background: transparent;
}
.blb-viewer button:focus-visible {
outline: 2px solid #fff;
outline-offset: 3px;
}
.blb-content {
position: relative;
max-width: 80vw;
transform: scale(0.8);
transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.blb-viewer.is-open .blb-content {
transform: scale(1);
}
.blb-image {
display: block;
width: auto;
height: auto;
max-width: 80vw;
max-height: 70vh;
border-radius: var(--blb-radius-lg);
touch-action: pan-y pinch-zoom;
-webkit-user-select: none;
user-select: none;
}
/* Close button */
.blb-close {
position: absolute;
top: -44px;
right: 0;
width: 36px;
height: 36px;
background: rgba(255, 255, 255, 0.1);
border: none;
border-radius: 50%;
color: white;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.3s ease, transform 0.3s ease;
}
.blb-close:hover {
background: rgba(255, 255, 255, 0.2);
transform: rotate(90deg);
}
/* Reduced motion: the viewer opens and closes at once, nothing scales */
@media (prefers-reduced-motion: reduce) {
.blb-thumb,
.blb-viewer,
.blb-content,
.blb-close,
.blb-nav {
transition: none;
}
.blb-content,
.blb-thumb:hover,
.blb-thumb:focus-visible {
transform: none;
}
}(function () {
'use strict';
// Basic Lightbox — one independent instance per .fx-0171-root (pasting the script twice is harmless)
var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
var CLOSE_MS = 400; // matches the CSS closing transition
function setup(root) {
if (root.hasAttribute('data-blb-ready')) return;
var thumbs = Array.prototype.slice.call(root.querySelectorAll('.blb-thumb'));
var viewer = root.querySelector('.blb-viewer');
if (!thumbs.length || !viewer || typeof viewer.showModal !== 'function') return;
root.setAttribute('data-blb-ready', '');
var image = viewer.querySelector('.blb-image');
var index = 0, opener = null, closeTimer = 0, downOnBackdrop = false;
image.draggable = false;
// Large version: data-full on the button, otherwise the thumbnail image itself
function sourceOf(thumb) {
var small = thumb.querySelector('img');
return {
src: thumb.getAttribute('data-full') || (small ? small.currentSrc || small.src : ''),
alt: small ? small.alt : ''
};
}
function show(i) {
index = i;
var s = sourceOf(thumbs[i]);
image.src = s.src;
image.alt = s.alt;
}
function open(i) {
clearTimeout(closeTimer);
opener = thumbs[i];
if (!viewer.open) viewer.showModal();
show(i);
void viewer.offsetWidth; // start the opening transition from the closed state
viewer.classList.add('is-open');
}
function close() {
if (!viewer.open) return;
viewer.classList.remove('is-open');
clearTimeout(closeTimer);
if (reduceMotion.matches) viewer.close();
else closeTimer = setTimeout(function () { viewer.close(); }, CLOSE_MS);
}
thumbs.forEach(function (thumb, i) {
thumb.addEventListener('click', function () { open(i); });
});
viewer.querySelector('.blb-close').addEventListener('click', close);
// Click on the dark background (not on the image or a button) closes
viewer.addEventListener('pointerdown', function (e) { downOnBackdrop = e.target === viewer; });
viewer.addEventListener('click', function (e) {
if (e.target === viewer && downOnBackdrop) close();
});
viewer.addEventListener('cancel', function (e) { e.preventDefault(); close(); });
// Keyboard: Escape closes
viewer.addEventListener('keydown', function (e) {
if (e.key === 'Escape') { e.preventDefault(); close(); }
});
// Closed: focus goes back to the thumbnail that opened the viewer
viewer.addEventListener('close', function () {
clearTimeout(closeTimer);
viewer.classList.remove('is-open');
if (opener) opener.focus();
});
}
function start() {
document.querySelectorAll('.fx-0171-root').forEach(setup);
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start);
else start();
})();Gallery Grid
Masonry-style grid that opens a lightbox.
Fullscreen Lightbox
Real browser fullscreen (on iPhone the viewer covers the window), Escape to close.
Effect page →View source code
<div class="fx-0179-root">
<a class="hzm-frame" href="#">
<img class="hzm-image" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='560' height='400' viewBox='0 0 560 400'%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop stop-color='%23667eea'/%3E%3Cstop offset='.5' stop-color='%23764ba2'/%3E%3Cstop offset='1' stop-color='%23f093fb'/%3E%3C/linearGradient%3E%3Cpattern id='s' width='20' height='20' patternUnits='userSpaceOnUse' patternTransform='rotate(45)'%3E%3Crect x='10' width='10' height='20' fill='%236366f1' fill-opacity='.1'/%3E%3C/pattern%3E%3Cpattern id='q' width='20' height='20' patternUnits='userSpaceOnUse'%3E%3Cpath d='M0 .5H20M.5 0V20' stroke='%23fff' stroke-opacity='.1'/%3E%3C/pattern%3E%3CradialGradient id='l' cx='168' cy='120' r='241' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%23fff' stop-opacity='.3'/%3E%3Cstop offset='1' stop-color='%23fff' stop-opacity='0'/%3E%3C/radialGradient%3E%3CradialGradient id='d' cx='392' cy='280' r='241' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-opacity='.2'/%3E%3Cstop offset='1' stop-opacity='0'/%3E%3C/radialGradient%3E%3Crect width='560' height='400' fill='url(%23g)'/%3E%3Crect width='560' height='400' fill='url(%23s)'/%3E%3Crect width='560' height='400' fill='url(%23q)'/%3E%3Crect width='560' height='400' fill='url(%23l)'/%3E%3Crect width='560' height='400' fill='url(%23d)'/%3E%3C/svg%3E" alt="Violet gradient grid pattern" width="560" height="400">
<span class="hzm-label" aria-hidden="true">Hover Me</span>
</a>
</div>/* fx-0179 — Hover Zoom: the image grows inside its frame on hover or keyboard focus (CSS only).
Everything is scoped to .fx-0179-root and the hzm- prefix: two copies on one page stay independent. */
.fx-0179-root,
.fx-0179-root *,
.fx-0179-root *::before,
.fx-0179-root *::after {
box-sizing: border-box;
}
.fx-0179-root {
--hzm-scale: 1.3; /* zoom level on hover / keyboard focus */
--hzm-duration: 0.5s; /* zoom-in and zoom-out time */
--hzm-width: 280px; /* maximum frame width (the frame shrinks on small screens) */
--hzm-ratio: 7 / 5; /* frame shape */
--hzm-radius: 0.75rem; /* frame corners */
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 250px;
padding: 16px;
position: relative;
background: #0a0a0f;
color: #fff;
font-family: sans-serif;
}
/* Frame: fluid width (capped by --hzm-width), height from --hzm-ratio */
.hzm-frame {
position: relative;
display: block;
width: 100%;
max-width: var(--hzm-width);
aspect-ratio: var(--hzm-ratio);
border-radius: var(--hzm-radius);
overflow: hidden;
isolation: isolate;
background: #12121a;
border: 1px solid rgba(255, 255, 255, 0.08);
}
.hzm-frame:focus-visible {
outline: 2px solid #fff;
outline-offset: 3px;
}
/* Your image: any <img>, cropped to the frame like a cover photo */
.hzm-image {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
-webkit-user-select: none;
user-select: none;
}
/* Optional caption over the image (delete the span if you do not want it) */
.hzm-label {
position: absolute;
inset: 0;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-weight: 600;
font-size: 1.2rem;
text-shadow: rgba(0, 0, 0, 0.3) 0 2px 4px;
pointer-events: none;
}
.hzm-frame {
cursor: pointer;
color: inherit;
text-decoration: none;
}
.hzm-image {
transition: transform var(--hzm-duration) cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Hover on the frame or on a link that wraps it */
.hzm-frame:hover .hzm-image,
.fx-0179-root a:hover .hzm-image {
transform: scale(var(--hzm-scale));
}
/* Keyboard focus on the frame (a link) or on a link that wraps it (separate rule: older browsers skip it alone) */
.hzm-frame:focus-visible .hzm-image,
.fx-0179-root a:focus-visible .hzm-image {
transform: scale(var(--hzm-scale));
}
/* Reduced motion: the image still zooms, without the transition */
@media (prefers-reduced-motion: reduce) {
.hzm-image {
transition: none;
}
}/* Pure CSS — no JavaScript required */Lens Zoom
Square magnifier that enlarges the area under the cursor.
Product Zoom
Product gallery: thumbnails switch the photo, the photo zooms under the pointer.
Effect page →View source code
<div class="fx-0187-root" data-speed="85" data-direction="left">
<div class="bmq-band">
<div class="bmq-viewport">
<div class="bmq-track">
<ul class="bmq-group" role="list">
<li>Welcome to Effect.Labs</li>
<li>Premium Web Effects</li>
<li>Modern CSS Animations</li>
<li>Infinite Scrolling</li>
</ul>
</div>
</div>
<button type="button" class="bmq-toggle" aria-pressed="false" aria-label="Pause"></button>
</div>
</div>.fx-0187-root,
.fx-0187-root *,
.fx-0187-root *::before,
.fx-0187-root *::after {
box-sizing: border-box;
}
/* Settings: variables below; speed (px/s) and direction in the data-speed and data-direction attributes of the HTML */
.fx-0187-root {
--bmq-height: 250px; /* frame height (auto: the band height) */
--bmq-bg: rgb(26, 26, 36); /* frame background */
--bmq-color: #6366f1; /* text colour */
--bmq-size: 1.5rem; /* text size */
--bmq-space: 4rem; /* space between two items */
--bmq-button: rgba(255, 255, 255, .8); /* Pause button colour */
--bmq-padding: 1rem 0; /* frame inner padding */
--bmq-button-size: 2rem; /* Pause button diameter */
display: flex;
align-items: center;
width: 100%;
min-height: var(--bmq-height);
padding: var(--bmq-padding);
overflow: hidden;
position: relative;
background: var(--bmq-bg);
color: #fff;
font-family: sans-serif;
}
.bmq-band {
display: flex;
align-items: center;
gap: .75rem;
width: 100%;
min-width: 0;
}
.bmq-viewport {
flex: 1;
min-width: 0;
overflow: hidden;
}
.bmq-track {
display: flex;
width: max-content;
}
.bmq-group {
display: flex;
align-items: center;
flex-shrink: 0;
margin: 0;
padding: 0;
list-style: none;
font-size: var(--bmq-size);
font-weight: 600;
color: var(--bmq-color);
}
.bmq-group > li {
margin: 0 calc(var(--bmq-space) / 2);
white-space: nowrap;
}
/* Scrolling: started by the script once the track is filled (bmq-on class) */
.fx-0187-root.bmq-on .bmq-track {
animation-name: bmq-scroll;
animation-duration: var(--bmq-duration, 15s);
animation-timing-function: linear;
animation-iteration-count: infinite;
will-change: transform;
}
.fx-0187-root[data-direction="right"] .bmq-track {
animation-direction: reverse;
}
@keyframes bmq-scroll {
from {
transform: translateX(0);
}
to {
transform: translateX(var(--bmq-shift));
}
}
/* Pause: hovering the band or the Pause button */
.bmq-viewport:hover .bmq-track,
.fx-0187-root.bmq-paused .bmq-track {
animation-play-state: paused;
}
/* Keyboard focus inside the band (bmq-focus class): band back to its start and still, the browser scrolls to the link */
.fx-0187-root.bmq-focus .bmq-track {
animation: none;
}
/* Pause / Play button (remove it from the HTML if the band is short and purely decorative) */
.bmq-toggle {
flex: none;
position: relative;
width: var(--bmq-button-size);
height: var(--bmq-button-size);
margin: 0 1rem 0 0;
padding: 0;
border: 1px solid currentColor;
border-radius: 50%;
background: transparent;
color: var(--bmq-button);
cursor: pointer;
}
.bmq-toggle::before,
.bmq-toggle::after {
content: "";
position: absolute;
top: 50%;
width: 3px;
height: 10px;
margin-top: -5px;
border-radius: 1px;
background: currentColor;
}
.bmq-toggle::before {
left: calc(50% - 4px);
}
.bmq-toggle::after {
left: calc(50% + 1px);
}
.bmq-toggle[aria-pressed="true"]::before {
left: calc(50% - 3px);
width: 0;
height: 0;
margin-top: -6px;
border-style: solid;
border-width: 6px 0 6px 10px;
border-color: transparent transparent transparent currentColor;
border-radius: 0;
background: none;
}
.bmq-toggle[aria-pressed="true"]::after {
display: none;
}
.bmq-toggle:hover {
background: rgba(127, 127, 127, .18);
}
.bmq-toggle:focus-visible {
outline: 2px solid currentColor;
outline-offset: 2px;
}
/* Without the script: still band, scrollable by hand */
.fx-0187-root:not(.bmq-on) .bmq-viewport {
overflow-x: auto;
}
.fx-0187-root:not(.bmq-on) .bmq-toggle {
display: none;
}
/* Reduced motion: nothing moves by itself, the content stays readable and scrollable by hand */
@media (prefers-reduced-motion: reduce) {
.fx-0187-root.bmq-on .bmq-track {
animation: none;
}
.fx-0187-root .bmq-viewport {
overflow-x: auto;
scrollbar-width: thin;
}
.fx-0187-root .bmq-viewport:focus-visible {
outline: 2px solid currentColor;
outline-offset: -2px;
}
.fx-0187-root .bmq-clone,
.fx-0187-root .bmq-toggle {
display: none;
}
}(function () {
'use strict';
// fx-0187 — Basic Marquee : the content is written once, the script copies it to fill the band
var ROOT = '.fx-0187-root';
var VERTICAL = false;
var DEFAULT_SPEED = 85; // pixels per second
var FOCUSABLE = 'a[href], button, input, select, textarea, [tabindex]';
// Decorative copy: hidden from screen readers and out of the keyboard order
function copyOf(group) {
var copy = group.cloneNode(true);
copy.classList.add('bmq-clone');
copy.setAttribute('aria-hidden', 'true');
copy.removeAttribute('id');
copy.querySelectorAll('[id]').forEach(function (el) { el.removeAttribute('id'); });
copy.querySelectorAll(FOCUSABLE).forEach(function (el) { el.setAttribute('tabindex', '-1'); });
return copy;
}
function setup(root) {
if (root.bmqReady) return; // script pasted twice
root.bmqReady = true;
var reduced = window.matchMedia('(prefers-reduced-motion: reduce)');
var bands = [];
root.querySelectorAll('.bmq-viewport').forEach(function (viewport) {
var track = viewport.querySelector('.bmq-track');
var group = track && track.querySelector('.bmq-group');
if (!group) return;
var holder = viewport.closest('[data-speed]');
bands.push({ viewport: viewport, track: track, group: group, holder: holder && root.contains(holder) ? holder : root });
});
if (!bands.length) return;
// Enough copies to cover the visible area + one coming in; shift = one group
function fill(band) {
var box = band.group.getBoundingClientRect();
var size = VERTICAL ? box.height : box.width;
var room = VERTICAL ? band.viewport.clientHeight : band.viewport.clientWidth;
if (!size) return;
var copies = band.track.children.length;
var needed = Math.ceil(room / size) + 1;
for (; copies < needed; copies++) band.track.appendChild(copyOf(band.group));
var speed = parseFloat(band.holder.getAttribute('data-speed')) || DEFAULT_SPEED;
band.track.style.setProperty('--bmq-shift', -size + 'px');
band.track.style.setProperty('--bmq-duration', (size / speed) + 's');
// Reduced motion: the band scrolls by hand, so also with the keyboard (tabindex) when it overflows
var over = VERTICAL ? band.viewport.scrollHeight > band.viewport.clientHeight + 1 : band.viewport.scrollWidth > band.viewport.clientWidth + 1;
if (reduced.matches && over) band.viewport.setAttribute('tabindex', '0');
else band.viewport.removeAttribute('tabindex');
root.classList.add('bmq-on');
}
function fillAll() { bands.forEach(fill); }
fillAll();
// Content changed later (translated text, new item): the copies are rebuilt
if ('MutationObserver' in window) {
bands.forEach(function (band) {
new MutationObserver(function () {
band.track.querySelectorAll('.bmq-clone').forEach(function (copy) { copy.remove(); });
fill(band);
}).observe(band.group, { childList: true, subtree: true, characterData: true });
});
}
if ('ResizeObserver' in window) {
var observer = new ResizeObserver(fillAll);
bands.forEach(function (band) {
observer.observe(band.viewport);
observer.observe(band.group);
});
} else {
window.addEventListener('resize', fillAll);
}
// Keyboard focus on a link in the band: still band (bmq-focus) with the link brought into view, put back when focus leaves
root.addEventListener('focusin', function (event) {
var viewport = event.target.closest('.bmq-viewport');
root.classList.toggle('bmq-focus', !!viewport);
if (!viewport) return;
var view = viewport.getBoundingClientRect();
var item = event.target.getBoundingClientRect();
if (VERTICAL) {
if (item.bottom > view.bottom) viewport.scrollTop += item.bottom - view.bottom;
if (item.top < view.top) viewport.scrollTop -= view.top - item.top;
} else {
if (item.right > view.right) viewport.scrollLeft += item.right - view.right;
if (item.left < view.left) viewport.scrollLeft -= view.left - item.left;
}
});
root.addEventListener('focusout', function () {
root.classList.remove('bmq-focus');
if (!reduced.matches) bands.forEach(function (band) { band.viewport.scrollLeft = 0; band.viewport.scrollTop = 0; });
});
var toggle = root.querySelector('.bmq-toggle');
if (toggle) {
toggle.addEventListener('click', function () {
var paused = toggle.getAttribute('aria-pressed') !== 'true';
toggle.setAttribute('aria-pressed', paused ? 'true' : 'false');
root.classList.toggle('bmq-paused', paused);
});
}
}
function init() {
document.querySelectorAll(ROOT).forEach(setup);
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init);
else init();
})();Reverse Marquee
Text scrolling in the opposite direction.
Image Marquee
Images scrolling horizontally.
Speed Variation
Rows scrolling at different speeds.
Hover Pause
Words grow while the band pauses on hover.
Marquee with Icons
Text mixed with icons and symbols.
CSS-Only Carousel
Native carousel without a single line of JavaScript (::scroll-button / ::scroll-marker), smooth scroll-snap: native arrows and dots in Chrome and Edge 135+; elsewhere snap scrolling by finger, keyboard and scrollbar.
💡 Perfect for: product gallery, testimonials, partner logos, onboarding, hero slider — anywhere you used to write 30 lines of JS.
Effect page →View source code
<div class="fx-0798-root">
<div class="coc-wrap">
<div class="coc-carousel" tabindex="0" role="region" aria-roledescription="carousel" aria-label="Carousel">
<div class="coc-slide" role="group" aria-roledescription="slide" aria-label="1 of 5" style="--g:linear-gradient(135deg,#6d8bff,#5cffd8)">01</div>
<div class="coc-slide" role="group" aria-roledescription="slide" aria-label="2 of 5" style="--g:linear-gradient(135deg,#ff7eb6,#a777ff)">02</div>
<div class="coc-slide" role="group" aria-roledescription="slide" aria-label="3 of 5" style="--g:linear-gradient(135deg,#ffb86b,#ff5e8a)">03</div>
<div class="coc-slide" role="group" aria-roledescription="slide" aria-label="4 of 5" style="--g:linear-gradient(135deg,#4dd2ff,#9b8cff)">04</div>
<div class="coc-slide" role="group" aria-roledescription="slide" aria-label="5 of 5" style="--g:linear-gradient(135deg,#5cffd8,#3ad6b3)">05</div>
</div>
</div>
</div>.fx-0798-root,
.fx-0798-root *,
.fx-0798-root *::before,
.fx-0798-root *::after {
box-sizing: border-box
}
.fx-0798-root {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 250px;
padding: 20px 0;
overflow: hidden;
position: relative;
background: rgb(26, 26, 36);
color: rgb(255, 255, 255);
font-family: sans-serif;
}
/* Width: the container width, capped by --coc-max-width */
.coc-wrap {
position: relative;
width: 100%;
max-width: var(--coc-max-width, 640px);
}
.coc-carousel {
display: flex;
gap: 14px;
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
padding: 6px;
border-radius: 14px;
scroll-marker-group: after;
/* Fallback (Firefox, Safari): thin visible scrollbar for mouse users */
scrollbar-width: thin;
scrollbar-color: rgba(255, 255, 255, .35) transparent;
}
.coc-carousel:focus-visible {
outline: 2px solid #5cffd8;
outline-offset: 2px;
}
.coc-slide {
position: relative;
overflow: hidden;
flex: 0 0 var(--coc-slide-width, 78%);
scroll-snap-align: center;
aspect-ratio: var(--coc-ratio, 16 / 9);
border-radius: 14px;
display: grid;
place-items: center;
color: #fff;
font-weight: 800;
font-size: 20px;
letter-spacing: -0.01em;
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
background: var(--g, linear-gradient(135deg, #6d8bff, #5cffd8));
}
/* An <img> placed in a slide covers it entirely */
.coc-slide > img {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
/* Native arrows and dots: Chrome / Edge 135+; the scrollbar is no longer needed there */
@supports selector(::scroll-marker) {
.coc-carousel {
scrollbar-width: none;
}
.coc-carousel::-webkit-scrollbar {
height: 0;
}
}
.coc-slide::scroll-marker {
content: "";
width: 9px;
height: 9px;
margin: 0 4px;
border: 0;
border-radius: 50%;
background: rgba(255, 255, 255, 0.28);
cursor: pointer;
transition: background .2s, transform .2s;
}
.coc-slide::scroll-marker:target-current {
background: #5cffd8;
transform: scale(1.3);
}
.coc-slide::scroll-marker:hover {
background: rgba(255, 255, 255, 0.6);
}
.coc-slide::scroll-marker:focus-visible {
outline: 2px solid #5cffd8;
outline-offset: 2px;
}
.coc-carousel::scroll-marker-group {
display: flex;
justify-content: center;
align-items: center;
padding-top: 12px;
}
.coc-carousel::scroll-button(left),
.coc-carousel::scroll-button(right) {
position: absolute;
top: calc(50% - 28px);
transform: translateY(-50%);
z-index: 3;
width: 38px;
height: 38px;
border: 0;
border-radius: 50%;
cursor: pointer;
font-size: 18px;
background: rgba(10, 14, 31, 0.65);
color: #fff;
-webkit-backdrop-filter: blur(6px);
backdrop-filter: blur(6px);
}
.coc-carousel::scroll-button(left) {
left: 10px;
content: "‹" / "Previous";
}
.coc-carousel::scroll-button(right) {
right: 10px;
content: "›" / "Next";
}
.coc-carousel::scroll-button(left):disabled,
.coc-carousel::scroll-button(right):disabled {
opacity: .35;
cursor: default;
}
.coc-carousel::scroll-button(left):focus-visible,
.coc-carousel::scroll-button(right):focus-visible {
outline: 2px solid #5cffd8;
outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
.coc-carousel {
scroll-behavior: auto;
}
}/* Pure CSS — no JavaScript required */WebGL Displacement Slideshow
Slideshow whose transitions are computed by a GPU displacement shader: visuals warp and blend into each other. Your images, pause on hover or with a button; CSS crossfade fallback without WebGL.
💡 Perfect for: visual hero, premium product gallery, agency showreel, photo portfolio, immersive homepage.
Effect page →Gallery Flow Morph
Scattered gallery drifting in parallax: click a tile and it morphs into a full-frame view through the View Transitions API, title revealed letter by letter. Pause on hover, focus or with a button; fade fallback, keyboard dismiss.
💡 Perfect for: portfolios, photo galleries, agency project pages, interactive moodboards.
Effect page →Velocity Marquee
Endless text bands that page scroll and the mouse speed up and tilt; they stop on hover, focus or with the Pause button. Reduced motion: still bands you scroll by hand.
💡 Perfect for: partner logo strips, « Trusted by » sections, press tickers, agency heroes.
Effect page →View source code
<div class="fx-0831-root" data-vmq-speed="50" data-vmq-skew="7">
<div class="vmq-demo-wrapper">
<span class="vmq-demo-label" aria-hidden="true">move the cursor · scroll the page</span>
<!-- upper secondary band (RTL, small) -->
<div class="vmq-stripe vmq-stripe--sm">
<div class="vmq-root" data-dir="rtl"
style="--vmq-size:clamp(13px,2.4vw,20px);--vmq-gap:18px;--vmq-sep-gap:10px;">
<div class="vmq-track">
<span class="vmq-item" data-style="outline">SEAMLESS</span>
<span class="vmq-sep" aria-hidden="true">·</span>
<span class="vmq-item" data-style="outline">INFINITE</span>
<span class="vmq-sep" aria-hidden="true">·</span>
<span class="vmq-item" data-style="outline">VELOCITY</span>
<span class="vmq-sep" aria-hidden="true">·</span>
<span class="vmq-item" data-style="outline">MARQUEE</span>
<span class="vmq-sep" aria-hidden="true">·</span>
<span class="vmq-item" data-style="outline">NO GAP</span>
<span class="vmq-sep" aria-hidden="true">·</span>
<span class="vmq-item" data-style="outline">SCROLL PHYSICS</span>
<span class="vmq-sep" aria-hidden="true">·</span>
</div>
</div>
</div>
<!-- main band (large type, LTR) -->
<div class="vmq-stripe vmq-stripe--lg">
<div class="vmq-root" style="--vmq-size:clamp(30px,6vw,56px);--vmq-gap:24px;">
<div class="vmq-track">
<span class="vmq-item">NEW DROP</span>
<span class="vmq-sep" aria-hidden="true">✦</span>
<span class="vmq-item" data-style="outline">EFFECT.LABS</span>
<span class="vmq-sep" aria-hidden="true">✦</span>
<span class="vmq-item">VANILLA JS</span>
<span class="vmq-sep" aria-hidden="true">✦</span>
<span class="vmq-item" data-style="outline">NO FRAMEWORK</span>
<span class="vmq-sep" aria-hidden="true">✦</span>
<span class="vmq-item">OPEN SOURCE</span>
<span class="vmq-sep" aria-hidden="true">✦</span>
<span class="vmq-item" data-style="outline">CSS + JS</span>
<span class="vmq-sep" aria-hidden="true">✦</span>
</div>
</div>
</div>
<!-- lower secondary band (RTL, small) -->
<div class="vmq-stripe vmq-stripe--sm">
<div class="vmq-root" data-dir="rtl"
style="--vmq-size:clamp(13px,2.4vw,20px);--vmq-gap:18px;--vmq-sep-gap:10px;">
<div class="vmq-track">
<span class="vmq-item" data-style="outline">INERTIA</span>
<span class="vmq-sep" aria-hidden="true">·</span>
<span class="vmq-item" data-style="outline">SKEWX</span>
<span class="vmq-sep" aria-hidden="true">·</span>
<span class="vmq-item" data-style="outline">MASK-IMAGE</span>
<span class="vmq-sep" aria-hidden="true">·</span>
<span class="vmq-item" data-style="outline">RAF + LERP</span>
<span class="vmq-sep" aria-hidden="true">·</span>
<span class="vmq-item" data-style="outline">A11Y</span>
<span class="vmq-sep" aria-hidden="true">·</span>
<span class="vmq-item" data-style="outline">WCAG 2.2.2</span>
<span class="vmq-sep" aria-hidden="true">·</span>
</div>
</div>
</div>
<button class="vmq-pause-btn" type="button" aria-pressed="false">
<span aria-hidden="true">⏸</span>
<span>Pause</span>
</button>
</div>
</div>.fx-0831-root,
.fx-0831-root *,
.fx-0831-root *::before,
.fx-0831-root *::after {
box-sizing: border-box
}
.fx-0831-root {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 300px;
overflow: hidden;
position: relative;
background: rgb(26, 26, 36);
color: rgb(255, 255, 255);
font-family: sans-serif;
}
.vmq-root {
position: relative;
overflow: hidden;
width: 100%;
cursor: default;
-webkit-mask-image: linear-gradient(to right,
transparent 0%,
#000 9%,
#000 91%,
transparent 100%);
mask-image: linear-gradient(to right,
transparent 0%,
#000 9%,
#000 91%,
transparent 100%);
}
@supports not ((mask-image: linear-gradient(to right, #000, #000)) or (-webkit-mask-image: linear-gradient(to right, #000, #000))) {
.vmq-root {
border-radius: 0;
}
}
.vmq-track {
display: flex;
align-items: center;
white-space: nowrap;
will-change: transform;
transform-origin: left center;
user-select: none;
-webkit-user-select: none;
}
.vmq-item {
flex-shrink: 0;
display: inline-flex;
align-items: center;
padding: 0 var(--vmq-gap, 28px);
font-size: var(--vmq-size, clamp(24px, 5vw, 48px));
font-weight: 800;
letter-spacing: -0.02em;
line-height: 1;
color: var(--vmq-color, #f1f5f9);
white-space: nowrap;
text-decoration: none;
}
.vmq-item[data-style="outline"] {
color: transparent;
-webkit-text-stroke: 1.5px var(--vmq-stroke, rgba(241, 245, 249, 0.45));
text-stroke: 1.5px var(--vmq-stroke, rgba(241, 245, 249, 0.45));
}
.vmq-sep {
flex-shrink: 0;
padding: 0 var(--vmq-sep-gap, 16px);
font-size: calc(var(--vmq-size, clamp(24px, 5vw, 48px)) * 0.60);
color: var(--vmq-accent, #6366f1);
line-height: 1;
pointer-events: none;
white-space: nowrap;
}
.vmq-demo-wrapper {
position: relative;
width: 100%;
min-height: 300px;
display: flex;
flex-direction: column;
align-items: stretch;
justify-content: center;
background: #06060e;
border-radius: 14px;
overflow: hidden;
gap: 0;
}
.vmq-demo-label {
position: absolute;
top: 16px;
left: 50%;
transform: translateX(-50%);
font-size: 11px;
color: rgba(148, 163, 184, 0.30);
letter-spacing: 0.10em;
text-transform: uppercase;
font-weight: 500;
pointer-events: none;
white-space: nowrap;
z-index: 2;
}
.vmq-stripe {
display: flex;
align-items: center;
flex: 1;
min-height: 60px;
}
.vmq-stripe--lg {
flex: 2;
min-height: 100px;
}
.vmq-stripe--sm {
flex: 1;
opacity: 0.6;
min-height: 56px;
}
.vmq-pause-btn {
position: absolute;
bottom: 14px;
right: 14px;
z-index: 10;
display: inline-flex;
align-items: center;
gap: 6px;
background: rgba(15, 15, 26, 0.80);
border: 1px solid rgba(99, 102, 241, 0.35);
color: #c7d2fe;
padding: 6px 12px 6px 10px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
cursor: pointer;
letter-spacing: 0.01em;
transition: background 0.15s, border-color 0.15s;
outline: 2px solid transparent;
outline-offset: 2px;
}
.vmq-pause-btn:hover {
background: rgba(30, 30, 50, 0.90);
border-color: rgba(99, 102, 241, 0.65);
}
.vmq-pause-btn:focus-visible {
outline-color: #818cf8;
}
.vmq-pause-btn[aria-pressed="true"] {
background: rgba(49, 46, 129, 0.85);
border-color: #6366f1;
color: #e0e7ff;
}
/* reduced motion: still band, scrollable by hand (finger, wheel, keyboard) */
.vmq-root.vmq-static {
overflow-x: auto;
-webkit-mask-image: none;
mask-image: none;
scrollbar-width: thin;
scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}
.vmq-root.vmq-static .vmq-track {
transform: none;
user-select: text;
-webkit-user-select: text;
}
.vmq-root:focus-visible {
outline: 2px solid #818cf8;
outline-offset: -2px;
}
@media (prefers-reduced-motion: reduce) {
.vmq-pause-btn,
.vmq-demo-label {
display: none;
}
}(function () {
/* fx-0831 — Velocity Marquee : one instance per .fx-0831-root */
'use strict';
var RM = window.matchMedia('(prefers-reduced-motion: reduce)');
var FOCUSABLE = 'a[href], button, input, select, textarea, [tabindex]';
function num(v, d, min, max) {
var n = parseFloat(v);
if (isNaN(n)) n = d;
return Math.max(min, Math.min(max, n));
}
/* smoothing independent of the screen refresh rate (k = factor tuned for 60 fps) */
function ease(k, dt) { return 1 - Math.pow(1 - k, dt * 60); }
function setupRoot(root) {
if (root.getAttribute('data-vmq-ready')) return;
root.setAttribute('data-vmq-ready', '1');
var BASE = num(root.getAttribute('data-vmq-speed'), 50, 5, 400); /* px/s */
var SKEW_MAX = num(root.getAttribute('data-vmq-skew'), 7, 0, 20); /* degrees */
var SCROLL_K = 3.6; /* px/s added per px of page scroll */
var MOUSE_K = 1.7; /* px/s added per px of horizontal mouse movement */
var SKEW_K = 0.0047; /* degrees of lean per px/s away from the base speed */
var BREATHE = 0.12; /* slow breathing: ±12% of the speed */
var btn = root.querySelector('.vmq-pause-btn');
var bands = [];
var vel = BASE, skew = 0, sBonus = 0, mBonus = 0, time = 0;
var paused = false, visible = true, reduced = RM.matches;
var raf = 0, lastT = 0, lastY = window.scrollY || 0, lastX = null;
Array.prototype.forEach.call(root.querySelectorAll('.vmq-root'), function (el) {
var track = el.querySelector('.vmq-track');
if (!track) return;
var b = {
el: el, track: track, orig: Array.prototype.slice.call(track.children),
setW: 0, pos: 0, rtl: el.getAttribute('data-dir') === 'rtl', hover: false, focus: false
};
el.addEventListener('pointerenter', function (e) { if (e.pointerType === 'mouse') b.hover = true; });
el.addEventListener('pointerleave', function () { b.hover = false; });
el.addEventListener('focusin', function () { b.focus = true; });
el.addEventListener('focusout', function () { b.focus = false; });
bands.push(b);
});
if (!bands.length) return;
function held() {
for (var i = 0; i < bands.length; i++) if (bands[i].hover || bands[i].focus) return true;
return false;
}
function clone(node) {
var c = node.cloneNode(true);
if (c.nodeType !== 1) return c;
c.setAttribute('aria-hidden', 'true');
c.removeAttribute('id');
if (c.matches(FOCUSABLE)) c.setAttribute('tabindex', '-1');
Array.prototype.forEach.call(c.querySelectorAll('[id]'), function (n) { n.removeAttribute('id'); });
Array.prototype.forEach.call(c.querySelectorAll(FOCUSABLE), function (n) { n.setAttribute('tabindex', '-1'); });
return c;
}
/* (re)builds each band: original set + copies hidden from screen readers */
function build() {
bands.forEach(function (b) {
var t = b.track;
while (t.lastChild && b.orig.indexOf(t.lastChild) < 0) t.removeChild(t.lastChild);
t.style.transform = '';
b.el.classList.toggle('vmq-static', reduced);
b.el.removeAttribute('tabindex');
if (reduced) {
b.setW = 0;
if (b.el.scrollWidth > b.el.clientWidth + 1) b.el.setAttribute('tabindex', '0');
return;
}
var cw = b.el.clientWidth || 480;
var sw = t.scrollWidth || 200;
var n = Math.ceil(cw / sw) + 1;
for (var i = 0; i < n; i++) b.orig.forEach(function (o) { t.appendChild(clone(o)); });
var first = b.orig[0], twin = t.children[b.orig.length];
var w = (first && twin) ? twin.getBoundingClientRect().left - first.getBoundingClientRect().left : 0;
b.setW = w > 1 ? w : sw;
b.pos = b.pos % b.setW;
});
if (!reduced) draw();
run();
}
function draw() {
bands.forEach(function (b) {
if (!b.setW) return;
var sk = b.rtl ? -skew : skew;
b.track.style.transform = 'translateX(' + (-b.pos).toFixed(2) + 'px) skewX(' + sk.toFixed(3) + 'deg)';
});
}
function frame(t) {
raf = 0;
if (reduced || paused || !visible) { lastT = 0; return; }
raf = requestAnimationFrame(frame);
var dt = lastT ? Math.min((t - lastT) / 1000, 0.05) : 0;
lastT = t;
if (!dt) return;
var hold = held();
time += 0.54 * dt;
var target = hold ? 0 : BASE * (1 + Math.sin(time) * BREATHE) + sBonus + mBonus;
sBonus *= Math.pow(0.80, dt * 60);
mBonus *= Math.pow(0.84, dt * 60);
/* hover or focus: quick stop (WCAG 2.2.2), otherwise smooth return */
vel += (target - vel) * ease(hold ? 0.16 : 0.07, dt);
if (hold && Math.abs(vel) < 0.5) vel = 0;
var tSkew = hold ? 0 : Math.max(-SKEW_MAX, Math.min(SKEW_MAX, -(vel - BASE) * SKEW_K));
skew += (tSkew - skew) * ease(0.09, dt);
bands.forEach(function (b) {
if (!b.setW) return;
var step = (b.rtl ? -vel : vel) * dt;
b.pos = ((b.pos + step) % b.setW + b.setW) % b.setW;
});
draw();
}
function run() {
if (!raf && !reduced && !paused && visible) { lastT = 0; raf = requestAnimationFrame(frame); }
}
window.addEventListener('scroll', function () {
var y = window.scrollY || 0;
if (visible) sBonus = (y - lastY) * SCROLL_K;
lastY = y;
}, { passive: true });
root.addEventListener('pointermove', function (e) {
if (e.pointerType !== 'mouse') return;
if (lastX !== null) mBonus = (e.clientX - lastX) * MOUSE_K;
lastX = e.clientX;
});
root.addEventListener('pointerleave', function () { lastX = null; });
if (btn) {
btn.addEventListener('click', function () {
paused = !paused;
btn.setAttribute('aria-pressed', paused ? 'true' : 'false');
var icon = btn.querySelector('[aria-hidden="true"]');
if (icon) icon.textContent = paused ? '▶' : '⏸';
if (paused) { vel = 0; skew = 0; draw(); } else { vel = 0; run(); }
});
}
if (RM.addEventListener) {
RM.addEventListener('change', function (e) { reduced = e.matches; skew = 0; build(); });
}
if ('IntersectionObserver' in window) {
new IntersectionObserver(function (en) {
visible = en[0].isIntersecting;
run();
}).observe(root);
}
var lastW = root.clientWidth, pending = 0;
if ('ResizeObserver' in window) {
new ResizeObserver(function () {
if (!root.clientWidth || root.clientWidth === lastW || pending) return;
pending = requestAnimationFrame(function () { pending = 0; lastW = root.clientWidth; build(); });
}).observe(root);
}
build();
if (document.fonts && document.fonts.ready) document.fonts.ready.then(build);
}
function init() {
Array.prototype.forEach.call(document.querySelectorAll('.fx-0831-root'), setupRoot);
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init);
else init();
})();Cylinder Marquee 3D
A pure CSS 3D cylinder: N faces positioned with rotateY + translateZ, radius auto-computed. Continuous rAF rotation, inertial pointer drag, cosine attenuation on back faces, pause button. Flat scrolling row if the browser lacks transform-style: preserve-3d; reduced motion stops the spin and exposes ‹ › buttons.
💡 Perfect for: testimonial halls of fame, tech-stack showcases, client/partner carousels, portfolio skills sections.
Effect page →Text-Path Marquee
Seamless text marquee across three sinusoidal SVG paths — no canvas, no framework. The wave pulses in amplitude and drifts in phase; the cursor raises a local Gaussian bump that deforms the path in real time (lerp). Solid/outline track alternation for depth, pause on hover/focus plus an accessible button. Under prefers-reduced-motion: frozen paths, static text.
💡 Perfect for: animated landing-page heroes, wavy section headers, product-launch tickers, festival or concert stage badges.
Effect page →Live Ticker
Endless ticker of indicators that recycles its items; root.ltkTicker.push() updates a value with a green or red flash. Inertial drag, pause on hover, focus or button. Reduced motion: a still, scrollable list.
💡 Perfect for: stock quote bars, SaaS announcement strips (changelog, system alerts, product updates), live notifications, breaking-news tickers.
Effect page →Lens Marquee
Two text layers scroll in perfect sync: an always-visible monochrome outline layer and a gradient-filled layer revealed only through a glowing circular lens that follows the pointer — or sweeps on its own. Pause on hover/focus plus an accessible button; the fill stays visible if mask-image is unsupported, and the band freezes under prefers-reduced-motion.
💡 Perfect for: creative agency heroes, tech-stack showcases, premium product launches, brand identity pages.
Effect page →