
The elastic button
Buttons, Hover, Text
A mortgage calculator in a card: dragging the years, the monthly payment is recounted and a bar split in two shows how much of what you pay back is the loan and how much is interest. More years, lower payment and wider interest: you see it in one gesture.
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>
<!--
"Mortgage payment calculator" 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>Mortgage payment calculator with the years to drag and the share of interest that widens</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 mortgage calculator: dragging the years, the monthly payment is recounted and the bar shows how much of
what you pay back is the loan and how much is interest -->
<section class="mg" data-mg aria-label="Mortgage calculator">
<header class="mg__head">
<span class="mg__title">Monthly payment</span>
<span class="mg__terms" data-terms></span>
</header>
<p class="mg__pay"><b data-pay></b><i>a month</i></p>
<div class="split" aria-hidden="true"><span class="split__loan" data-loan></span><span class="split__int" data-int></span></div>
<div class="legend">
<span class="legend__item">Loan <b data-loanv></b></span>
<span class="legend__item legend__item--int">Interest <b data-intv></b></span>
</div>
<div class="yrs" data-yrs>
<div class="yrs__track" aria-hidden="true"><span class="yrs__fill" data-fill></span><span class="yrs__ticks" data-ticks></span></div>
<span class="yrs__thumb" data-thumb aria-hidden="true"><span class="yrs__bubble"><span data-years></span></span><span class="yrs__knob" data-knob></span></span>
<input class="yrs__input" data-input type="range" min="10" max="30" step="1" aria-label="Years to repay">
</div>
</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>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.
15 values to change
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 “Mortgage payment calculator” from Animorio and fit it into my sitePayment = loan × r / (1 − (1 + r)^−n), with r the monthly rate and n the months. From it the total interest (payment × n − loan) and the loan’s share of the total paid back, which is the width of the green piece.
Knob, payment and interest follow the finger with power3.out in 0.3 seconds, no spring: a number never overshoots. The split of the bar instead settles with back.out(2.2) in 0.7: that is where the motion tells the change.
A transparent input type=range covers the track; the drawn knob and tag sit in an element GSAP moves in x. aria-valuetext says years and payment.
| Name | File | Default | What it changes |
|---|---|---|---|
LOAN | script.js | 240000 | How much is borrowed, in euros. |
RATE | script.js | 3.6 | The fixed yearly rate, in percent (made up). |
YEARS | script.js | 25 | The years chosen at the start, from 10 to 30. |
ACCENT | script.js | #5ee6b0 | The colour of the loan in the bar. |
LOOP | script.js | true | Left alone, a pointer drags the years. |
On the site of a bank, a broker or an estate agency, on the page of a home for sale, in any simulator where one knob changes both the payment and the total cost (financing, leasing, long-term rentals).
The same card, as wide as the screen; the payment drops down to 38 pixels. The slider is dragged with a finger (touch-action: pan-y lets the page scroll vertically).
Numbers, bar and knob go straight to their value, with no counting and no bounces.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 4.6 KB; the libraries: GSAP 28 KB.
Tested on 16 November 2026
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.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.