Scroll Animation for Squarespace Commerce

Squarespace Commerce supports Code Blocks on any page. Paste the ScrollerSites embed snippet to add scroll-driven animation to your storefront.

Manual Implementation
38 lines
// Manual scroll animation on Squarespace — 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, Squarespace Code Injection injection,
// CDN setup for 120+ JPEG files, lazy loading...
preloadFrames(120).then(() => drawFrame(0));

Adding Scroll Animation to Squarespace Commerce

Open the Squarespace editor, add a Code Block to any section, and paste the ScrollerSites snippet. The animation plays as visitors scroll past — no custom CSS or JavaScript required.

  • Use a Code Block on your homepage hero
  • Add it to product landing pages built with Squarespace pages

Ready to Add Scroll Animation?

Add scroll animation to Squarespace Commerce without leaving the Squarespace editor.

Get Started Free →

Related Platform Guides

Related Articles