gitoria

components

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitb7e11e3bb7e11e3bvirtual-list: the first resetKey is the baseline, so centerId and scrollTop keep their place at mount; gate for itAtlasb7e11e3b/components/virtual-list/demo.hl

2.5 KB

  1. // demo.hl — `/virtual-list`: 13,449 generated rows, loaded 50 at a time by the page's own function (an app would ask its server here). The
  2. // page tells how many rows were loaded in total and which row was tapped. The list is 24 rows tall; the page shows the count of DOM rows.
  3. parent '../main.hl'
  4. import VirtualList from './virtual-list.hl'
  5. import { greyLighter } from '../../shared/base.hl'
  6. __title = 'Virtual list · Hybriel components'
  7. static count = 13449
  8. Hybrid chunk = []
  9. Number chunkFrom = 0
  10. Number fetches = 0
  11. String tapped = 'nothing yet'
  12. String playingId = ''
  13. String domRows = ''
  14. String resetToken = ''
  15. Boolean descending = false
  16. Number resetOffset = null
  17. changeSort(Number top) {
  18. descending = !descending
  19. resetOffset = top
  20. loadRange(0, 30)
  21. resetToken = descending ? 'descending' : 'ascending'
  22. }
  23. // the page's data: row n is made up from n (a real app asks its server)
  24. makeRow(Number n) {
  25. item = descending ? count - 1 - n : n
  26. return { id = 'song-' + item title = 'Song number ' + item sub = 'Artist ' + (n % 97) + ' · Album ' + (n % 331) aside = '' + (n % 12) img = '' }
  27. }
  28. // the list asks for the rows near the viewport: load a chunk of 50 around them
  29. loadRange = (Number first, Number wanted) => {
  30. let start = first - 10
  31. if (start < 0) { start = 0 }
  32. let end = start + 50 + wanted
  33. if (end > count) { end = count }
  34. out = []
  35. let i = start
  36. while (i < end) { out.push(makeRow(i)) i = i + 1 }
  37. chunk = out
  38. chunkFrom = start
  39. fetches = fetches + 1
  40. }
  41. picked = (String id, Number index) => {
  42. tapped = id + ' (row ' + (index + 1) + ')'
  43. playingId = id
  44. }
  45. View {
  46. virtualListDemo {
  47. h1 { "Virtual list" }
  48. button { id = 'sortReset' type = 'button' 'Change sort, start at top' on click() { changeSort(null) } }
  49. button { id = 'offsetReset' type = 'button' 'Change sort, restore row 200' on click() { changeSort(11200) } }
  50. button { id = 'sameReset' type = 'button' 'Repeat reset key' on click() { resetToken = resetToken } }
  51. p { class = "muted" "13,449 rows; only the rows near the viewport exist in the page. The page loaded rows " output { id = "vl-fetches" fetches } " times." }
  52. div { id = "vl-box"
  53. VirtualList { itemCount = 13449 rowHeight = 56 loaded = chunk loadedFrom = chunkFrom onRange = loadRange onPick = picked selectedId = playingId scrollTop = resetOffset resetKey = resetToken listLabel = "Songs" }
  54. }
  55. p { class = "muted" "Tapped: " output { id = "vl-tapped" tapped } }
  56. p { a { id = "readme" href = "/virtual-list/README.md" "README (how to use it)" } }
  57. }
  58. }
  59. Style {
  60. virtualListDemo {
  61. '#vl-box' {
  62. height = '24rem'
  63. background = greyLighter
  64. }
  65. }
  66. }

Branches

Latest commits

  • b7e11e3bvirtual-list: the first resetKey is the baseline, so centerId and scrollTop keep their place at mount; gate for itAtlas
  • 7e428ba6Re-vendor Hybriel day72 (day73 withdrawn: minifier breaks write sets)Atlas
  • a06fc778Reset virtual-list window when the host changes resetKeyAtlas
  • 3aab598cRe-vendor complete Hybriel day73 set for virtual-list resetAtlas
  • 337ca075MD1 gate check measures frames in the page, not milliseconds from outside, and takes the middle load (components#30)mre
  • f5f131c5Record AP29 autoplay comparisons and passing gatesmre
  • 51c38187Gate media autoplay on first load and after client mountmre
  • a3f2223dRecord successful B44 deployment and live proofmre
  • 06c1e021Record passing B44 browser rerunmre
  • c9861533Record B44 component proof and browser gate blockermre
  • 1b7413beIgnore detached media events and space demo option outputsmre
  • ca3b4959Re-vendor complete Hybriel plugins and runtime to day44mre
  • df9e7df9Last-item checks run in the browser gate (components#26 fixed on day41); media-player loop is a plain Booleanmre
  • 895a5afcRe-vendor complete Hybriel plugins and runtime to day41mre
  • 16006bb3Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
  • 88397fc3Re-vendor complete Hybriel plugins and runtime to day39mre
  • 9b872cedRecord IC28 deployment and live icon verificationmre
  • 46fefaa7Count the icons entry in the offline home-page checkmre
  • c7e14cabRecord IC28 rerun and unchanged-main baseline comparisonmre
  • 5e090ffdRecord IC28 review evidence and gate resultsmre