Skip to content
animorio
IT
All components

Corner radius scrubber

Counters, HoverGSAP, CSS onlyMediumCompressed weight: Demo 7.3 KBGSAP 28 KBFreeDownload the zip

One field, one gesture, in the clean style of product interface pieces: the corner radius in the inspector of a design app, scrubbed sideways as in the real tools. As you drag, the digits roll, a thin ruler slides in underneath and the square above rounds its corners on a spring; pulled hard, the number widens and leans, and past the limit the field resists like a rubber band.

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>
<!--
  "Corner radius scrubber" 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>The corner radius counter you drag sideways, with a sliding ruler</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" data-stage>
    <!-- one field of a design tool's inspector: drag sideways on it and the radius changes,
         the digits roll, a thin ruler slides underneath and the shape above follows -->
    <div class="inspector" data-inspector>
      <svg class="shape" data-shape viewBox="0 0 140 140" aria-hidden="true">
        <path class="shape__fill" data-shape-fill></path>
        <path class="shape__corner" data-shape-corner></path>
      </svg>

      <div class="field" data-field role="spinbutton" tabindex="0" aria-label="Corner radius" aria-valuemin="0" aria-valuemax="48" aria-valuenow="12">
        <span class="field__face" data-face></span>
        <svg class="field__icon" data-icon viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 12.5V8a4.5 4.5 0 0 1 4.5-4.5h4.5"></path></svg>
        <span class="field__num" data-num></span>
        <span class="field__unit">px</span>
        <svg class="field__hint field__hint--l" data-hint-l viewBox="0 0 8 10" aria-hidden="true"><path d="M5.5 2 2.5 5l3 3"></path></svg>
        <svg class="field__hint field__hint--r" data-hint-r viewBox="0 0 8 10" aria-hidden="true"><path d="M2.5 2l3 3-3 3"></path></svg>
      </div>

      <div class="ruler" data-ruler aria-hidden="true">
        <svg class="ruler__tape" data-tape><path class="ruler__ticks" data-ticks></path><path class="ruler__major" data-major></path></svg>
        <span class="ruler__mark"></span>
      </div>
    </div>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true">
      <path class="ghost__arrow" d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path>
      <path class="ghost__scrub" transform="translate(-6.5 -8.5)" d="M2.5 12h19M6.5 8 2.5 12l4 4M17.5 8l4 4-4 4"></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.

15 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 “Corner radius scrubber” 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 white, alone in the middle, there is a square with a thin dark outline and under it the corner radius field, light grey, with a corner icon, the number 12 and «px». With the mouse over it the cursor becomes the sideways double arrow and two small chevrons slide out of the field with a pixel of bounce. On press the field lightens and gives a little; dragging sideways changes the number one pixel at a time and the digits roll up or down with the direction, while underneath a ruler of thin ticks lights up and slides under a blue mark held in the middle: every eight pixels a longer tick, and the blue mark hops. The square above rounds its four corners on a spring, with the top-left corner drawn again in blue. Pulled hard, the number widens on the width axis and leans with the gesture, then straightens as the hand slows down. Past 0 or 48 the field follows the hand by a few pixels, less and less, the ruler goes a little past its end and the number flashes blue; let go, everything springs back into place and the ruler fades out. It also works with the arrow keys. Until someone touches it, a drawn pointer uses it by itself.

How it works

Dragging in pixels

On pointerdown the field captures the pointer (setPointerCapture) and remembers the starting x and value; on every pointermove the raw value is the start plus the movement divided by PX_PER_STEP, rounded and clamped between 0 and the maximum. That way the hand can leave the field without losing the gesture.

Springs in a single ticker

The square’s radius, the ruler’s position, the field’s offset past the limits and the strength of the pull are four springs damped just under critical, computed in one gsap.ticker with the step capped at 1/30 of a second; once they all rest the ticker removes itself and nothing is redrawn.

The rubber band at the limits

Past the limit the field moves by one minus e to the minus effort, times 14 pixels: it follows the hand less and less and never goes further. The ruler runs a couple of ticks past its end on the same curve, and on release everything springs back to the true value.

The number that widens

The pointer’s speed, smoothed on every move and decayed when the hand stops, becomes the strength of the pull: on Mona Sans’s wdth axis the number goes from 100 to 124 and leans a few degrees with the gesture. It is a spring too, so it straightens with a small settle.

Rolling digits

Each digit sits in a one-line window with hidden overflow: the old one leaves up or down depending on the direction, the new one comes in from the other side with back.out. While dragging the roll is shorter, so the digits keep up with a fast hand.

Values to change

NameFileDefaultWhat it changes
STARTscript.js12The radius at the start, in pixels.
MAXscript.js48The largest radius: past it, the field resists like a rubber band.
PX_PER_STEPscript.js4How many pixels of dragging for one pixel of radius.
TICKscript.js6The gap between two ticks of the ruler.
STRETCHscript.js1How much the number widens and leans when pulled hard: 0 never, 2 twice as much.
SPRINGscript.js1How springy the shape and the return are: 0.4 calm, 2 very bouncy.
ACCENTscript.js#3b5bfdThe colour of the corner, the ruler mark and the flash at the limits.
AUTOscript.jstrueThe field uses itself until someone touches it.

Try them in the Playground

When to use it

For the number fields of an editor, a configurator or a settings panel (radius, opacity, spacing, size): you adjust it with a gesture, without typing, and the ruler tells you where you are.

On phones

On the phone you drag with a finger (touch-action: none on the field, so the page does not scroll); the square takes its size from the shorter side of the screen and the field from the width. There is no hover, everything else is the same.

With reduced motion

No springs, leaning or rubber band: the square takes the new radius at once, the digits and the ruler change with a fade.

Pitfalls

  • Without setPointerCapture, leaving the field with a fast gesture stopped the drag halfway: once captured, the field receives the moves even outside its edges.
  • The speed measured only in pointermove stayed high when the hand stopped suddenly, and the number stayed wide: in the ticker, if no move arrives for 60 milliseconds, the speed decays.
  • The spring radius can go below zero when it bounces: an SVG arc with a negative radius draws crooked, so in the path the radius is clamped between 0 and half the side.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 31 October 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 components