188

Draw-a-Path Marquee

£7
or the whole Vault, £99
Open in new tab

Text marquee that follows any line the visitor draws. Draw with a mouse, pen or finger and the headline pours onto the stroke, banks through every curve letter by letter and loops along it, faster where the line was drawn fast.

advanced
10 more details
text-animationmarqueeinfinite-loopcurved-pathsvg-pathvelocity-reactivepointer-dragtouch-dragreduced-motionprogressive-enhancement

Released

About this effect

Draw-a-Path Marquee turns a headline into something the visitor steers. Draw any line on the stage, with a mouse, a pen or a finger, and the words start pouring onto it from where you started, chasing the pen tip as you draw. Let go and the stroke settles into a smooth curve while the text keeps looping along it as a marquee.

Read the full effect overview

Every letter is placed and rotated on its own, so the type banks through bends without bunching up on the inside of a curve or kinking at a sharp corner. The speed you drew at carries into the motion: a stretch drawn quickly runs faster and looser for a few seconds, a slowly drawn stretch runs slower, and then the whole line eases into a steady cruise. Draw a closed loop and the text joins round it without a seam; draw a new line and the text runs off the old one as it pours onto the new.

The demo opens with a wave already running, plus Ring and Spiral presets and Clear. It suits campaign heroes, event and festival pages, portfolio intros and any landing page that wants visitors to play with the headline rather than read past it.

Draw-a-Path Marquee - GSAP animation effect preview

What's included

14 items
  • Draw any line with a mouse, pen or finger and the headline pours onto it live, following the pen tip
  • On release the stroke is smoothed and sharp corners are rounded to a minimum radius set relative to the font size
  • Letters are placed and banked one by one with even tracking; bends that curl towards the letters are widened to fit the type instead of opening gaps
  • Drawing speed becomes marquee speed: the text runs faster while it crosses a stretch drawn fast, then eases to a steady cruise
  • Lines drawn right to left are turned round once, so most of the text reads upright; hand wobble on a straight stroke is ironed out
  • Open lines are always full of text end to end, entering and leaving with a short fade
  • Closed loops are detected and the text joins seamlessly all the way round
  • Drawing a new line runs the text off the old path while it pours onto the new one, never a hard cut
  • Wave, Ring and Spiral presets drawn by an animated pen, plus Clear; a preset is already running on load
  • Options for text, separator, speed, direction, smoothing, minimum bend radius and whether the stroke stays visible
  • Small JavaScript API (setPath, setText, clear, pause, play, revert) and a pathchange event with the smoothed path data
  • Taps and tiny twitches are ignored, so a stray click never wipes the running line
  • Touch drawing is limited to the stage, so the rest of the page still scrolls normally
  • Accessible: the headline is read once by screen readers, presets are native buttons, reduced motion lays the text still along the path, and without JavaScript the headline is plain text

Perfect for

5 use cases
  • Campaign and product-launch heroes that invite visitors to draw before they scroll
  • Festival, event and exhibition pages where a playful headline sets the tone
  • Creative studio and portfolio intros that show craft in the first interaction
  • Brand microsites and 404 pages that reward a moment of play
  • Workshops and education pages explaining paths, curves or typography

How it works

2 sections

The stage records the pointer while you draw and turns the rough stroke into a smooth path, rounding corners and dropping tiny loops that are too tight for the type to follow. Wobble shorter than a letter or two is ironed out, and bends that curl towards the letters are widened until the type fits them. Each letter is then placed individually along that path and turned to match the direction of the line under it, so the tracking stays even. A line drawn mostly right to left is turned round so the text reads upright.

The headline repeats along the path as a marquee driven by GSAP. The whole marquee speeds up while it crosses a stretch that was drawn quickly, and that response fades out over a few seconds into a steady cruise. A closed loop fits a whole number of repeats so the join is invisible. Glyph elements are reused rather than recreated, only transforms and opacity change each frame, and the animation sleeps when the stage is off screen or paused.

Difficulty Advanced
Includes HTML + JS + CSS source, documentation, AI setup prompt, lifetime updates

Lighthouse, as measured

Google Lighthouse on this effect's demo, from the latest scan. A measurement of the demo as shipped, not a promise for your page.

Accessibility
100
Best practices
100

No performance score, on purpose. That figure depends on how you deploy: your server's compression and caching, your CDN, the connection and the device doing the test, none of which the code controls. The same page can score very differently on two consecutive runs, so measure it where it will live.

The Vault opens this source and the whole library.

Each product gives you the HTML, CSS and JavaScript source, the full documentation and an AI setup prompt, licensed for unlimited personal and commercial projects. Every paid product is tested for desktop and mobile layouts, reduced-motion handling, animation cleanup and keyboard controls wherever there is something to operate.

One payment, over 350 products, and future additions to the library.

Documentation

Quick Start

1. Add to your HTML <head>:

In your downloadThe working code for this step, in index.html.

2. Add before the closing </body> tag:

In your downloadThe working code for this step, in index.html.

3. Add the effect HTML anywhere in your <body>:

In your downloadThe working code for this step, in index.html.

Give the stage a height (the demo makes it fill the viewport under the control row). Everything else is generated by the script.

Using It With Your Own Design

What the effect needs from your markup: a container with data-path-marquee, a stage inside it with data-path-marquee-stage (the drawing surface), and the headline inside the stage with data-path-marquee-text. The script reads the headline's text (or data-text) and creates the SVG stroke layer, the glyph layer and the pen dot inside the stage. Preset and clear buttons are optional: any element inside the container with data-path-preset="wave|ring|spiral" or data-path-clear is wired up, and preset buttons get aria-pressed kept in sync. Several containers on one page each run independently.

Spacing: letters are spaced evenly along the curve at half their cap height, plus a small extra tracking of 0.03em, so tight bends never make letters touch and never open gaps that read as spaces.

What is only the demo's styling: the Anton and Archivo fonts, the grey ground, the pill buttons, the cue line, the hairline under the control row and the full-viewport layout. Change --marquee-size to set the type size (the script reads the computed value, so a clamp() works and a resize relays the text), set the type face on .path-marquee__glyphs, the accent on --accent and the guide stroke on --guide. Use any font: condensed faces fit more text on a short stroke.

CSS the effect depends on:

  • .path-marquee__stage needs position: relative, a real height and touch-action: none. Keep touch-action: none on the stage only, so a finger draws there while the rest of the page still scrolls. overflow: hidden keeps letters near the edges from widening the page.
  • .path-marquee__glyphs sets the font, size and colour of the moving letters; keep line-height: 1 and pointer-events: none.
  • .path-marquee__glyph must stay position: absolute; left: 0; top: 0; transform-origin: 0 0; white-space: pre. Every letter is positioned by a single transform.
  • .has-js .path-marquee__text visually hides the headline once the script runs; it stays in the accessibility tree. Without JavaScript (or if GSAP fails to load, which removes .has-js) the headline shows as normal type.

Options

Set these on the [data-path-marquee] container.

Attribute Values Default Description
data-text Any text Headline text Text to run along the path. Falls back to the data-path-marquee-text element.
data-separator Any text • Placed between repeats of the text.
data-speed Number, 0 or more 1.5 Cruise speed in font sizes per second.
data-direction forward, reverse forward forward runs from where the line started towards where it ended.
data-smoothing 0 to 1 0.5 How much of the hand's wobble is smoothed out, relative to the font size. 0 follows the hand closely; at the default a wobbly straight line comes out straight.
data-min-radius Number (0.3 to 4) 1.5 Tightest outward bend allowed, as a multiple of the font size. Bends that curl towards the letters are widened further, to a radius worked out from the font's cap height and widest letter (about 4 font sizes for Anton), so neighbouring letters never touch.
data-upright auto, off auto auto turns a line drawn mostly right to left round, once for the whole line, so most of the text reads upright (the text then travels the other way). Closed loops are turned so the text rides round the outside. off keeps every line exactly as drawn.
data-keep-stroke true, false true Keep a faint guide line under the text after release.
data-preset wave, ring, spiral, none wave Path drawn on load, so the stage is never empty. ring is a closed oval with the text riding its outside. none starts empty.

Accessibility

  • Screen readers: the headline is read once from the data-path-marquee-text element; every moving letter is an aria-hidden copy.
  • Keyboard: presets and Clear are native buttons with visible focus and aria-pressed state. Drawing is a pointer gesture; keyboard users get the same result from the presets, and you can add your own buttons that call setPath().
  • Touch: draw with one finger on the stage. Only the stage blocks scrolling, so the page around it scrolls normally.
  • Reduced motion: with prefers-reduced-motion: reduce the text sits still along the path with no travel, pouring or speed changes. Drawing still works and lays the text on the new line when you let go. Switching the preference while the page is open keeps the current line.
  • No JavaScript: the headline renders as plain, large text and the controls are hidden.

Performance

Letter elements are pooled and reused, and only transform and opacity change while it runs. The animation sleeps when the stage scrolls out of view, when paused, and under reduced motion once a line is laid.

Dependencies

Required:

  • GSAP 3.12+ (core only; the demo pins 3.15.0)

No GSAP plugins and no smooth-scroll library are needed.

Also in your download: the full source, worked examples, the events and programmatic API, and the class reference.

£7