SPB Git

Repository Public

virtual.html 945 B 17 lines html

1<!doctype html>2<html><head><meta charset="utf-8"><title>Virtual list</title>3<style>body{margin:0;font:14px sans-serif}#box{height:400px;width:500px;overflow-y:auto;position:relative;border:1px solid #888}4#spacer{height:6000px;position:relative}.row{position:absolute;left:0;right:0;height:30px;box-sizing:border-box;border-bottom:1px solid #eee}</style></head>5<body><h1>Virtual list</h1><div id="box"><div id="spacer"><div id="rows"></div></div></div>6<script>7const box = document.getElementById('box'), rows = document.getElementById('rows');8function paint() {9  const first = Math.floor(box.scrollTop / 30);10  rows.innerHTML = '';11  for (let i = first; i < Math.min(200, first + 16); i++) {12    const d = document.createElement('div'); d.className = 'row'; d.style.top = (i * 30) + 'px'; d.dataset.index = i; d.textContent = 'VROW-' + i; rows.appendChild(d);13  }14}15box.addEventListener('scroll', paint); paint();16</script></body></html>17
Files main
Menu

Theme