explaingit

maxwellito/vivus

15,477JavaScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

A tiny zero-dependency JavaScript library that animates SVG images to look like they are being drawn by hand, tracing each stroke one at a time with built-in styles like delayed, sync, or one-by-one.

Mindmap

mindmap
  root((vivus))
    What it does
      SVG draw animation
      Stroke-by-stroke reveal
      No dependencies
    Animation styles
      Delayed start
      Sync all paths
      OneByOne drawing
    How it works
      strokeDashoffset CSS
      JavaScript loop
      Pathformer converter
    Use cases
      Landing page logos
      Portfolio intros
      Icon animations
    Audience
      Frontend developers
      Web designers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add a hand-drawn drawing animation to a logo or icon on a website landing page.

USE CASE 2

Create an animated SVG illustration that traces itself stroke by stroke for a portfolio or intro sequence.

USE CASE 3

Export a CSS-only animated SVG using the companion Vivus Instant tool without writing any JavaScript.

Tech stack

JavaScriptCSSSVG

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

Vivus is a small JavaScript library that makes an SVG image appear as if it is being drawn by an invisible pen. An SVG is an image file built from mathematical descriptions of lines and shapes rather than pixels, which is what makes the trick possible, Vivus can trace those lines one stroke at a time and reveal the picture as the strokes are drawn. The library has no dependencies, so you only need to include the script in your page. There are several built-in animation styles. The default, "delayed", starts every line at almost the same moment but with a small offset. "Sync" starts and finishes every line at the same time. "OneByOne" draws each line in turn, with a length-based duration so the pen moves at a constant speed and the effect looks closest to live handwriting. Under the hood Vivus relies on a CSS property called strokeDashoffset that controls how much of a path's outline is visible, a JavaScript loop changes that value over time to produce the drawing effect. Because strokeDashoffset only works on path elements, the library ships with a class called "pathformer" that converts other SVG shapes, circles, rectangles, lines, polylines, into paths so they can be animated. Your SVG paths need a stroke and no fill, and hidden paths or text elements should be removed first. You would use Vivus to add a hand-drawn flourish to a logo, illustration, icon, or any decorative SVG on a website, common touches for landing pages and intros. It can be installed via npm, Bower, or popular CDNs, and a companion tool called Vivus Instant lets you export a CSS-only animated SVG without writing JavaScript. The full README is longer than what was provided.

Copy-paste prompts

Prompt 1
I have an SVG logo I want to animate as if it's being drawn. Write the JavaScript to set up Vivus on it with the OneByOne style and a speed of 200.
Prompt 2
My SVG has circle and rect elements that aren't animating with Vivus. Show me how to use the Pathformer class to convert them to paths before animating.
Prompt 3
Write a Vivus setup that animates an SVG with the delayed style and calls a callback function when the drawing finishes.
Prompt 4
I want to animate an SVG only after the user scrolls it into view. Show me how to trigger Vivus programmatically on a scroll event.
Open on GitHub → Explain another repo

← maxwellito on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.