jukebox
All repositories: gitoria
3.7 KB
# Virtual listA list of tens of thousands of rows that scrolls smoothly on a phone. Demo: `/virtual-list`(https://components.hybriel.worldapi.org/virtual-list).Only the rows near the viewport exist in the page. Every row has the same fixed height, so the list knowswhere row N is without measuring: a spacer as tall as the whole list (`itemCount × rowHeight`) makes the scrollbar honest, and the few rows near the viewport (about 30 on a phone) are placed inside it. Scrolling a13,449-row list to the end keeps the page at about 35 rows.Pure Hybriel: one file, `virtual-list.hl`, with its own `Style`; no JavaScript file. It does not fetch anything:**the host owns the data** and loads it page by page.## Use it in an appCopy `components/virtual-list/virtual-list.hl` (and `components/icons/icons.hl`, which it imports), then:```import VirtualList from './virtual-list.hl'Number total = 13449Hybrid chunk = [] // the rows the host has loadedNumber chunkFrom = 0 // the number of the first row in `chunk`loadRange = (first, wanted) => {r = emit server myRows(first - 20 < 0 ? 0 : first - 20, 100) // an app asks its serverchunk = r.rowschunkFrom = r.offset}picked = (id, index) => { ... }View {div { class = "my-box" // gets a height, the list scrolls inside itVirtualList { itemCount = total rowHeight = 56 loaded = chunk loadedFrom = chunkFrom onRange = loadRange onPick = picked selectedId = playingId }}}```## Attributes| Attribute | Meaning ||---|---|| `itemCount` | how many rows the whole list has || `rowHeight` | the height of every row in pixels (default 56); the rows are exactly this tall || `loaded` | the rows the host has loaded, `[{ id, title, sub, aside, img }]`; `img` is a thumbnail address or `''` (a plain square) and is loaded lazily || `loadedFrom` | the number of the first row in `loaded` (0-based) || `onRange` | a function the host hands in; called with `(first, count)` when rows near the viewport are not all in `loaded`; the host loads them and hands in new `loaded` / `loadedFrom` || `onPick` | called with `(id, index)` when a row is tapped || `selectedId` | the `id` of the row to mark (the accent colour on a surface) || `thumbs` | `"false"` leaves the thumbnail out || `overscan` | how many rows are kept above and below the viewport (default 10) || `listLabel`, `emptyText` | the accessible name of the list; the text shown when `itemCount` is 0 || content | anything written inside `VirtualList { … }` stands above the rows and scrolls away with them (an album's cover and title) |`emit vlTop()` scrolls back to the first row; the host calls it after it changed the order or the filter.## Behaviour- Rows that the host has not delivered yet are blank rows of the same height, so the list never jumps; the host's`loaded` may be only a chunk of 100 rows around the viewport, a jump to the middle of the list asks for that part.- The list fills the box the host gives `virtual-list` (`height: 100%` of its parent, the scrolling happens inside).- A row is a button (keyboard Tab and Enter work), exactly `rowHeight` tall: the tap area is the row itself, no padding tricks, so thelist stays dense. Thumbnail, the text block and the row share one centre line.- Colours are the semantic tokens with a black/white/grey fallback (the base look); no frames.- **Use one per page**: a composed component's members are the page's state, so the public names (`itemCount`, `loaded`, `selectedId` …)are chosen to stay clear of a host's own.## Not yetNo row measuring (all rows are one height), no sticky section headers, no horizontal lists, no keyboard arrow navigation betweenrows (Tab moves along the rows that exist), and a row moved out of the window loses the keyboard focus.
Branches
Latest commits
- b42e7dfbjukebox: conductor records (CONDUCTOR.md, STATUS.md), old STATUS archivedmre
- 1b0d0bc1jukebox: a startup error prints its message before exit 1 (hybriel#247)mre
- b19c478bjukebox JB18 (jukebox#17): onto Hybriel set-day31 (b287cd82, contains the SIGPIPE fix 6d2ca454): plugins/core and plugins/web re-vendored, bin/ from the set; a client that closes /stream while it is written no longer kills the server (90 aborted streams survived, the old bin died with exit 141 on the first)mre
- 73867a2ejukebox#2: Style blocks in the language's nested form (rules named after the View's own elements, pseudo-classes nested, merged duplicates); the same CSS rules, the pages look the samemre
- 06c548d6jukebox JB15: report, log linemre
- 980859cbjukebox JB15 (jukebox#15): the now-playing overlay on a short screen (tablet or phone on its side) gave the queue 12 to 100 px because the big cover took the room; the cover now shrinks with the screen height and goes away under 41rem, the queue keeps 3+ rows; gate tests/jb15.mjs at 8 sizesmre
- 9efc40ffjukebox#12 #14: Grok session 1793246574527-181160mre
- 7d58b36ejukebox JB13 (jukebox#13): Next and Previous ask for the songs after / before the current song's id in the current order, not for place + 1; gate tests/jb13.mjs checks Next with the queue down to one song after the order changedmre
- 51358794jukebox JB14 (jukebox#14): the Songs screen opens sorted the way it was left (kept on the server in storage/ui.json), the sort control shows the sort the rows really have (selected options, autocomplete off); gate tests/jb14.mjsmre
- cc68a063jukebox JB13 (jukebox#13): a tapped song plays the song that was tapped, found by its id in the list as it is now (not by its row number, which counted plays move); the queue goes on from its place there, the rows refresh on the tap; gate tests/jb13.mjs (songs by plays, favourites)mre
- 88d3d5c1jukebox JB12b (jukebox#12): the scroll handle is big (2.75rem x 4rem, accent colour, grip) and drawn on every device, no media query; native bar hidden; gate tests/touch.mjs checks the drawn width with and without touchmre
- b58e4495jukebox JB11 (jukebox#11): the next song starts in the ended event on the same audio element, so it also starts with the screen locked; gate tests/jb11.mjs (hidden tab, no frames)mre
- 12a26233jukebox JB12 (jukebox#12): the long lists get a scroll handle a finger can use on touch screens (44 px tap area, slim look, drag through all rows), gate tests/touch.mjsmre
- 0f2157a9jukebox JV1: onto Hybriel set-day27b: readBytes and stat for /stream and the mp3 tags (no dd, head or tail), startup fault exits 1, fs and mpackdb plugins re-vendored; songs with a comma in the title are indexed againmre
- 63d0f2eejukebox ST1 (jukebox#2): styles of main, songs and search moved into their own Style blocks (styles.hl 81 to 8 rules, pixel-identical at 390 and 1280); artist and album wait for an hl:web fixmre
- c5b8fde9jukebox JB3b: keyboard gap repro as a reportmre
- 9daebb4bjukebox JB3b: shuffle, now-playing overlay, next and previous, play counting, media session, gates; keyboard left open (Hybriel gap)mre
- 59c1373ejukebox JB3 (work in progress): albums without folder and with disc markers folded, compilations, duplicate songs, own play counter, server-side shuffle queuemre
- 2a4cfc55jukebox: library screens (songs, artists, albums, artist, album, search, favourites), compact player bar, /stream with Range, thumbnails, virtual list vendored, ui gate and real-library checkmre
- 93a44212jukebox: report, numbers of the full scan, notes on the index key rulemre