cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="outer">
  <div class="inner">
    <ul>
      <li>SweeTango </li>
      <li>Pacific Rose</li>
      <li>SnapDragon</li>
      <li>Envy</li>
      <li>Koru (Plumac)</li>
      <li>Pink Lady (Cripps Pink)</li>
      <li>Honeycrisp</li>
      <li>Royal Gala</li>
      <li>Macoun</li>
      <li>McIntosh</li>
      <li>Autumn Glory</li>
      <li>Opal</li>
      <li>Rome</li>
      <li>Red Delicious</li>
      <li>Golden Delicious</li>
      <li>Cameo</li>
      <li>Granny Smith</li>
      <li>Rainier Gala</li>
      <li>SweeTango </li>
      <li>Pacific Rose</li>
      <li>SnapDragon</li>
      <li>Envy</li>
      <li>Koru (Plumac)</li>
      <li>Pink Lady (Cripps Pink)</li>
      <li>Honeycrisp</li>
      <li>Royal Gala</li>
      <li>Macoun</li>
      <li>McIntosh</li>
      <li>Autumn Glory</li>
      <li>Opal</li>
      <li>Rome</li>
      <li>Red Delicious</li>
      <li>Golden Delicious</li>
      <li>Cameo</li>
      <li>Granny Smith</li>
      <li>Rainier Gala</li>
      <li>SweeTango </li>
      <li>Pacific Rose</li>
      <li>SnapDragon</li>
      <li>Envy</li>
      <li>Koru (Plumac)</li>
      <li>Pink Lady (Cripps Pink)</li>
      <li>Honeycrisp</li>
      <li>Royal Gala</li>
      <li>Macoun</li>
      <li>McIntosh</li>
      <li>Autumn Glory</li>
      <li>Opal</li>
      <li>Rome</li>
      <li>Red Delicious</li>
      <li>Golden Delicious</li>
      <li>Cameo</li>
      <li>Granny Smith</li>
      <li>Rainier Gala</li>
      <li>SweeTango </li>
      <li>Pacific Rose</li>
      <li>SnapDragon</li>
      <li>Envy</li>
      <li>Koru (Plumac)</li>
      <li>Pink Lady (Cripps Pink)</li>
      <li>Honeycrisp</li>
      <li>Royal Gala</li>
      <li>Macoun</li>
      <li>McIntosh</li>
      <li>Autumn Glory</li>
      <li>Opal</li>
      <li>Rome</li>
      <li>Red Delicious</li>
      <li>Golden Delicious</li>
      <li>Cameo</li>
      <li>Granny Smith</li>
      <li>Rainier Gala</li>
    </ul>
    <div class="notch"></div>
  </div>
</div>
            
          
!
            
              :root {
  --width: 494px;
  --height: 242px;
  --chrome: 22.5px;
  --outer-border-radius: 25px;
  --thumb-radius: 0px;
}

html {
  box-sizing: border-box;
}

* {
  box-sizing: inherit;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  background: radial-gradient(turquoise, midnightblue);
  font-weight: lighter;
  font-size: 10px;
}

.outer {
  position: relative;
  margin: 0 auto;
  width: var(--width);
  height: var(--height);
  border-radius: var(--outer-border-radius);
  border: solid 2px buttonface;
  display: flex;
  align-items: center;
  
  background: black;
}

.inner {
  background: white;
/*   position: absolute; */
  margin: 0 auto;
  width: calc(100% - var(--chrome));
  height: calc(100% - var(--chrome));
  border-radius: calc(var(--chrome) - 10px);
  overflow-y: scroll;
  overflow-x: hidden;
}

.notch {
  position: absolute;
  background: black;
  width: 3%;
  height: 60%;
  top: 20%;
  left:calc(var(--chrome)/2);
  border-radius: 0 10px 10px 0;
}

ul {
  padding-left: calc(var(--chrome)/4);
  padding-right: 10px;
  margin: 5px 0;
  overflow: hidden;
}

li {
  list-style: none;
  padding: 5px 5px;
  border-bottom: 1px solid #dadada;
  transform-origin: center left;
}

*::-webkit-scrollbar { 
  width: 5px;
  padding: 100px;
  transform: scalex(10);
}

*::-webkit-scrollbar-thumb {
  border-radius: var(--thumb-radius);
  background-color: #5555;
  padding-right: 5px;
  transform: scalex(10);
}
            
          
!
            
              console.clear();

const THRESH = 10;

const $ = selector => document.querySelector(selector);
const $$ = selector => document.querySelectorAll(selector);

const items = $$("li");
const style = getComputedStyle(document.body);
// const chromeWidth = style.getPropertyValue("--chrome");
const chromeWidth = 22.5;

/*
THIS WAS WRONG! It just wasn't being used! Thanks @drmercer 🎉

WRONG:
const setCustomProperty = (property, value) => {
  style.setProperty("--${property}", value);
};

RIGHT:
const setCustomProperty = (property, value) => {
  style.setProperty(`--${property}`, value);
};
*/

let notchRect = $(".notch").getBoundingClientRect();

window.addEventListener("resize", () => {
  notchRect = $(".notch").getBoundingClientRect();
});

bumpItems();

$(".inner").onscroll = onScroll;

function onScroll(e) {
  window.requestAnimationFrame(bumpItems);
}

function bumpItems() {
  for (let item of items) {
    const itemRect = item.getBoundingClientRect();
    const distFromBottom = itemRect.top - notchRect.bottom;
    const distFromTop = itemRect.bottom - notchRect.top;

    if (Math.abs(distFromTop) < THRESH) {
      item.style.transform = `translateX(${lerp(
        0,
        chromeWidth,
        (distFromTop + THRESH) / (THRESH * 2)
      )}px)`;
    } else if (
      distFromTop > 0 &&
      Math.abs(distFromBottom) > THRESH &&
      distFromBottom < 0
    ) {
      item.style.transform = `translateX(${chromeWidth}px)`;
    } else if (Math.abs(distFromBottom) < THRESH) {
      item.style.transform = `translateX(${lerp(
        chromeWidth,
        0,
        (distFromBottom + THRESH) / (THRESH * 2)
      )}px)`;
    } else {
      item.style.transform = `translateX(0)`;
    }
  }
}

function lerp(v0, v1, t) {
  return v0 * (1 - t) + v1 * t;
}

            
          
!
999px
Loading ..................

Console