Skip to content
animorio
IT
Back to the library

Library loans timeline

Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 5.2 KBGSAP 28 KBFreeDownload the zip

The loans page of a library: three books, each with a bar running from today to its due date on a shared line of four weeks. The one due in two days is orange. Renewing it, the bar runs two weeks further and settles, the days count, the orange turns blue and the button says “Renewed”.

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>
<!--
  "Library loans timeline" 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>Library loans with the due dates on the line of days and the renewal that moves them</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">
    <!-- the loans page of a public library: each book has a bar from today to its due date on a shared line of four
         weeks; renewing pushes the bar two weeks further, the days count up and the warning colour goes away -->
    <section class="lib" data-lib aria-label="Your loans">
      <header class="lib__head">
        <span class="lib__title">Your loans</span>
        <span class="lib__brand">Alder Library</span>
      </header>
      <div class="lib__weeks" aria-hidden="true"><span>Today</span><span>1 week</span><span>2 weeks</span><span>3 weeks</span></div>
      <div class="lib__rows" data-rows>
        <div class="lib__grid" aria-hidden="true"><i></i><i></i><i></i><i></i></div>
      </div>
      <p class="sr" data-live aria-live="polite"></p>
    </section>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></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.

18 values to change

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 “Library loans timeline” 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 warm white, a white card: at the top “Your loans” and the library’s name, then the four weeks (Today, 1 week, 2 weeks, 3 weeks) with a thin rule for each that runs through all the rows. Each book has its drawn cover, title and author, a “Renew” button and below it a bar that starts at today’s rule and ends at the due date, with “Due in 2 days” next to it. On opening the bars grow from today. On hover the cover leans and lifts. Pressing “Renew” the bar stretches by fourteen days with a small bounce and swells for a moment, the days count up to 16, the colour goes from orange to blue, the cover hops and the button rolls to “Renewed” and switches off. The third book is reserved by another reader: its button says “Reserved” and it cannot be renewed.

How it works

One variable per row

Each row has a CSS variable --d with the days to the due date: the bar’s width and the label’s position are calc(var(--d) / 28 * 100%). The script animates a number and writes it into the variable: bar, label and count stay together.

The renewal

The number goes from 2 to 16 with back.out(1.25): the bar slightly passes the new due date and comes back. Meanwhile scaleY goes to 1.6 and back with elastic.out. Below SOON days the row has the class that gives it the warning colour.

The shared line

The week rules are a four-column grid absolutely positioned behind the rows, starting where the bars start: so the due dates of different books compare at a glance.

Values to change

NameFileDefaultWhat it changes
EXTRAscript.js14By how many days the renewal moves the due date.
SOONscript.js3Below how many days the due date takes the warning colour.
ACCENTscript.js#3457d5The colour of the loans with time left.
WARNscript.js#e07a1fThe colour of those due soon.
SLIDEscript.js0.9How many seconds the bar takes to stretch.
HOLDscript.js2.2Alone: how many seconds the renewals stay before starting over.
LOOPscript.jstrueLeft alone, a pointer renews two books.

Try them in the Playground

When to use it

In a library’s reader area, in a reading or rental app, in any list of things with a deadline that can be moved (subscriptions, rentals, free trials, paperwork).

On phones

The same card, as wide as the screen; title and author are cut with an ellipsis, the button stays whole. Past three weeks the due label moves above the end of the bar so it does not leave the card.

With reduced motion

The bars are already at their size; on renewal bar, days and colour change at once and the button says “Renewed” without rolling.

Pitfalls

  • A due date 23 days away would put the label outside the card: past 19 days it moves above the bar, right-aligned to its end.
  • The disabled button has its colour written in the CSS: otherwise it takes the browser’s grey.
  • The week rules sit behind: the title has a fading white background that covers them only where there is text.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 16 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