๐Ÿงบ

Scroll Animation for Ecwid Stores

Ecwid embeds into any website, so you can add scroll animation either to your host site (around the Ecwid widget) or via Ecwid's custom HTML support.

Manual Implementation
38 lines
// Manual scroll animation on Ecwid โ€” 47+ lines before mobile
const canvas = document.getElementById('scroll-canvas');
const ctx = canvas.getContext('2d');
const frames = [];
let currentFrame = 0;

async function preloadFrames(count) {
  await Promise.all(Array.from({ length: count }, (_, i) => {
    const img = new Image();
    const padded = String(i).padStart(4, '0');
    img.src = `https://your-cdn.com/frames/frame-${padded}.jpg`;
    frames.push(img);
    return new Promise((r) => { img.onload = r; img.onerror = r; });
  }));
}

function drawFrame(index) {
  if (!frames[index]) return;
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  ctx.drawImage(frames[index], 0, 0, canvas.width, canvas.height);
}

window.addEventListener('scroll', () => {
  const rect = canvas.parentElement.getBoundingClientRect();
  const scrolled = -rect.top;
  const total = rect.height - window.innerHeight;
  const progress = Math.max(0, Math.min(1, scrolled / total));
  const frameIndex = Math.floor(progress * (frames.length - 1));
  if (frameIndex !== currentFrame) {
    currentFrame = frameIndex;
    requestAnimationFrame(() => drawFrame(currentFrame));
  }
}, { passive: true });

// Still needed: resize handler, mobile touch events,
// Safari canvas fix, host site theme injection,
// CDN setup for 120+ JPEG files, lazy loading...
preloadFrames(120).then(() => drawFrame(0));

Adding Scroll Animation to Ecwid

Place the ScrollerSites embed on your host page above or below the Ecwid widget. For storefront-internal placement, use Ecwid's custom HTML field in the design panel.

  • โ— Add scroll animation to your homepage above the Ecwid product grid
  • โ— Use it on landing pages that drive traffic to specific Ecwid SKUs

Ready to Add Scroll Animation?

Pair scroll animation with your Ecwid storefront to make every product page feel premium.

Get Started Free โ†’

Related Platform Guides

Related Articles