VibeFX
Live preview · fully interactive

The prompt

Build a magnetic dot trail that follows the pointer.

## Look
Twelve 14px circles, background #7c6cff, on #08080d. Each later dot is slightly smaller and more transparent.

## Behavior
Each dot lerps 35% of the way toward the previous dot every frame, so the chain lags and bends. Until the user moves, drive the head with a slow orbit.

## Design tokens
- Page #08080d; dots #7c6cff; hint #8a8a99.

## Motion
- Lerp factor 0.35 per frame, about a 180ms visual lag on the tail. No duration tween.

## Constraints
- Single self-contained HTML file. No libraries.
- Honor prefers-reduced-motion: reduce by skipping the loop and leaving a readable static frame
- Readable at 390px width with no horizontal page scroll

The code

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body { min-height: 100%; }
  body {
    background: #08080d; color: #f2f2f7; font-family: Inter, system-ui, sans-serif;
    min-height: 100vh; overflow: hidden;
  }
  .hint { position: absolute; left: 16px; top: 16px; z-index: 5; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #8a8a99; }
  .dot { position: fixed; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #7c6cff; pointer-events: none; }
  @media (max-width: 420px) {
    .hint { font-size: 10px; letter-spacing: 0.08em; }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  }
</style>
</head>
<body>
<p class="hint">Move around</p><div id="dots"></div>

<script>

  var reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
  var pointer = { x: window.innerWidth / 2, y: window.innerHeight / 2 };
  var userMoved = false;
  window.addEventListener("pointermove", function (e) {
    userMoved = true;
    pointer.x = e.clientX;
    pointer.y = e.clientY;
  });
  function idlePointer(now) {
    if (userMoved || reduce) return;
    pointer.x = window.innerWidth * (0.5 + Math.cos(now / 700) * 0.28);
    pointer.y = window.innerHeight * (0.5 + Math.sin(now / 900) * 0.2);
  }

  var n = 12;
  var nodes = [];
  var root = document.getElementById("dots");
  for (var i = 0; i < n; i++) {
    var el = document.createElement("div");
    el.className = "dot";
    el.style.opacity = String(1 - i / (n + 1));
    el.style.transform = "scale(" + (1 - i * 0.05) + ")";
    root.appendChild(el);
    nodes.push({ el: el, x: pointer.x, y: pointer.y });
  }
  function frame(now) {
    if (reduce) return;
    idlePointer(now);
    var prevX = pointer.x, prevY = pointer.y;
    for (var i = 0; i < nodes.length; i++) {
      var node = nodes[i];
      node.x += (prevX - node.x) * 0.35;
      node.y += (prevY - node.y) * 0.35;
      node.el.style.left = node.x + "px";
      node.el.style.top = node.y + "px";
      prevX = node.x; prevY = node.y;
    }
    requestAnimationFrame(frame);
  }
  requestAnimationFrame(frame);
</script>
</body>
</html>

About this effect

A delayed follow trail. Each dot lerps toward the previous one, so the chain bends when the pointer turns. Built for hero backgrounds and empty states.

Similar effects