Skip to content
animorio
IT
All components

Glass lens price slider

Sliders, Hover, PhysicsGSAP, CSS onlyMediumCompressed weight: Demo 10 KBGSAP 28 KBFreeDownload the zip

The price filter of Northvale, a made-up online shop of trail running shoes, in a white card from a premium shot. Over the chosen range sits a glass lens that runs from the price histogram down to the track, with the two handles at its corners: you can drag the handles one at a time, or grab the lens in the middle and slide the whole range at once, with a sheen that leans the way it goes. The bars inside light up orange with an elastic hop, the ones outside sink, Min, Max and the result count roll digit by digit, and the Show products button takes the number with a small swell and a light.

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>
<!--
  "Glass lens price slider" 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 price range slider with the glass lens that slides the range</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>
    <!-- the price filter of Northvale, an invented shop of trail running shoes: a histogram of the prices, a glass
         lens over the chosen range that can be grabbed and slid as a whole, two handles at its corners, rolling
         prices and the number of results that the Show button takes -->
    <section class="filter" aria-labelledby="f-title" data-card>
      <header class="filter__head">
        <div>
          <h2 class="filter__title" id="f-title">Price</h2>
          <p class="filter__sub">Northvale · Trail running shoes</p>
        </div>
        <button class="reset" type="button" data-reset>
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.6 6.4A4.8 4.8 0 1 1 3.4 9.6"/><path d="M3.2 3.4v3.2h3.2"/></svg>
          <span>Reset</span>
        </button>
      </header>

      <div class="range" data-range>
        <div class="bars" aria-hidden="true" data-bars></div>
        <div class="track" aria-hidden="true"><span class="track__fill" data-fill></span></div>
        <div class="lens" role="slider" tabindex="0" aria-label="Move the price range" data-lens>
          <span class="lens__glass" data-glass>
            <span class="lens__tint"></span>
            <span class="lens__sheen" data-sheen></span>
            <span class="lens__grip" aria-hidden="true"><i></i><i></i><i></i></span>
          </span>
        </div>
        <span class="thumb" role="slider" tabindex="0" aria-label="Minimum price" data-thumb>
          <span class="thumb__body" data-body><span class="thumb__core"></span></span>
        </span>
        <span class="thumb" role="slider" tabindex="0" aria-label="Maximum price" data-thumb>
          <span class="thumb__body" data-body><span class="thumb__core"></span></span>
        </span>
      </div>

      <div class="fields">
        <div class="field" data-field>
          <span class="field__key">Min</span>
          <span class="field__val">$<span class="roll" data-roll-lo></span></span>
        </div>
        <span class="fields__line" aria-hidden="true"></span>
        <div class="field" data-field>
          <span class="field__key">Max</span>
          <span class="field__val">$<span class="roll" data-roll-hi></span><span class="field__plus" data-plus>+</span></span>
        </div>
      </div>

      <button class="show" type="button" data-show>
        <span class="show__face" data-show-face>
          <span class="show__sweep" data-sweep aria-hidden="true"></span>
          <span class="show__words">Show&nbsp;<span class="roll" data-roll-count></span>&nbsp;<span data-noun>products</span></span>
          <svg class="show__chev" viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3.8 10.2 8 6 12.2"/></svg>
        </span>
      </button>
      <p class="sr" aria-live="polite" data-live></p>
    </section>

    <svg class="pointer" viewBox="0 0 24 24" aria-hidden="true" data-pointer>
      <path d="M5 3.2l13.6 8.3-6 1.2-3.1 5.6z"/>
    </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.

34 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 “Glass lens price slider” 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 a white ground there is a single white card with wide corners, its one pixel edge catching the light at the top, a soft layered shadow with a thread of orange and a very fine grain. At the top Price, under it Northvale · Trail running shoes, and on the right a small Reset with its round arrow. In the middle the histogram of the shoes in forty thin bars, taller where there are more models, and under it the thin track. Over the chosen range, from the top of the chart down to the track, sits a glass lens with rounded top corners, a veil of orange, a light edge, three small lines to grab it by and a slanted sheen; at its two lower corners the two white handles with an orange heart. When it opens the card rises, the bars grow from the middle outwards and the lens opens from the centre on a spring, lighting the bars it meets. Grabbed, a handle swells and takes an orange halo, and its field, Min or Max, lights up; dragged, it follows the finger on a spring, its heart stretching a little as it runs, and the lens widens or narrows with it. Grabbed in the middle, the lens lifts by two pixels and carries the whole range with it: both handles swell slightly, both fields light up together and the sheen leans and slides the way it goes, then drifts back to the centre. The bars coming into the range light up orange with an elastic hop, the ones leaving sink into grey. Min and Max roll like an odometer, and when the maximum reaches the end a plus appears. Let go, everything settles on a multiple of five with a small bounce and the black Show 128 products button takes the new number with a hair of a swell and an orange light running across it. Until someone touches it, a drawn pointer widens the maximum, narrows the minimum, grabs the lens and slides it left and right, then presses Reset.

How it works

Two values and two springs

Each handle has the finger’s value and the drawn one: on every frame of GSAP’s ticker a damped spring (stiffness and friction among the values) pulls the second towards the first, with the time step capped at 1/30 of a second. The numbers follow the finger; the handles, the lens and the bars follow the spring.

The lens that carries the range

The lens is a div laid between the two handles: its left and width come from the drawn values. Grabbed in the middle, it remembers the two starting values and moves both by the same distance, keeping the width and stopping at the ends of the scale. The sheen is a slanted band that shifts and tilts with the average speed of the two handles and drifts back to the centre by itself.

The bars coming in and going out

Each bar knows the price at its centre: when it passes in or out of the drawn values it changes class (colour in a CSS transition) and GSAP takes it to full height with an elastic.out or lowers it with a power3.out. The product count adds up the bars in proportion to how much of each one sits inside the range.

The rolling digits

Each digit is a column from 0 to 9 in a box 1ch wide with tabular figures: GSAP moves the column’s yPercent. Extra boxes shrink to zero width, so 95 and 115 stay centred with no leading zeros.

Values to change

NameFileDefaultWhat it changes
LOWESTscript.js40The lowest price on the scale, in dollars.
HIGHESTscript.js320The highest price on the scale, shown with a plus.
START_MINscript.js90Where the minimum sits when it opens.
START_MAXscript.js190Where the maximum sits when it opens.
STEPscript.js5How many dollars a handle moves by and the multiple it settles on.
GAPscript.js25The smallest distance between the two handles.
BARSscript.js40How many bars the histogram has.
TOTALscript.js438How many shoes the shop has in all.
STIFFNESSscript.js420The spring pulling the handles and the lens to the finger.
DAMPINGscript.js24Lower lets them pass the mark and come back.
SWELLscript.js1.22How much a grabbed handle swells.
SINKscript.js0.36How tall the bars outside the range stay.
SPEEDscript.js1The speed of the round on its own.
AUTOscript.jstrueThe drawn pointer that plays with the filter until someone touches it.
--accentstyle.css#ff5a1fThe orange of the lit bars, the track and the fields.
--buttonstyle.css#141414The colour of the Show products button.

Try them in the Playground

When to use it

In the filter column of an online shop (shoes, clothes, electronics, homes for sale), when the buyer wants to keep the same budget and move it up or down: with the lens it takes one gesture instead of moving two handles.

On phones

The card narrows to 90% of the screen and the chart gets shorter with the height of the box; the finger grabs the handles and the lens like the mouse, and a tap on the track brings the nearest handle there. Nothing scrolls sideways while dragging.

With reduced motion

No springs, hops or self-moving pointer: the card fades in with the range already in place, the handles follow the finger without bouncing, the bars change colour with a fade and the digits change without rolling.

Pitfalls

  • The ticker writes the handles’ transform on every frame: the press swell goes on the child (thumb__body), or GSAP and the ticker cancel each other.
  • The lens sheen must drift back to the centre even when the handles are still: the ticker keeps drawing until the sheen has arrived, otherwise it stayed tilted after letting go.
  • The hidden leading digits must shrink to zero width, not just turn transparent, or a two-digit price stays shifted by a space.
  • During the opening the bars grow with one group tween: the springs only start afterwards, because a bar's state change with auto overwrite would have stopped them halfway.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 10 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 components