[{"data":1,"prerenderedAt":2904},["ShallowReactive",2],{"navigation_docs":3,"-guides-popovers":107,"-guides-popovers-surround":2899},[4,26,57,87,97],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":25},"Getting Started","i-lucide-rocket","\u002Fgetting-started","1.getting-started",[10,15,20],{"title":11,"path":12,"stem":13,"icon":14},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction","i-lucide-book-open",{"title":16,"path":17,"stem":18,"icon":19},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation","i-lucide-download",{"title":21,"path":22,"stem":23,"icon":24},"Architecture","\u002Fgetting-started\u002Farchitecture","1.getting-started\u002F3.architecture","i-lucide-workflow",false,{"title":27,"icon":28,"path":29,"stem":30,"children":31,"page":25},"Reference","i-lucide-layers","\u002Freference","2.reference",[32,37,42,47,52],{"title":33,"path":34,"stem":35,"icon":36},"VirtualGrid","\u002Freference\u002Fvirtual-grid","2.reference\u002F1.virtual-grid","i-lucide-table-2",{"title":38,"path":39,"stem":40,"icon":41},"Primitives","\u002Freference\u002Fprimitives","2.reference\u002F2.primitives","i-lucide-crosshair",{"title":43,"path":44,"stem":45,"icon":46},"Utilities","\u002Freference\u002Futilities","2.reference\u002F3.utilities","i-lucide-wrench",{"title":48,"path":49,"stem":50,"icon":51},"Benchmarks","\u002Freference\u002Fbenchmarks","2.reference\u002F4.benchmarks","i-lucide-timer",{"title":53,"path":54,"stem":55,"icon":56},"ARIA patterns","\u002Freference\u002Faria-patterns","2.reference\u002F6.aria-patterns","i-lucide-accessibility",{"title":58,"icon":59,"path":60,"stem":61,"children":62,"page":25},"Guides","i-lucide-compass","\u002Fguides","3.guides",[63,67,72,77,82],{"title":64,"path":65,"stem":66,"icon":56},"Accessibility","\u002Fguides\u002Faccessibility","3.guides\u002F1.accessibility",{"title":68,"path":69,"stem":70,"icon":71},"Popovers and overlays","\u002Fguides\u002Fpopovers","3.guides\u002F2.popovers","i-lucide-message-square",{"title":73,"path":74,"stem":75,"icon":76},"Floating UI","\u002Fguides\u002Ffloating-ui","3.guides\u002F3.floating-ui","i-lucide-layers-2",{"title":78,"path":79,"stem":80,"icon":81},"Sizing and direction","\u002Fguides\u002Fsizing-and-direction","3.guides\u002F4.sizing-and-direction","i-lucide-move",{"title":83,"path":84,"stem":85,"icon":86},"Performance","\u002Fguides\u002Fperformance","3.guides\u002F5.performance","i-lucide-gauge",{"title":88,"icon":89,"path":90,"stem":91,"children":92,"page":25},"Examples","i-lucide-flask-conical","\u002Fexamples","4.examples",[93],{"title":94,"path":95,"stem":96,"icon":56},"ARIA examples","\u002Fexamples\u002Faria","4.examples\u002F1.aria",{"title":98,"icon":99,"path":100,"stem":101,"children":102,"page":25},"Changes","i-lucide-history","\u002Fchanges","5.changes",[103],{"title":104,"path":105,"stem":106,"icon":99},"Changelog","\u002Fchanges\u002Fchangelog","5.changes\u002F1.changelog",{"id":108,"title":68,"body":109,"description":2892,"extension":2893,"links":2894,"meta":2895,"navigation":2896,"path":69,"seo":2897,"stem":70,"__hash__":2898},"docs\u002F3.guides\u002F2.popovers.md",{"type":110,"value":111,"toc":2878},"minimark",[112,116,119,131,134,137,142,1816,1820,1829,2170,2176,2180,2193,2210,2387,2470,2478,2487,2692,2710,2714,2729,2848,2866,2875],[113,114,115],"p",{},"In this guide you open a native popover under the item a user clicks, and keep it attached while the grid scrolls.",[113,117,118],{},"The grid renders only the items near the viewport. Once the clicked item scrolls out, its element is removed from the DOM, and a popover attached to that element loses its position. Instead, you ask the grid for the item's rectangle by index. The grid computes it from the item's position in the list, so it works whether or not the item is rendered.",[113,120,121,122,126,127,130],{},"A native popover is an element with the ",[123,124,125],"code",{},"popover"," attribute. The browser puts it in the top layer when you call ",[123,128,129],{},"showPopover()",", so it draws above the page and the scroll container does not clip it.",[132,133],"popover-demo",{},[113,135,136],{},"In the demo, the popover keeps following item 4,200 after you scroll far enough that the item is no longer in the DOM.",[138,139,141],"h2",{"id":140},"build-it","Build it",[143,144,146,151,170,173,413,419,766,770,789,918,925,929,953,1000,1010,1031,1035,1055,1377,1391,1458,1476,1483,1489,1508,1694,1803,1807,1810],"steps",{"level":145},"3",[147,148,150],"h3",{"id":149},"mark-each-item-with-its-index","Mark each item with its index",[113,152,153,154,157,158,161,162,165,166,169],{},"Add ",[123,155,156],{},":data-index=\"index\""," to the root element of both the ",[123,159,160],{},"default"," and ",[123,163,164],{},"placeholder"," slots. The grid gives you ",[123,167,168],{},"index"," in the slot. The attribute lets you find the item from a DOM event later.",[113,171,172],{},"The script defines the items, the provider and the grid ref.",[174,175,180],"pre",{"className":176,"code":177,"language":178,"meta":179,"style":179},"language-vue shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003Cscript setup>\nimport { useTemplateRef } from \"vue\";\nimport { createPageProvider } from \"vvirtual-grid\u002Fvue\";\n\nconst items = Array.from({ length: 10000 }, (_, i) => ({ title: `Item ${i + 1}` }));\nconst pageProvider = createPageProvider(items);\nconst grid = useTemplateRef(\"grid\");\n\u003C\u002Fscript>\n","vue","",[123,181,182,202,234,257,264,361,378,403],{"__ignoreMap":179},[183,184,187,191,195,199],"span",{"class":185,"line":186},"line",1,[183,188,190],{"class":189},"sMK4o","\u003C",[183,192,194],{"class":193},"swJcz","script",[183,196,198],{"class":197},"spNyl"," setup",[183,200,201],{"class":189},">\n",[183,203,205,209,212,216,219,222,225,228,231],{"class":185,"line":204},2,[183,206,208],{"class":207},"s7zQu","import",[183,210,211],{"class":189}," {",[183,213,215],{"class":214},"sTEyZ"," useTemplateRef",[183,217,218],{"class":189}," }",[183,220,221],{"class":207}," from",[183,223,224],{"class":189}," \"",[183,226,178],{"class":227},"sfazB",[183,229,230],{"class":189},"\"",[183,232,233],{"class":189},";\n",[183,235,237,239,241,244,246,248,250,253,255],{"class":185,"line":236},3,[183,238,208],{"class":207},[183,240,211],{"class":189},[183,242,243],{"class":214}," createPageProvider",[183,245,218],{"class":189},[183,247,221],{"class":207},[183,249,224],{"class":189},[183,251,252],{"class":227},"vvirtual-grid\u002Fvue",[183,254,230],{"class":189},[183,256,233],{"class":189},[183,258,260],{"class":185,"line":259},4,[183,261,263],{"emptyLinePlaceholder":262},true,"\n",[183,265,267,270,273,276,279,282,286,289,292,295,298,302,305,308,312,315,318,321,324,326,328,331,333,336,339,342,345,348,351,354,356,359],{"class":185,"line":266},5,[183,268,269],{"class":197},"const",[183,271,272],{"class":214}," items ",[183,274,275],{"class":189},"=",[183,277,278],{"class":214}," Array",[183,280,281],{"class":189},".",[183,283,285],{"class":284},"s2Zo4","from",[183,287,288],{"class":214},"(",[183,290,291],{"class":189},"{",[183,293,294],{"class":193}," length",[183,296,297],{"class":189},":",[183,299,301],{"class":300},"sbssI"," 10000",[183,303,304],{"class":189}," },",[183,306,307],{"class":189}," (",[183,309,311],{"class":310},"sHdIc","_",[183,313,314],{"class":189},",",[183,316,317],{"class":310}," i",[183,319,320],{"class":189},")",[183,322,323],{"class":197}," =>",[183,325,307],{"class":214},[183,327,291],{"class":189},[183,329,330],{"class":193}," title",[183,332,297],{"class":189},[183,334,335],{"class":189}," `",[183,337,338],{"class":227},"Item ",[183,340,341],{"class":189},"${",[183,343,344],{"class":214},"i ",[183,346,347],{"class":189},"+",[183,349,350],{"class":300}," 1",[183,352,353],{"class":189},"}`",[183,355,218],{"class":189},[183,357,358],{"class":214},"))",[183,360,233],{"class":189},[183,362,364,366,369,371,373,376],{"class":185,"line":363},6,[183,365,269],{"class":197},[183,367,368],{"class":214}," pageProvider ",[183,370,275],{"class":189},[183,372,243],{"class":284},[183,374,375],{"class":214},"(items)",[183,377,233],{"class":189},[183,379,381,383,386,388,390,392,394,397,399,401],{"class":185,"line":380},7,[183,382,269],{"class":197},[183,384,385],{"class":214}," grid ",[183,387,275],{"class":189},[183,389,215],{"class":284},[183,391,288],{"class":214},[183,393,230],{"class":189},[183,395,396],{"class":227},"grid",[183,398,230],{"class":189},[183,400,320],{"class":214},[183,402,233],{"class":189},[183,404,406,409,411],{"class":185,"line":405},8,[183,407,408],{"class":189},"\u003C\u002F",[183,410,194],{"class":193},[183,412,201],{"class":189},[113,414,415,416,281],{},"The template adds the index attribute to both slots. The grid uses the scroll container, column tracks and probe from ",[417,418,78],"a",{"href":79},[174,420,422],{"className":176,"code":421,"language":178,"meta":179,"style":179},"\u003Ctemplate>\n  \u003Cdiv class=\"h-96 overflow-y-auto\">\n    \u003CVirtualGrid\n      ref=\"grid\"\n      :length=\"items.length\"\n      :page-size=\"40\"\n      :page-provider=\"pageProvider\"\n      class=\"grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-2\"\n    >\n      \u003Ctemplate #default=\"{ item, index, style }\">\n        \u003Cbutton :style=\"style\" :data-index=\"index\" class=\"h-16\">{{ item.title }}\u003C\u002Fbutton>\n      \u003C\u002Ftemplate>\n\n      \u003Ctemplate #placeholder=\"{ index, style }\">\n        \u003Cdiv :style=\"style\" :data-index=\"index\" class=\"h-16\" \u002F>\n      \u003C\u002Ftemplate>\n    \u003C\u002FVirtualGrid>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n",[123,423,424,433,455,463,477,498,514,530,544,550,589,644,654,659,688,728,737,747,757],{"__ignoreMap":179},[183,425,426,428,431],{"class":185,"line":186},[183,427,190],{"class":189},[183,429,430],{"class":193},"template",[183,432,201],{"class":189},[183,434,435,438,441,444,446,448,451,453],{"class":185,"line":204},[183,436,437],{"class":189},"  \u003C",[183,439,440],{"class":193},"div",[183,442,443],{"class":197}," class",[183,445,275],{"class":189},[183,447,230],{"class":189},[183,449,450],{"class":227},"h-96 overflow-y-auto",[183,452,230],{"class":189},[183,454,201],{"class":189},[183,456,457,460],{"class":185,"line":236},[183,458,459],{"class":189},"    \u003C",[183,461,462],{"class":193},"VirtualGrid\n",[183,464,465,468,470,472,474],{"class":185,"line":259},[183,466,467],{"class":197},"      ref",[183,469,275],{"class":189},[183,471,230],{"class":189},[183,473,396],{"class":227},[183,475,476],{"class":189},"\"\n",[183,478,479,482,485,487,489,492,494,496],{"class":185,"line":266},[183,480,481],{"class":189},"      :",[183,483,484],{"class":197},"length",[183,486,275],{"class":189},[183,488,230],{"class":189},[183,490,491],{"class":214},"items",[183,493,281],{"class":189},[183,495,484],{"class":214},[183,497,476],{"class":189},[183,499,500,502,505,507,509,512],{"class":185,"line":363},[183,501,481],{"class":189},[183,503,504],{"class":197},"page-size",[183,506,275],{"class":189},[183,508,230],{"class":189},[183,510,511],{"class":300},"40",[183,513,476],{"class":189},[183,515,516,518,521,523,525,528],{"class":185,"line":380},[183,517,481],{"class":189},[183,519,520],{"class":197},"page-provider",[183,522,275],{"class":189},[183,524,230],{"class":189},[183,526,527],{"class":214},"pageProvider",[183,529,476],{"class":189},[183,531,532,535,537,539,542],{"class":185,"line":405},[183,533,534],{"class":197},"      class",[183,536,275],{"class":189},[183,538,230],{"class":189},[183,540,541],{"class":227},"grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-2",[183,543,476],{"class":189},[183,545,547],{"class":185,"line":546},9,[183,548,549],{"class":189},"    >\n",[183,551,553,556,558,561,563,565,567,569,572,574,577,579,582,585,587],{"class":185,"line":552},10,[183,554,555],{"class":189},"      \u003C",[183,557,430],{"class":193},[183,559,560],{"class":189}," #",[183,562,160],{"class":197},[183,564,275],{"class":189},[183,566,230],{"class":189},[183,568,291],{"class":189},[183,570,571],{"class":214}," item",[183,573,314],{"class":189},[183,575,576],{"class":214}," index",[183,578,314],{"class":189},[183,580,581],{"class":214}," style ",[183,583,584],{"class":189},"}",[183,586,230],{"class":189},[183,588,201],{"class":189},[183,590,592,595,598,601,603,605,608,610,613,615,617,619,621,623,625,627,630,632,635,638,640,642],{"class":185,"line":591},11,[183,593,594],{"class":189},"        \u003C",[183,596,597],{"class":193},"button",[183,599,600],{"class":197}," :style",[183,602,275],{"class":189},[183,604,230],{"class":189},[183,606,607],{"class":227},"style",[183,609,230],{"class":189},[183,611,612],{"class":197}," :data-index",[183,614,275],{"class":189},[183,616,230],{"class":189},[183,618,168],{"class":227},[183,620,230],{"class":189},[183,622,443],{"class":197},[183,624,275],{"class":189},[183,626,230],{"class":189},[183,628,629],{"class":227},"h-16",[183,631,230],{"class":189},[183,633,634],{"class":189},">",[183,636,637],{"class":214},"{{ item.title }}",[183,639,408],{"class":189},[183,641,597],{"class":193},[183,643,201],{"class":189},[183,645,647,650,652],{"class":185,"line":646},12,[183,648,649],{"class":189},"      \u003C\u002F",[183,651,430],{"class":193},[183,653,201],{"class":189},[183,655,657],{"class":185,"line":656},13,[183,658,263],{"emptyLinePlaceholder":262},[183,660,662,664,666,668,670,672,674,676,678,680,682,684,686],{"class":185,"line":661},14,[183,663,555],{"class":189},[183,665,430],{"class":193},[183,667,560],{"class":189},[183,669,164],{"class":197},[183,671,275],{"class":189},[183,673,230],{"class":189},[183,675,291],{"class":189},[183,677,576],{"class":214},[183,679,314],{"class":189},[183,681,581],{"class":214},[183,683,584],{"class":189},[183,685,230],{"class":189},[183,687,201],{"class":189},[183,689,691,693,695,697,699,701,703,705,707,709,711,713,715,717,719,721,723,725],{"class":185,"line":690},15,[183,692,594],{"class":189},[183,694,440],{"class":193},[183,696,600],{"class":197},[183,698,275],{"class":189},[183,700,230],{"class":189},[183,702,607],{"class":227},[183,704,230],{"class":189},[183,706,612],{"class":197},[183,708,275],{"class":189},[183,710,230],{"class":189},[183,712,168],{"class":227},[183,714,230],{"class":189},[183,716,443],{"class":197},[183,718,275],{"class":189},[183,720,230],{"class":189},[183,722,629],{"class":227},[183,724,230],{"class":189},[183,726,727],{"class":189}," \u002F>\n",[183,729,731,733,735],{"class":185,"line":730},16,[183,732,649],{"class":189},[183,734,430],{"class":193},[183,736,201],{"class":189},[183,738,740,743,745],{"class":185,"line":739},17,[183,741,742],{"class":189},"    \u003C\u002F",[183,744,33],{"class":193},[183,746,201],{"class":189},[183,748,750,753,755],{"class":185,"line":749},18,[183,751,752],{"class":189},"  \u003C\u002F",[183,754,440],{"class":193},[183,756,201],{"class":189},[183,758,760,762,764],{"class":185,"line":759},19,[183,761,408],{"class":189},[183,763,430],{"class":193},[183,765,201],{"class":189},[147,767,769],{"id":768},"find-the-clicked-index","Find the clicked index",[113,771,772,773,776,777,780,781,784,785,788],{},"Listen for ",[123,774,775],{},"click"," once on ",[123,778,779],{},"\u003CVirtualGrid>",". One listener covers every item, so the items need no handlers of their own. In the handler, walk up from ",[123,782,783],{},"event.target"," to the nearest element with a ",[123,786,787],{},"data-index"," attribute and read it.",[174,790,794],{"className":791,"code":792,"language":793,"meta":179,"style":179},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","function indexFromEvent(event: Event) {\n  const item = (event.target as Element).closest(\"[data-index]\");\n  return item ? Number((item as HTMLElement).dataset.index) : -1;\n}\n","ts",[123,795,796,820,865,913],{"__ignoreMap":179},[183,797,798,801,804,806,809,811,815,817],{"class":185,"line":186},[183,799,800],{"class":197},"function",[183,802,803],{"class":284}," indexFromEvent",[183,805,288],{"class":189},[183,807,808],{"class":310},"event",[183,810,297],{"class":189},[183,812,814],{"class":813},"sBMFI"," Event",[183,816,320],{"class":189},[183,818,819],{"class":189}," {\n",[183,821,822,825,827,830,832,834,836,839,842,845,847,849,852,854,856,859,861,863],{"class":185,"line":204},[183,823,824],{"class":197},"  const",[183,826,571],{"class":214},[183,828,829],{"class":189}," =",[183,831,307],{"class":193},[183,833,808],{"class":214},[183,835,281],{"class":189},[183,837,838],{"class":214},"target",[183,840,841],{"class":207}," as",[183,843,844],{"class":813}," Element",[183,846,320],{"class":193},[183,848,281],{"class":189},[183,850,851],{"class":284},"closest",[183,853,288],{"class":193},[183,855,230],{"class":189},[183,857,858],{"class":227},"[data-index]",[183,860,230],{"class":189},[183,862,320],{"class":193},[183,864,233],{"class":189},[183,866,867,870,872,875,878,881,884,886,889,891,893,896,898,900,903,905,908,911],{"class":185,"line":236},[183,868,869],{"class":207},"  return",[183,871,571],{"class":214},[183,873,874],{"class":189}," ?",[183,876,877],{"class":284}," Number",[183,879,880],{"class":193},"((",[183,882,883],{"class":214},"item",[183,885,841],{"class":207},[183,887,888],{"class":813}," HTMLElement",[183,890,320],{"class":193},[183,892,281],{"class":189},[183,894,895],{"class":214},"dataset",[183,897,281],{"class":189},[183,899,168],{"class":214},[183,901,902],{"class":193},") ",[183,904,297],{"class":189},[183,906,907],{"class":189}," -",[183,909,910],{"class":300},"1",[183,912,233],{"class":189},[183,914,915],{"class":185,"line":259},[183,916,917],{"class":189},"}\n",[113,919,920,921,924],{},"The function returns ",[123,922,923],{},"-1"," when the click did not land on an item, for example on the gap between two items.",[147,926,928],{"id":927},"create-one-rectangle-query","Create one rectangle query",[113,930,931,934,935,937,938,161,941,944,945,948,949,952],{},[123,932,933],{},"getItemRect"," takes a query object. You set ",[123,936,168],{},", ",[123,939,940],{},"layout",[123,942,943],{},"root"," on it, and the function writes the item's rectangle into ",[123,946,947],{},"query.rect",". Create the query once with ",[123,950,951],{},"createRectQuery",", outside the handlers, and change its fields before each call.",[174,954,956],{"className":791,"code":955,"language":793,"meta":179,"style":179},"import { createRectQuery } from \"vvirtual-grid\u002Fprimitives\";\n\nconst query = createRectQuery();\n",[123,957,958,980,984],{"__ignoreMap":179},[183,959,960,962,964,967,969,971,973,976,978],{"class":185,"line":186},[183,961,208],{"class":207},[183,963,211],{"class":189},[183,965,966],{"class":214}," createRectQuery",[183,968,218],{"class":189},[183,970,221],{"class":207},[183,972,224],{"class":189},[183,974,975],{"class":227},"vvirtual-grid\u002Fprimitives",[183,977,230],{"class":189},[183,979,233],{"class":189},[183,981,982],{"class":185,"line":204},[183,983,263],{"emptyLinePlaceholder":262},[183,985,986,988,991,993,995,998],{"class":185,"line":236},[183,987,269],{"class":197},[183,989,990],{"class":214}," query ",[183,992,275],{"class":189},[183,994,966],{"class":284},[183,996,997],{"class":214},"()",[183,999,233],{"class":189},[113,1001,1002,1003,1006,1007,281],{},"The function writes into an object you own, instead of returning a new one, because ",[123,1004,1005],{},"viewport-scroll"," fires on every scroll event. A new rectangle per event is garbage the browser must collect while the user scrolls. Reusing one object avoids that. It is the same idea as an output parameter in a C API, ",[123,1008,1009],{},"get_rect(index, &rect)",[113,1011,1012,1013,1016,1017,1020,1021,1023,1024,1027,1028,1030],{},"Set ",[123,1014,1015],{},"query.root"," to ",[123,1018,1019],{},"grid.value.$el",". With a ",[123,1022,943],{},", the rectangle is relative to the viewport, like ",[123,1025,1026],{},"getBoundingClientRect()",". This costs one layout read of the grid's first element. Without a ",[123,1029,943],{},", the rectangle is relative to item 0 and the call reads nothing from the DOM.",[147,1032,1034],{"id":1033},"position-the-popover-from-the-rectangle","Position the popover from the rectangle",[113,1036,1037,1038,1041,1042,1044,1045,1047,1048,1051,1052,281],{},"Write a ",[123,1039,1040],{},"place()"," function that fills the query, calls ",[123,1043,933],{},", and moves the popover under the item. The function uses the ",[123,1046,396],{}," ref from ",[417,1049,150],{"href":1050},"#mark-each-item-with-its-index"," and the query from ",[417,1053,928],{"href":1054},"#create-one-rectangle-query",[174,1056,1058],{"className":791,"code":1057,"language":793,"meta":179,"style":179},"import { ref, useTemplateRef } from \"vue\";\nimport { getItemRect } from \"vvirtual-grid\u002Fprimitives\";\n\nconst popover = useTemplateRef(\"popover\");\nconst anchored = ref(-1);\n\nfunction place() {\n  if (anchored.value \u003C 0 || !grid.value || !popover.value) return;\n  query.root = grid.value.$el;\n  query.index = anchored.value;\n  query.layout = grid.value.measurement;\n  if (!getItemRect(query)) return;\n  popover.value.style.translate = `${query.rect.left}px ${query.rect.bottom}px`;\n}\n",[123,1059,1060,1085,1106,1110,1133,1155,1159,1170,1220,1245,1264,1287,1310,1373],{"__ignoreMap":179},[183,1061,1062,1064,1066,1069,1071,1073,1075,1077,1079,1081,1083],{"class":185,"line":186},[183,1063,208],{"class":207},[183,1065,211],{"class":189},[183,1067,1068],{"class":214}," ref",[183,1070,314],{"class":189},[183,1072,215],{"class":214},[183,1074,218],{"class":189},[183,1076,221],{"class":207},[183,1078,224],{"class":189},[183,1080,178],{"class":227},[183,1082,230],{"class":189},[183,1084,233],{"class":189},[183,1086,1087,1089,1091,1094,1096,1098,1100,1102,1104],{"class":185,"line":204},[183,1088,208],{"class":207},[183,1090,211],{"class":189},[183,1092,1093],{"class":214}," getItemRect",[183,1095,218],{"class":189},[183,1097,221],{"class":207},[183,1099,224],{"class":189},[183,1101,975],{"class":227},[183,1103,230],{"class":189},[183,1105,233],{"class":189},[183,1107,1108],{"class":185,"line":236},[183,1109,263],{"emptyLinePlaceholder":262},[183,1111,1112,1114,1117,1119,1121,1123,1125,1127,1129,1131],{"class":185,"line":259},[183,1113,269],{"class":197},[183,1115,1116],{"class":214}," popover ",[183,1118,275],{"class":189},[183,1120,215],{"class":284},[183,1122,288],{"class":214},[183,1124,230],{"class":189},[183,1126,125],{"class":227},[183,1128,230],{"class":189},[183,1130,320],{"class":214},[183,1132,233],{"class":189},[183,1134,1135,1137,1140,1142,1144,1146,1149,1151,1153],{"class":185,"line":266},[183,1136,269],{"class":197},[183,1138,1139],{"class":214}," anchored ",[183,1141,275],{"class":189},[183,1143,1068],{"class":284},[183,1145,288],{"class":214},[183,1147,1148],{"class":189},"-",[183,1150,910],{"class":300},[183,1152,320],{"class":214},[183,1154,233],{"class":189},[183,1156,1157],{"class":185,"line":363},[183,1158,263],{"emptyLinePlaceholder":262},[183,1160,1161,1163,1166,1168],{"class":185,"line":380},[183,1162,800],{"class":197},[183,1164,1165],{"class":284}," place",[183,1167,997],{"class":189},[183,1169,819],{"class":189},[183,1171,1172,1175,1177,1180,1182,1185,1188,1191,1194,1197,1199,1201,1203,1205,1207,1209,1211,1213,1215,1218],{"class":185,"line":405},[183,1173,1174],{"class":207},"  if",[183,1176,307],{"class":193},[183,1178,1179],{"class":214},"anchored",[183,1181,281],{"class":189},[183,1183,1184],{"class":214},"value",[183,1186,1187],{"class":189}," \u003C",[183,1189,1190],{"class":300}," 0",[183,1192,1193],{"class":189}," ||",[183,1195,1196],{"class":189}," !",[183,1198,396],{"class":214},[183,1200,281],{"class":189},[183,1202,1184],{"class":214},[183,1204,1193],{"class":189},[183,1206,1196],{"class":189},[183,1208,125],{"class":214},[183,1210,281],{"class":189},[183,1212,1184],{"class":214},[183,1214,902],{"class":193},[183,1216,1217],{"class":207},"return",[183,1219,233],{"class":189},[183,1221,1222,1225,1227,1229,1231,1234,1236,1238,1240,1243],{"class":185,"line":546},[183,1223,1224],{"class":214},"  query",[183,1226,281],{"class":189},[183,1228,943],{"class":214},[183,1230,829],{"class":189},[183,1232,1233],{"class":214}," grid",[183,1235,281],{"class":189},[183,1237,1184],{"class":214},[183,1239,281],{"class":189},[183,1241,1242],{"class":214},"$el",[183,1244,233],{"class":189},[183,1246,1247,1249,1251,1253,1255,1258,1260,1262],{"class":185,"line":552},[183,1248,1224],{"class":214},[183,1250,281],{"class":189},[183,1252,168],{"class":214},[183,1254,829],{"class":189},[183,1256,1257],{"class":214}," anchored",[183,1259,281],{"class":189},[183,1261,1184],{"class":214},[183,1263,233],{"class":189},[183,1265,1266,1268,1270,1272,1274,1276,1278,1280,1282,1285],{"class":185,"line":591},[183,1267,1224],{"class":214},[183,1269,281],{"class":189},[183,1271,940],{"class":214},[183,1273,829],{"class":189},[183,1275,1233],{"class":214},[183,1277,281],{"class":189},[183,1279,1184],{"class":214},[183,1281,281],{"class":189},[183,1283,1284],{"class":214},"measurement",[183,1286,233],{"class":189},[183,1288,1289,1291,1293,1296,1298,1300,1303,1306,1308],{"class":185,"line":646},[183,1290,1174],{"class":207},[183,1292,307],{"class":193},[183,1294,1295],{"class":189},"!",[183,1297,933],{"class":284},[183,1299,288],{"class":193},[183,1301,1302],{"class":214},"query",[183,1304,1305],{"class":193},")) ",[183,1307,1217],{"class":207},[183,1309,233],{"class":189},[183,1311,1312,1315,1317,1319,1321,1323,1325,1328,1330,1333,1335,1337,1340,1342,1345,1347,1350,1352,1354,1356,1358,1360,1363,1365,1368,1371],{"class":185,"line":656},[183,1313,1314],{"class":214},"  popover",[183,1316,281],{"class":189},[183,1318,1184],{"class":214},[183,1320,281],{"class":189},[183,1322,607],{"class":214},[183,1324,281],{"class":189},[183,1326,1327],{"class":214},"translate",[183,1329,829],{"class":189},[183,1331,1332],{"class":189}," `${",[183,1334,1302],{"class":214},[183,1336,281],{"class":189},[183,1338,1339],{"class":214},"rect",[183,1341,281],{"class":189},[183,1343,1344],{"class":214},"left",[183,1346,584],{"class":189},[183,1348,1349],{"class":227},"px ",[183,1351,341],{"class":189},[183,1353,1302],{"class":214},[183,1355,281],{"class":189},[183,1357,1339],{"class":214},[183,1359,281],{"class":189},[183,1361,1362],{"class":214},"bottom",[183,1364,584],{"class":189},[183,1366,1367],{"class":227},"px",[183,1369,1370],{"class":189},"`",[183,1372,233],{"class":189},[183,1374,1375],{"class":185,"line":661},[183,1376,917],{"class":189},[113,1378,1379,1380,1383,1384,161,1387,1390],{},"The popover needs ",[123,1381,1382],{},"position: fixed",", because the rectangle holds viewport coordinates. Also reset ",[123,1385,1386],{},"margin",[123,1388,1389],{},"inset",", which the browser sets on every popover to center it.",[174,1392,1394],{"className":176,"code":1393,"language":178,"meta":179,"style":179},"\u003Ctemplate>\n  \u003Cdiv ref=\"popover\" popover style=\"position: fixed; inset: 0 auto auto 0; margin: 0\">\n    Item {{ anchored }}\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n",[123,1395,1396,1404,1437,1442,1450],{"__ignoreMap":179},[183,1397,1398,1400,1402],{"class":185,"line":186},[183,1399,190],{"class":189},[183,1401,430],{"class":193},[183,1403,201],{"class":189},[183,1405,1406,1408,1410,1412,1414,1416,1418,1420,1423,1426,1428,1430,1433,1435],{"class":185,"line":204},[183,1407,437],{"class":189},[183,1409,440],{"class":193},[183,1411,1068],{"class":197},[183,1413,275],{"class":189},[183,1415,230],{"class":189},[183,1417,125],{"class":227},[183,1419,230],{"class":189},[183,1421,1422],{"class":197}," popover",[183,1424,1425],{"class":197}," style",[183,1427,275],{"class":189},[183,1429,230],{"class":189},[183,1431,1432],{"class":227},"position: fixed; inset: 0 auto auto 0; margin: 0",[183,1434,230],{"class":189},[183,1436,201],{"class":189},[183,1438,1439],{"class":185,"line":236},[183,1440,1441],{"class":214},"    Item {{ anchored }}\n",[183,1443,1444,1446,1448],{"class":185,"line":259},[183,1445,752],{"class":189},[183,1447,440],{"class":193},[183,1449,201],{"class":189},[183,1451,1452,1454,1456],{"class":185,"line":266},[183,1453,408],{"class":189},[183,1455,430],{"class":193},[183,1457,201],{"class":189},[113,1459,1460,1462,1463,1466,1467,1469,1470,1472,1473,1475],{},[123,1461,933],{}," returns ",[123,1464,1465],{},"false"," and leaves ",[123,1468,947],{}," unchanged when ",[123,1471,1284],{}," is not ready or nothing is rendered yet. The ",[123,1474,1040],{}," function stops in that case.",[147,1477,1479,1480,1482],{"id":1478},"call-place-when-the-position-can-change","Call ",[123,1481,1040],{}," when the position can change",[113,1484,1485,1486,1488],{},"The popover must move in three situations. Call ",[123,1487,1040],{}," in each of them:",[1490,1491,1492,1496,1502],"ul",{},[1493,1494,1495],"li",{},"When it opens, for the first position.",[1493,1497,1498,1499,1501],{},"On ",[123,1500,1005],{},", because every item moved on screen.",[1493,1503,1498,1504,1507],{},[123,1505,1506],{},"layout-change",", because the item size, the gap or the number of columns changed.",[174,1509,1511],{"className":176,"code":1510,"language":178,"meta":179,"style":179},"\u003Ctemplate>\n  \u003Cdiv class=\"h-96 overflow-y-auto\">\n    \u003CVirtualGrid\n      ref=\"grid\"\n      :length=\"items.length\"\n      :page-size=\"40\"\n      :page-provider=\"pageProvider\"\n      @click=\"open\"\n      @viewport-scroll=\"place\"\n      @layout-change=\"place\"\n      class=\"grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-2\"\n    >\n      \u003C!-- the default, placeholder and probe slots -->\n    \u003C\u002FVirtualGrid>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n",[123,1512,1513,1521,1539,1545,1557,1575,1589,1603,1619,1634,1648,1660,1664,1670,1678,1686],{"__ignoreMap":179},[183,1514,1515,1517,1519],{"class":185,"line":186},[183,1516,190],{"class":189},[183,1518,430],{"class":193},[183,1520,201],{"class":189},[183,1522,1523,1525,1527,1529,1531,1533,1535,1537],{"class":185,"line":204},[183,1524,437],{"class":189},[183,1526,440],{"class":193},[183,1528,443],{"class":197},[183,1530,275],{"class":189},[183,1532,230],{"class":189},[183,1534,450],{"class":227},[183,1536,230],{"class":189},[183,1538,201],{"class":189},[183,1540,1541,1543],{"class":185,"line":236},[183,1542,459],{"class":189},[183,1544,462],{"class":193},[183,1546,1547,1549,1551,1553,1555],{"class":185,"line":259},[183,1548,467],{"class":197},[183,1550,275],{"class":189},[183,1552,230],{"class":189},[183,1554,396],{"class":227},[183,1556,476],{"class":189},[183,1558,1559,1561,1563,1565,1567,1569,1571,1573],{"class":185,"line":266},[183,1560,481],{"class":189},[183,1562,484],{"class":197},[183,1564,275],{"class":189},[183,1566,230],{"class":189},[183,1568,491],{"class":214},[183,1570,281],{"class":189},[183,1572,484],{"class":214},[183,1574,476],{"class":189},[183,1576,1577,1579,1581,1583,1585,1587],{"class":185,"line":363},[183,1578,481],{"class":189},[183,1580,504],{"class":197},[183,1582,275],{"class":189},[183,1584,230],{"class":189},[183,1586,511],{"class":300},[183,1588,476],{"class":189},[183,1590,1591,1593,1595,1597,1599,1601],{"class":185,"line":380},[183,1592,481],{"class":189},[183,1594,520],{"class":197},[183,1596,275],{"class":189},[183,1598,230],{"class":189},[183,1600,527],{"class":214},[183,1602,476],{"class":189},[183,1604,1605,1608,1610,1612,1614,1617],{"class":185,"line":405},[183,1606,1607],{"class":189},"      @",[183,1609,775],{"class":197},[183,1611,275],{"class":189},[183,1613,230],{"class":189},[183,1615,1616],{"class":214},"open",[183,1618,476],{"class":189},[183,1620,1621,1623,1625,1627,1629,1632],{"class":185,"line":546},[183,1622,1607],{"class":189},[183,1624,1005],{"class":197},[183,1626,275],{"class":189},[183,1628,230],{"class":189},[183,1630,1631],{"class":214},"place",[183,1633,476],{"class":189},[183,1635,1636,1638,1640,1642,1644,1646],{"class":185,"line":552},[183,1637,1607],{"class":189},[183,1639,1506],{"class":197},[183,1641,275],{"class":189},[183,1643,230],{"class":189},[183,1645,1631],{"class":214},[183,1647,476],{"class":189},[183,1649,1650,1652,1654,1656,1658],{"class":185,"line":591},[183,1651,534],{"class":197},[183,1653,275],{"class":189},[183,1655,230],{"class":189},[183,1657,541],{"class":227},[183,1659,476],{"class":189},[183,1661,1662],{"class":185,"line":646},[183,1663,549],{"class":189},[183,1665,1666],{"class":185,"line":656},[183,1667,1669],{"class":1668},"sHwdD","      \u003C!-- the default, placeholder and probe slots -->\n",[183,1671,1672,1674,1676],{"class":185,"line":661},[183,1673,742],{"class":189},[183,1675,33],{"class":193},[183,1677,201],{"class":189},[183,1679,1680,1682,1684],{"class":185,"line":690},[183,1681,752],{"class":189},[183,1683,440],{"class":193},[183,1685,201],{"class":189},[183,1687,1688,1690,1692],{"class":185,"line":730},[183,1689,408],{"class":189},[183,1691,430],{"class":193},[183,1693,201],{"class":189},[174,1695,1697],{"className":791,"code":1696,"language":793,"meta":179,"style":179},"function open(event: MouseEvent) {\n  const index = indexFromEvent(event);\n  if (index === -1) return;\n  anchored.value = index;\n  place();\n  popover.value.showPopover();\n}\n",[123,1698,1699,1719,1737,1758,1773,1782,1799],{"__ignoreMap":179},[183,1700,1701,1703,1706,1708,1710,1712,1715,1717],{"class":185,"line":186},[183,1702,800],{"class":197},[183,1704,1705],{"class":284}," open",[183,1707,288],{"class":189},[183,1709,808],{"class":310},[183,1711,297],{"class":189},[183,1713,1714],{"class":813}," MouseEvent",[183,1716,320],{"class":189},[183,1718,819],{"class":189},[183,1720,1721,1723,1725,1727,1729,1731,1733,1735],{"class":185,"line":204},[183,1722,824],{"class":197},[183,1724,576],{"class":214},[183,1726,829],{"class":189},[183,1728,803],{"class":284},[183,1730,288],{"class":193},[183,1732,808],{"class":214},[183,1734,320],{"class":193},[183,1736,233],{"class":189},[183,1738,1739,1741,1743,1745,1748,1750,1752,1754,1756],{"class":185,"line":236},[183,1740,1174],{"class":207},[183,1742,307],{"class":193},[183,1744,168],{"class":214},[183,1746,1747],{"class":189}," ===",[183,1749,907],{"class":189},[183,1751,910],{"class":300},[183,1753,902],{"class":193},[183,1755,1217],{"class":207},[183,1757,233],{"class":189},[183,1759,1760,1763,1765,1767,1769,1771],{"class":185,"line":259},[183,1761,1762],{"class":214},"  anchored",[183,1764,281],{"class":189},[183,1766,1184],{"class":214},[183,1768,829],{"class":189},[183,1770,576],{"class":214},[183,1772,233],{"class":189},[183,1774,1775,1778,1780],{"class":185,"line":266},[183,1776,1777],{"class":284},"  place",[183,1779,997],{"class":193},[183,1781,233],{"class":189},[183,1783,1784,1786,1788,1790,1792,1795,1797],{"class":185,"line":363},[183,1785,1314],{"class":214},[183,1787,281],{"class":189},[183,1789,1184],{"class":214},[183,1791,281],{"class":189},[183,1793,1794],{"class":284},"showPopover",[183,1796,997],{"class":193},[183,1798,233],{"class":189},[183,1800,1801],{"class":185,"line":380},[183,1802,917],{"class":189},[147,1804,1806],{"id":1805},"check-that-it-follows-the-item","Check that it follows the item",[113,1808,1809],{},"Click an item, then scroll the container until that item is out of sight. The popover keeps moving with the item's position and moves outside the container.",[113,1811,1812,1813,1815],{},"To see that the item left the DOM, open the browser's Elements panel and expand the grid. It has no child with the item's ",[123,1814,787],{},", and the popover is still in the page.",[138,1817,1819],{"id":1818},"hide-the-popover-when-the-item-is-out-of-view","Hide the popover when the item is out of view",[113,1821,1822,1823,1825,1826,281],{},"The rectangle stays valid after the item scrolls out, so the popover moves outside the scroll container and may overlap other parts of the page. To close it instead, compare the rectangle with the scroll container's bounds at the end of ",[123,1824,1040],{},". Give the scroll container a template ref named ",[123,1827,1828],{},"scroller",[174,1830,1832],{"className":791,"code":1831,"language":793,"meta":179,"style":179},"const scroller = useTemplateRef(\"scroller\");\n\nfunction place() {\n  if (anchored.value \u003C 0 || !grid.value || !popover.value || !scroller.value) return;\n  query.root = grid.value.$el;\n  query.index = anchored.value;\n  query.layout = grid.value.measurement;\n  if (!getItemRect(query)) return;\n  const bounds = scroller.value.getBoundingClientRect();\n  if (query.rect.bottom \u003C bounds.top || query.rect.top > bounds.bottom) {\n    popover.value.hidePopover();\n    return;\n  }\n  popover.value.style.translate = `${query.rect.left}px ${query.rect.bottom}px`;\n}\n",[123,1833,1834,1857,1861,1871,1923,1945,1963,1985,2005,2030,2082,2100,2107,2112,2166],{"__ignoreMap":179},[183,1835,1836,1838,1841,1843,1845,1847,1849,1851,1853,1855],{"class":185,"line":186},[183,1837,269],{"class":197},[183,1839,1840],{"class":214}," scroller ",[183,1842,275],{"class":189},[183,1844,215],{"class":284},[183,1846,288],{"class":214},[183,1848,230],{"class":189},[183,1850,1828],{"class":227},[183,1852,230],{"class":189},[183,1854,320],{"class":214},[183,1856,233],{"class":189},[183,1858,1859],{"class":185,"line":204},[183,1860,263],{"emptyLinePlaceholder":262},[183,1862,1863,1865,1867,1869],{"class":185,"line":236},[183,1864,800],{"class":197},[183,1866,1165],{"class":284},[183,1868,997],{"class":189},[183,1870,819],{"class":189},[183,1872,1873,1875,1877,1879,1881,1883,1885,1887,1889,1891,1893,1895,1897,1899,1901,1903,1905,1907,1909,1911,1913,1915,1917,1919,1921],{"class":185,"line":259},[183,1874,1174],{"class":207},[183,1876,307],{"class":193},[183,1878,1179],{"class":214},[183,1880,281],{"class":189},[183,1882,1184],{"class":214},[183,1884,1187],{"class":189},[183,1886,1190],{"class":300},[183,1888,1193],{"class":189},[183,1890,1196],{"class":189},[183,1892,396],{"class":214},[183,1894,281],{"class":189},[183,1896,1184],{"class":214},[183,1898,1193],{"class":189},[183,1900,1196],{"class":189},[183,1902,125],{"class":214},[183,1904,281],{"class":189},[183,1906,1184],{"class":214},[183,1908,1193],{"class":189},[183,1910,1196],{"class":189},[183,1912,1828],{"class":214},[183,1914,281],{"class":189},[183,1916,1184],{"class":214},[183,1918,902],{"class":193},[183,1920,1217],{"class":207},[183,1922,233],{"class":189},[183,1924,1925,1927,1929,1931,1933,1935,1937,1939,1941,1943],{"class":185,"line":266},[183,1926,1224],{"class":214},[183,1928,281],{"class":189},[183,1930,943],{"class":214},[183,1932,829],{"class":189},[183,1934,1233],{"class":214},[183,1936,281],{"class":189},[183,1938,1184],{"class":214},[183,1940,281],{"class":189},[183,1942,1242],{"class":214},[183,1944,233],{"class":189},[183,1946,1947,1949,1951,1953,1955,1957,1959,1961],{"class":185,"line":363},[183,1948,1224],{"class":214},[183,1950,281],{"class":189},[183,1952,168],{"class":214},[183,1954,829],{"class":189},[183,1956,1257],{"class":214},[183,1958,281],{"class":189},[183,1960,1184],{"class":214},[183,1962,233],{"class":189},[183,1964,1965,1967,1969,1971,1973,1975,1977,1979,1981,1983],{"class":185,"line":380},[183,1966,1224],{"class":214},[183,1968,281],{"class":189},[183,1970,940],{"class":214},[183,1972,829],{"class":189},[183,1974,1233],{"class":214},[183,1976,281],{"class":189},[183,1978,1184],{"class":214},[183,1980,281],{"class":189},[183,1982,1284],{"class":214},[183,1984,233],{"class":189},[183,1986,1987,1989,1991,1993,1995,1997,1999,2001,2003],{"class":185,"line":405},[183,1988,1174],{"class":207},[183,1990,307],{"class":193},[183,1992,1295],{"class":189},[183,1994,933],{"class":284},[183,1996,288],{"class":193},[183,1998,1302],{"class":214},[183,2000,1305],{"class":193},[183,2002,1217],{"class":207},[183,2004,233],{"class":189},[183,2006,2007,2009,2012,2014,2017,2019,2021,2023,2026,2028],{"class":185,"line":546},[183,2008,824],{"class":197},[183,2010,2011],{"class":214}," bounds",[183,2013,829],{"class":189},[183,2015,2016],{"class":214}," scroller",[183,2018,281],{"class":189},[183,2020,1184],{"class":214},[183,2022,281],{"class":189},[183,2024,2025],{"class":284},"getBoundingClientRect",[183,2027,997],{"class":193},[183,2029,233],{"class":189},[183,2031,2032,2034,2036,2038,2040,2042,2044,2046,2048,2050,2052,2055,2057,2060,2062,2064,2066,2068,2071,2073,2075,2077,2079],{"class":185,"line":552},[183,2033,1174],{"class":207},[183,2035,307],{"class":193},[183,2037,1302],{"class":214},[183,2039,281],{"class":189},[183,2041,1339],{"class":214},[183,2043,281],{"class":189},[183,2045,1362],{"class":214},[183,2047,1187],{"class":189},[183,2049,2011],{"class":214},[183,2051,281],{"class":189},[183,2053,2054],{"class":214},"top",[183,2056,1193],{"class":189},[183,2058,2059],{"class":214}," query",[183,2061,281],{"class":189},[183,2063,1339],{"class":214},[183,2065,281],{"class":189},[183,2067,2054],{"class":214},[183,2069,2070],{"class":189}," >",[183,2072,2011],{"class":214},[183,2074,281],{"class":189},[183,2076,1362],{"class":214},[183,2078,902],{"class":193},[183,2080,2081],{"class":189},"{\n",[183,2083,2084,2087,2089,2091,2093,2096,2098],{"class":185,"line":591},[183,2085,2086],{"class":214},"    popover",[183,2088,281],{"class":189},[183,2090,1184],{"class":214},[183,2092,281],{"class":189},[183,2094,2095],{"class":284},"hidePopover",[183,2097,997],{"class":193},[183,2099,233],{"class":189},[183,2101,2102,2105],{"class":185,"line":646},[183,2103,2104],{"class":207},"    return",[183,2106,233],{"class":189},[183,2108,2109],{"class":185,"line":656},[183,2110,2111],{"class":189},"  }\n",[183,2113,2114,2116,2118,2120,2122,2124,2126,2128,2130,2132,2134,2136,2138,2140,2142,2144,2146,2148,2150,2152,2154,2156,2158,2160,2162,2164],{"class":185,"line":661},[183,2115,1314],{"class":214},[183,2117,281],{"class":189},[183,2119,1184],{"class":214},[183,2121,281],{"class":189},[183,2123,607],{"class":214},[183,2125,281],{"class":189},[183,2127,1327],{"class":214},[183,2129,829],{"class":189},[183,2131,1332],{"class":189},[183,2133,1302],{"class":214},[183,2135,281],{"class":189},[183,2137,1339],{"class":214},[183,2139,281],{"class":189},[183,2141,1344],{"class":214},[183,2143,584],{"class":189},[183,2145,1349],{"class":227},[183,2147,341],{"class":189},[183,2149,1302],{"class":214},[183,2151,281],{"class":189},[183,2153,1339],{"class":214},[183,2155,281],{"class":189},[183,2157,1362],{"class":214},[183,2159,584],{"class":189},[183,2161,1367],{"class":227},[183,2163,1370],{"class":189},[183,2165,233],{"class":189},[183,2167,2168],{"class":185,"line":690},[183,2169,917],{"class":189},[113,2171,2172,2173,2175],{},"The code reads every rectangle before it writes the ",[123,2174,1327],{}," style. Reading a layout value after a style write forces the browser to recompute layout at once, which slows every scroll event.",[138,2177,2179],{"id":2178},"let-css-place-the-popover-with-anchor-positioning","Let CSS place the popover with anchor positioning",[113,2181,2182,2183,2189,2190,2192],{},"In browsers that support ",[417,2184,2188],{"href":2185,"rel":2186},"https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FCSS\u002FCSS_anchor_positioning",[2187],"nofollow","CSS anchor positioning",", the browser can place the popover, with no ",[123,2191,1040],{}," call on scroll. The browser needs the item to be in the DOM, so this works only while the anchored item is rendered.",[113,2194,2195,2198,2199,2202,2203,2206,2207,281],{},[123,2196,2197],{},"createItemTracker"," tells you when an element starts or stops rendering an index. Set ",[123,2200,2201],{},"anchor-name"," on the element in ",[123,2204,2205],{},"onBind",", and close the popover in ",[123,2208,2209],{},"onUnbind",[174,2211,2213],{"className":791,"code":2212,"language":793,"meta":179,"style":179},"import { createItemTracker } from \"vvirtual-grid\u002Fprimitives\";\n\nconst track = createItemTracker({\n  onBind: (index, element) => {\n    element.style.anchorName = index === anchored.value ? \"--item\" : \"\";\n  },\n  onUnbind: (index) => {\n    if (index === anchored.value) popover.value.hidePopover();\n  },\n});\n",[123,2214,2215,2236,2240,2255,2277,2320,2325,2342,2375,2379],{"__ignoreMap":179},[183,2216,2217,2219,2221,2224,2226,2228,2230,2232,2234],{"class":185,"line":186},[183,2218,208],{"class":207},[183,2220,211],{"class":189},[183,2222,2223],{"class":214}," createItemTracker",[183,2225,218],{"class":189},[183,2227,221],{"class":207},[183,2229,224],{"class":189},[183,2231,975],{"class":227},[183,2233,230],{"class":189},[183,2235,233],{"class":189},[183,2237,2238],{"class":185,"line":204},[183,2239,263],{"emptyLinePlaceholder":262},[183,2241,2242,2244,2247,2249,2251,2253],{"class":185,"line":236},[183,2243,269],{"class":197},[183,2245,2246],{"class":214}," track ",[183,2248,275],{"class":189},[183,2250,2223],{"class":284},[183,2252,288],{"class":214},[183,2254,2081],{"class":189},[183,2256,2257,2260,2262,2264,2266,2268,2271,2273,2275],{"class":185,"line":259},[183,2258,2259],{"class":284},"  onBind",[183,2261,297],{"class":189},[183,2263,307],{"class":189},[183,2265,168],{"class":310},[183,2267,314],{"class":189},[183,2269,2270],{"class":310}," element",[183,2272,320],{"class":189},[183,2274,323],{"class":197},[183,2276,819],{"class":189},[183,2278,2279,2282,2284,2286,2288,2291,2293,2295,2297,2299,2301,2303,2305,2307,2310,2312,2315,2318],{"class":185,"line":266},[183,2280,2281],{"class":214},"    element",[183,2283,281],{"class":189},[183,2285,607],{"class":214},[183,2287,281],{"class":189},[183,2289,2290],{"class":214},"anchorName",[183,2292,829],{"class":189},[183,2294,576],{"class":214},[183,2296,1747],{"class":189},[183,2298,1257],{"class":214},[183,2300,281],{"class":189},[183,2302,1184],{"class":214},[183,2304,874],{"class":189},[183,2306,224],{"class":189},[183,2308,2309],{"class":227},"--item",[183,2311,230],{"class":189},[183,2313,2314],{"class":189}," :",[183,2316,2317],{"class":189}," \"\"",[183,2319,233],{"class":189},[183,2321,2322],{"class":185,"line":363},[183,2323,2324],{"class":189},"  },\n",[183,2326,2327,2330,2332,2334,2336,2338,2340],{"class":185,"line":380},[183,2328,2329],{"class":284},"  onUnbind",[183,2331,297],{"class":189},[183,2333,307],{"class":189},[183,2335,168],{"class":310},[183,2337,320],{"class":189},[183,2339,323],{"class":197},[183,2341,819],{"class":189},[183,2343,2344,2347,2349,2351,2353,2355,2357,2359,2361,2363,2365,2367,2369,2371,2373],{"class":185,"line":405},[183,2345,2346],{"class":207},"    if",[183,2348,307],{"class":193},[183,2350,168],{"class":214},[183,2352,1747],{"class":189},[183,2354,1257],{"class":214},[183,2356,281],{"class":189},[183,2358,1184],{"class":214},[183,2360,902],{"class":193},[183,2362,125],{"class":214},[183,2364,281],{"class":189},[183,2366,1184],{"class":214},[183,2368,281],{"class":189},[183,2370,2095],{"class":284},[183,2372,997],{"class":193},[183,2374,233],{"class":189},[183,2376,2377],{"class":185,"line":546},[183,2378,2324],{"class":189},[183,2380,2381,2383,2385],{"class":185,"line":552},[183,2382,584],{"class":189},[183,2384,320],{"class":214},[183,2386,233],{"class":189},[174,2388,2392],{"className":2389,"code":2390,"language":2391,"meta":179,"style":179},"language-css shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","[popover] {\n  position-anchor: --item;\n  inset: auto;\n  margin: 0;\n  top: anchor(bottom);\n  left: anchor(left);\n}\n","css",[123,2393,2394,2406,2418,2431,2442,2454,2466],{"__ignoreMap":179},[183,2395,2396,2399,2401,2404],{"class":185,"line":186},[183,2397,2398],{"class":189},"[",[183,2400,125],{"class":197},[183,2402,2403],{"class":189},"]",[183,2405,819],{"class":189},[183,2407,2408,2411,2413,2416],{"class":185,"line":204},[183,2409,2410],{"class":214},"  position-anchor",[183,2412,297],{"class":189},[183,2414,2415],{"class":214}," --item",[183,2417,233],{"class":189},[183,2419,2420,2424,2426,2429],{"class":185,"line":236},[183,2421,2423],{"class":2422},"sqsOY","  inset",[183,2425,297],{"class":189},[183,2427,2428],{"class":214}," auto",[183,2430,233],{"class":189},[183,2432,2433,2436,2438,2440],{"class":185,"line":259},[183,2434,2435],{"class":2422},"  margin",[183,2437,297],{"class":189},[183,2439,1190],{"class":300},[183,2441,233],{"class":189},[183,2443,2444,2447,2449,2452],{"class":185,"line":266},[183,2445,2446],{"class":2422},"  top",[183,2448,297],{"class":189},[183,2450,2451],{"class":214}," anchor(bottom)",[183,2453,233],{"class":189},[183,2455,2456,2459,2461,2464],{"class":185,"line":363},[183,2457,2458],{"class":2422},"  left",[183,2460,297],{"class":189},[183,2462,2463],{"class":214}," anchor(left)",[183,2465,233],{"class":189},[183,2467,2468],{"class":185,"line":380},[183,2469,917],{"class":189},[113,2471,153,2472,1016,2475,2477],{},[123,2473,2474],{},"@render=\"track(grid.$el)\"",[123,2476,779],{},", so the tracker compares the rendered elements after each patch.",[113,2479,2480,2481,2483,2484,2486],{},"The tracker reports changes in what the grid renders. It does not notice when ",[123,2482,1179],{}," changes. To anchor an item that is already rendered, set ",[123,2485,2201],{}," yourself, and clear it on the previous item.",[174,2488,2490],{"className":791,"code":2489,"language":793,"meta":179,"style":179},"function anchor(index: number) {\n  const root: HTMLElement = grid.value.$el;\n  const previous = root.querySelector(\":scope > [style*='anchor-name']\");\n  if (previous) (previous as HTMLElement).style.anchorName = \"\";\n  const next = root.querySelector(`:scope > [data-index=\"${index}\"]`);\n  if (next) (next as HTMLElement).style.anchorName = \"--item\";\n  anchored.value = index;\n}\n",[123,2491,2492,2512,2537,2566,2600,2637,2674,2688],{"__ignoreMap":179},[183,2493,2494,2496,2499,2501,2503,2505,2508,2510],{"class":185,"line":186},[183,2495,800],{"class":197},[183,2497,2498],{"class":284}," anchor",[183,2500,288],{"class":189},[183,2502,168],{"class":310},[183,2504,297],{"class":189},[183,2506,2507],{"class":813}," number",[183,2509,320],{"class":189},[183,2511,819],{"class":189},[183,2513,2514,2516,2519,2521,2523,2525,2527,2529,2531,2533,2535],{"class":185,"line":204},[183,2515,824],{"class":197},[183,2517,2518],{"class":214}," root",[183,2520,297],{"class":189},[183,2522,888],{"class":813},[183,2524,829],{"class":189},[183,2526,1233],{"class":214},[183,2528,281],{"class":189},[183,2530,1184],{"class":214},[183,2532,281],{"class":189},[183,2534,1242],{"class":214},[183,2536,233],{"class":189},[183,2538,2539,2541,2544,2546,2548,2550,2553,2555,2557,2560,2562,2564],{"class":185,"line":236},[183,2540,824],{"class":197},[183,2542,2543],{"class":214}," previous",[183,2545,829],{"class":189},[183,2547,2518],{"class":214},[183,2549,281],{"class":189},[183,2551,2552],{"class":284},"querySelector",[183,2554,288],{"class":193},[183,2556,230],{"class":189},[183,2558,2559],{"class":227},":scope > [style*='anchor-name']",[183,2561,230],{"class":189},[183,2563,320],{"class":193},[183,2565,233],{"class":189},[183,2567,2568,2570,2572,2575,2578,2580,2582,2584,2586,2588,2590,2592,2594,2596,2598],{"class":185,"line":259},[183,2569,1174],{"class":207},[183,2571,307],{"class":193},[183,2573,2574],{"class":214},"previous",[183,2576,2577],{"class":193},") (",[183,2579,2574],{"class":214},[183,2581,841],{"class":207},[183,2583,888],{"class":813},[183,2585,320],{"class":193},[183,2587,281],{"class":189},[183,2589,607],{"class":214},[183,2591,281],{"class":189},[183,2593,2290],{"class":214},[183,2595,829],{"class":189},[183,2597,2317],{"class":189},[183,2599,233],{"class":189},[183,2601,2602,2604,2607,2609,2611,2613,2615,2617,2619,2622,2624,2626,2628,2631,2633,2635],{"class":185,"line":266},[183,2603,824],{"class":197},[183,2605,2606],{"class":214}," next",[183,2608,829],{"class":189},[183,2610,2518],{"class":214},[183,2612,281],{"class":189},[183,2614,2552],{"class":284},[183,2616,288],{"class":193},[183,2618,1370],{"class":189},[183,2620,2621],{"class":227},":scope > [data-index=\"",[183,2623,341],{"class":189},[183,2625,168],{"class":214},[183,2627,584],{"class":189},[183,2629,2630],{"class":227},"\"]",[183,2632,1370],{"class":189},[183,2634,320],{"class":193},[183,2636,233],{"class":189},[183,2638,2639,2641,2643,2646,2648,2650,2652,2654,2656,2658,2660,2662,2664,2666,2668,2670,2672],{"class":185,"line":363},[183,2640,1174],{"class":207},[183,2642,307],{"class":193},[183,2644,2645],{"class":214},"next",[183,2647,2577],{"class":193},[183,2649,2645],{"class":214},[183,2651,841],{"class":207},[183,2653,888],{"class":813},[183,2655,320],{"class":193},[183,2657,281],{"class":189},[183,2659,607],{"class":214},[183,2661,281],{"class":189},[183,2663,2290],{"class":214},[183,2665,829],{"class":189},[183,2667,224],{"class":189},[183,2669,2309],{"class":227},[183,2671,230],{"class":189},[183,2673,233],{"class":189},[183,2675,2676,2678,2680,2682,2684,2686],{"class":185,"line":380},[183,2677,1762],{"class":214},[183,2679,281],{"class":189},[183,2681,1184],{"class":214},[183,2683,829],{"class":189},[183,2685,576],{"class":214},[183,2687,233],{"class":189},[183,2689,2690],{"class":185,"line":405},[183,2691,917],{"class":189},[113,2693,1479,2694,2697,2698,2700,2701,2706,2707,2709],{},[123,2695,2696],{},"anchor(index)"," from the ",[123,2699,1616],{}," handler in ",[417,2702,1479,2704,1482],{"href":2703},"#call-place-when-the-position-can-change",[123,2705,1040],{}," instead of setting ",[123,2708,1179],{}," directly. It clears the previous element and sets the new one when that element is already rendered.",[138,2711,2713],{"id":2712},"dispatch-your-own-events-from-the-grid","Dispatch your own events from the grid",[113,2715,2716,2717,2720,2721,2724,2725,2728],{},"The grid does not emit events for pointer or focus actions on items. A listener on the grid element is the lowest-level hook for those, and you can turn what it reads into an event of your own. For example, to tell other components which item got focus, listen to ",[123,2718,2719],{},"focusin",", find the index as in ",[417,2722,769],{"href":2723},"#find-the-clicked-index",", and dispatch a ",[123,2726,2727],{},"CustomEvent"," that carries it.",[174,2730,2732],{"className":791,"code":2731,"language":793,"meta":179,"style":179},"function onFocusIn(event: FocusEvent) {\n  const index = indexFromEvent(event);\n  if (index === -1) return;\n  grid.value.$el.dispatchEvent(new CustomEvent(\"item-focus\", { detail: index }));\n}\n",[123,2733,2734,2754,2772,2792,2844],{"__ignoreMap":179},[183,2735,2736,2738,2741,2743,2745,2747,2750,2752],{"class":185,"line":186},[183,2737,800],{"class":197},[183,2739,2740],{"class":284}," onFocusIn",[183,2742,288],{"class":189},[183,2744,808],{"class":310},[183,2746,297],{"class":189},[183,2748,2749],{"class":813}," FocusEvent",[183,2751,320],{"class":189},[183,2753,819],{"class":189},[183,2755,2756,2758,2760,2762,2764,2766,2768,2770],{"class":185,"line":204},[183,2757,824],{"class":197},[183,2759,576],{"class":214},[183,2761,829],{"class":189},[183,2763,803],{"class":284},[183,2765,288],{"class":193},[183,2767,808],{"class":214},[183,2769,320],{"class":193},[183,2771,233],{"class":189},[183,2773,2774,2776,2778,2780,2782,2784,2786,2788,2790],{"class":185,"line":236},[183,2775,1174],{"class":207},[183,2777,307],{"class":193},[183,2779,168],{"class":214},[183,2781,1747],{"class":189},[183,2783,907],{"class":189},[183,2785,910],{"class":300},[183,2787,902],{"class":193},[183,2789,1217],{"class":207},[183,2791,233],{"class":189},[183,2793,2794,2797,2799,2801,2803,2805,2807,2810,2812,2815,2818,2820,2822,2825,2827,2829,2831,2834,2836,2838,2840,2842],{"class":185,"line":259},[183,2795,2796],{"class":214},"  grid",[183,2798,281],{"class":189},[183,2800,1184],{"class":214},[183,2802,281],{"class":189},[183,2804,1242],{"class":214},[183,2806,281],{"class":189},[183,2808,2809],{"class":284},"dispatchEvent",[183,2811,288],{"class":193},[183,2813,2814],{"class":189},"new",[183,2816,2817],{"class":284}," CustomEvent",[183,2819,288],{"class":193},[183,2821,230],{"class":189},[183,2823,2824],{"class":227},"item-focus",[183,2826,230],{"class":189},[183,2828,314],{"class":189},[183,2830,211],{"class":189},[183,2832,2833],{"class":193}," detail",[183,2835,297],{"class":189},[183,2837,576],{"class":214},[183,2839,218],{"class":189},[183,2841,358],{"class":193},[183,2843,233],{"class":189},[183,2845,2846],{"class":185,"line":266},[183,2847,917],{"class":189},[113,2849,153,2850,1016,2853,2855,2856,2859,2860,161,2863,281],{},[123,2851,2852],{},"@focusin=\"onFocusIn\"",[123,2854,779],{},". Other code listens on the grid element with ",[123,2857,2858],{},"grid.value.$el.addEventListener(\"item-focus\", (event) => event.detail)",". The same pattern works for ",[123,2861,2862],{},"pointerover",[123,2864,2865],{},"contextmenu",[113,2867,2868,2869,2871,2872,281],{},"To place an overlay with a library instead of your own ",[123,2870,1327],{},", read ",[417,2873,2874],{"href":74},"Position with Floating UI",[607,2876,2877],{},"html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sqsOY, html code.shiki .sqsOY{--shiki-light:#8796B0;--shiki-default:#B2CCD6;--shiki-dark:#B2CCD6}",{"title":179,"searchDepth":204,"depth":204,"links":2879},[2880,2889,2890,2891],{"id":140,"depth":204,"text":141,"children":2881},[2882,2883,2884,2885,2886,2888],{"id":149,"depth":236,"text":150},{"id":768,"depth":236,"text":769},{"id":927,"depth":236,"text":928},{"id":1033,"depth":236,"text":1034},{"id":1478,"depth":236,"text":2887},"Call place() when the position can change",{"id":1805,"depth":236,"text":1806},{"id":1818,"depth":204,"text":1819},{"id":2178,"depth":204,"text":2179},{"id":2712,"depth":204,"text":2713},"Open a native popover under a clicked grid item and keep it attached while the grid scrolls.","md",null,{},{"icon":71},{"title":68,"description":2892},"p6gXJ3JbZ4ODO436glqgpKi0TXfmRwWj1wC_4JmpCSo",[2900,2902],{"title":64,"path":65,"stem":66,"description":2901,"icon":56,"children":-1},"Make a screen reader announce \"item 4,200 of 10,000\" and let keyboard users move through the grid.",{"title":73,"path":74,"stem":75,"description":2903,"icon":76,"children":-1},"Use the rectangle the grid computes as a Floating UI virtual element, so a floating element follows items that are not rendered.",1794785668767]