scroll falloff

by phloe

HTML

<div id="container"></div>

CSS

body {
  margin: 0;
  overflow: hidden;
}
#container {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  margin: 0;
  width: calc(100% + 100px);
  perspective: 1000px;
  transform-style: preserve-3d;
  _perspective-origin: 50% 50%;
  overflow-x: hidden;
  overflow-y: scroll;
  margin-right: -100px;
  -webkit-overflow-scrolling: touch;
	-ms-overflow-style: -ms-autohiding-scrollbar;
  height: 100vh;
}

ol {
  list-style: none;
  margin: 0;
  padding: 0;
  transform-style: preserve-3d;
}

ol:nth-of-type(1) {
  transform: scale(3) translateX(-31.5vw) translateZ(-2000px);
}

ol:nth-of-type(2) {
  transform: scale(2.5) translateX(-21.325vw) translateZ(-1500px);
}

ol:nth-of-type(3) {
  transform: scale(2) translateX(-11.9vw) translateZ(-1000px);
}

ol:nth-of-type(4) {
  transform: scale(1.5) translateX(-4vw) translateZ(-500px);
}

ol:nth-of-type(5) {
  transform: scale(1) translateZ(0px);
}

ol:nth-of-type(6) {
  transform: scale(1.5) translateX(3.7vw) translateZ(-500px);
}

ol:nth-of-type(7) {
  transform: scale(2) translateX(11.425vw) translateZ(-1000px);
}

ol:nth-of-type(8) {
  transform: scale(2.5) translateX(20.75vw) translateZ(-1500px);
}

ol:nth-of-type(9) {
  transform: scale(3) translateX(30.9vw) translateZ(-2000px);
}

li {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20vh;
}

JavaScript

const rows = 20;
const columns = 9;
for (let x = 0; x < columns; x++) {
	const column = document.createElement("ol");
	for (let y = 0; y < rows; y++) {
  	const item = document.createElement("li");
    item.style.backgroundColor = `rgb(${Math.round((x / columns) * 255)}, 128, ${Math.round((y / rows) * 255)})`; 
    item.innerText = `${x + 1}-${y + 1}`;
    column.appendChild(item);
  }
  container.appendChild(column);
}