Skip to content
animorio
IT
Back to the library

Document scanner

SVG, TransitionsGSAP, CSS onlyAdvancedCompressed weight: Demo 6.2 KBGSAP 28 KBFreeDownload the zip

A phone’s document scanner: in the viewfinder a sheet photographed askew on a dark desk. Tap the shutter and the yellow outline leaves the frame and snaps onto the sheet’s four corners, a line of light reads it from top to bottom and the ink turns crisp as it passes; then the sheet straightens, turns clean white and shrinks towards the pile, which counts one more page.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Document scanner" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Document scanner</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- a document scanner: the sheet is photographed askew, the outline finds its four corners,
         a line reads it, then the sheet straightens, turns clean white and goes onto the pile -->
    <section class="ds" data-ds data-state="idle" aria-label="Document scanner">
      <div class="ds__view">
        <svg viewBox="0 0 300 220" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
          <g data-sheet>
            <polygon class="ds__shadow" data-shadow points=""></polygon>
            <polygon class="ds__paper" data-paper points=""></polygon>
            <g class="ds__ink" data-ink></g>
          </g>
          <polygon class="ds__outline" data-outline points=""></polygon>
          <g class="ds__corners" data-corners><circle r="4.500"></circle><circle r="4.500"></circle><circle r="4.500"></circle><circle r="4.500"></circle></g>
          <line class="ds__beam" data-beam x1="0" y1="0" x2="0" y2="0"></line>
        </svg>
        <span class="ds__hint"><span data-outhint>Point at a document</span></span>
      </div>
      <div class="ds__row">
        <span class="ds__tray"><i data-tray></i><span class="ds__count"><span data-outcount>2 pages</span></span></span>
        <button class="ds__shutter" type="button" data-btn aria-label="Scan the document"><i></i></button>
        <span class="ds__mode">Auto</span>
      </div>
    </section>
    <span class="live" aria-live="polite" data-live></span>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></path></svg>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

12 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Document scanner” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On black, a camera viewfinder: a dark desk seen from above with a paper-coloured sheet on it, askew and in perspective, with a title, a few lines and a box near the bottom; at the top a tag says “Point at a document”. Below, on the left the pile of pages already scanned with its count, in the middle the round shutter, on the right “Auto”. Tap the shutter and the circle turns yellow while the tag rolls to “Hold steady”: a yellow outline with four small rings at its corners leaves the viewfinder’s frame and snaps onto the sheet’s corners, one after the other, on a spring. Then “Reading the page”: a line of yellow light runs down the sheet following its slant, and the lines it has passed turn into crisp black ink. Then “Straightening”: the sheet straightens into a rectangle in the middle and the paper lightens to white, the outline follows it and lets go. Finally the sheet shrinks towards the bottom left corner, the pile below gives a start and the count rolls to “3 pages”, and a new sheet appears in the viewfinder, askew in another way.

How it works

One sheet, four corners

The sheet is an SVG polygon described by eight numbers, the coordinates of its corners. Every line of text is written in the sheet’s own coordinates, from 0 to 1, and laid down by blending the four corners: move the corners and all the content follows the perspective.

The outline and the line

The outline has its own eight numbers, starting from the viewfinder’s frame and reaching the sheet’s on a spring, one corner after the other. The line of light is the segment between the sheet’s left and right edges at a height going from 0 to 1.

Straightening

GSAP takes the sheet’s eight numbers to those of an upright rectangle in the middle, while another number lightens the paper from the photo’s warm grey to white. Then the same numbers go to a tiny rectangle in the corner, and the count goes up.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#ffcf33The colour of the outline that finds the sheet and of the line that reads it.
SWEEPscript.js1.1How many seconds the line takes to read the sheet from top to bottom.
FLATscript.js0.7How long the sheet takes to straighten.

Try them in the Playground

When to use it

On the page of an app that scans receipts, contracts or notes; at a bank or an insurer, where a document has to be photographed; in the guide to a new feature. The same four-corner sheet serves to straighten a whiteboard, a business card, a receipt.

On phones

The piece is at most 312 pixels wide; the viewfinder is 228 tall and gets lower on low screens, the drawing filling it by cropping the sides. The shutter is a 58 pixel circle.

With reduced motion

No snapping outline and no running line: on tap the sheet is at once straight, white and readable, the pile counts one more page and after a moment the new sheet fades in. The demo’s pointer does not start.

Pitfalls

  • GSAP takes an array for a list of targets: the corners’ eight numbers live in plain objects with keys 0 to 7, otherwise they do not animate.
  • Blending the four corners is not true perspective: for a slightly tilted sheet the eye does not notice, for a very oblique one a matrix would be needed.
  • The viewfinder is a drawing: the capture, the outcome and the page count are told in words in an aria-live region.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.2 KB; the libraries: GSAP 28 KB.

Testing

Tested on 26 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations