From a796cf775a01f0c06f07cb226a06f1d2eeed0694 Mon Sep 17 00:00:00 2001 From: barry <91018388+barry166@users.noreply.github.com> Date: Mon, 30 Mar 2026 16:05:45 +0800 Subject: [PATCH] demo: virtual scroll with zero DOM measurement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A variable-height virtual scrolling list where every row height is predicted by Pretext's prepare() + layout() — no DOM measurements at all during scroll. Demonstrates the core README use case: "proper virtualization/occlusion without guesstimates & caching". - 38k items, only ~20 DOM nodes rendered at any time - Binary search for first visible row - Row pooling / recycling for smooth scrolling - Stats bar showing items, rendered count, DOM reads, total height - Reuses the existing shower-thoughts.json corpus from the masonry demo --- pages/demos/index.html | 5 + pages/demos/virtual-scroll.html | 64 +++++++++++++ pages/demos/virtual-scroll.ts | 165 ++++++++++++++++++++++++++++++++ 3 files changed, 234 insertions(+) create mode 100644 pages/demos/virtual-scroll.html create mode 100644 pages/demos/virtual-scroll.ts diff --git a/pages/demos/index.html b/pages/demos/index.html index a15f4efd..97ed65d6 100644 --- a/pages/demos/index.html +++ b/pages/demos/index.html @@ -136,6 +136,11 @@
A text-card occlusion demo where height prediction comes from Pretext instead of DOM reads.
+ + +Thousands of variable-height rows scrolled with zero DOM measurement — heights predicted entirely by Pretext.
+ +diff --git a/pages/demos/virtual-scroll.html b/pages/demos/virtual-scroll.html new file mode 100644 index 00000000..e20f4f9a --- /dev/null +++ b/pages/demos/virtual-scroll.html @@ -0,0 +1,64 @@ + + +
+ + +
+ + +
+