[{"data":1,"prerenderedAt":1673},["ShallowReactive",2],{"navigation_docs":3,"-guides-performance":107,"-guides-performance-surround":1668},[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":83,"body":109,"description":1661,"extension":1662,"links":1663,"meta":1664,"navigation":1665,"path":84,"seo":1666,"stem":85,"__hash__":1667},"docs\u002F3.guides\u002F5.performance.md",{"type":110,"value":111,"toc":1651},"minimark",[112,121,136,1648],[113,114,115,116,120],"p",{},"This guide covers the changes that keep scrolling responsive, in order of impact. The grid does little on a scroll event. If the first visible row has not changed, it compares two numbers and stops, and it recomputes the rendered window only when that row changes. The ",[117,118,119],"a",{"href":49},"benchmarks"," show that this work is a small fraction of a frame. What slows a grid down is the code you add around it.",[113,122,123,124,126,127,131,132,135],{},"The samples assume the grid from ",[117,125,16],{"href":17},", including its ",[128,129,130],"code",{},"length"," and ",[128,133,134],{},"pageProvider",".",[137,138,139,144,154,416,419,430,438,444,710,716,928,941,944,948,954,1176,1417,1428,1437,1444,1447,1450,1456,1615,1618,1622,1631,1635,1638],"steps",{},[140,141,143],"h3",{"id":142},"debounce-the-page-provider","Debounce the page provider",[113,145,146,147,149,150,153],{},"If your ",[128,148,134],{}," calls a network API, set ",[128,151,152],{},"pageProviderDebounceTime"," to about 150 milliseconds.",[155,156,161],"pre",{"className":157,"code":158,"language":159,"meta":160,"style":160},"language-vue shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003Ctemplate>\n  \u003Cdiv class=\"h-96 overflow-y-auto\">\n    \u003CVirtualGrid\n      :length=\"length\"\n      :page-size=\"40\"\n      :page-provider=\"pageProvider\"\n      :page-provider-debounce-time=\"150\"\n    >\n      \u003Ctemplate #default=\"{ item, index, style }\">\n        \u003Cdiv :style=\"style\" :data-index=\"index\">{{ item.name }}\u003C\u002Fdiv>\n      \u003C\u002Ftemplate>\n    \u003C\u002FVirtualGrid>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n","vue","",[128,162,163,179,206,215,233,251,267,284,290,332,377,387,397,407],{"__ignoreMap":160},[164,165,168,172,176],"span",{"class":166,"line":167},"line",1,[164,169,171],{"class":170},"sMK4o","\u003C",[164,173,175],{"class":174},"swJcz","template",[164,177,178],{"class":170},">\n",[164,180,182,185,188,192,195,198,202,204],{"class":166,"line":181},2,[164,183,184],{"class":170},"  \u003C",[164,186,187],{"class":174},"div",[164,189,191],{"class":190},"spNyl"," class",[164,193,194],{"class":170},"=",[164,196,197],{"class":170},"\"",[164,199,201],{"class":200},"sfazB","h-96 overflow-y-auto",[164,203,197],{"class":170},[164,205,178],{"class":170},[164,207,209,212],{"class":166,"line":208},3,[164,210,211],{"class":170},"    \u003C",[164,213,214],{"class":174},"VirtualGrid\n",[164,216,218,221,223,225,227,230],{"class":166,"line":217},4,[164,219,220],{"class":170},"      :",[164,222,130],{"class":190},[164,224,194],{"class":170},[164,226,197],{"class":170},[164,228,130],{"class":229},"sTEyZ",[164,231,232],{"class":170},"\"\n",[164,234,236,238,241,243,245,249],{"class":166,"line":235},5,[164,237,220],{"class":170},[164,239,240],{"class":190},"page-size",[164,242,194],{"class":170},[164,244,197],{"class":170},[164,246,248],{"class":247},"sbssI","40",[164,250,232],{"class":170},[164,252,254,256,259,261,263,265],{"class":166,"line":253},6,[164,255,220],{"class":170},[164,257,258],{"class":190},"page-provider",[164,260,194],{"class":170},[164,262,197],{"class":170},[164,264,134],{"class":229},[164,266,232],{"class":170},[164,268,270,272,275,277,279,282],{"class":166,"line":269},7,[164,271,220],{"class":170},[164,273,274],{"class":190},"page-provider-debounce-time",[164,276,194],{"class":170},[164,278,197],{"class":170},[164,280,281],{"class":247},"150",[164,283,232],{"class":170},[164,285,287],{"class":166,"line":286},8,[164,288,289],{"class":170},"    >\n",[164,291,293,296,298,301,304,306,308,311,314,317,320,322,325,328,330],{"class":166,"line":292},9,[164,294,295],{"class":170},"      \u003C",[164,297,175],{"class":174},[164,299,300],{"class":170}," #",[164,302,303],{"class":190},"default",[164,305,194],{"class":170},[164,307,197],{"class":170},[164,309,310],{"class":170},"{",[164,312,313],{"class":229}," item",[164,315,316],{"class":170},",",[164,318,319],{"class":229}," index",[164,321,316],{"class":170},[164,323,324],{"class":229}," style ",[164,326,327],{"class":170},"}",[164,329,197],{"class":170},[164,331,178],{"class":170},[164,333,335,338,340,343,345,347,350,352,355,357,359,362,364,367,370,373,375],{"class":166,"line":334},10,[164,336,337],{"class":170},"        \u003C",[164,339,187],{"class":174},[164,341,342],{"class":190}," :style",[164,344,194],{"class":170},[164,346,197],{"class":170},[164,348,349],{"class":200},"style",[164,351,197],{"class":170},[164,353,354],{"class":190}," :data-index",[164,356,194],{"class":170},[164,358,197],{"class":170},[164,360,361],{"class":200},"index",[164,363,197],{"class":170},[164,365,366],{"class":170},">",[164,368,369],{"class":229},"{{ item.name }}",[164,371,372],{"class":170},"\u003C\u002F",[164,374,187],{"class":174},[164,376,178],{"class":170},[164,378,380,383,385],{"class":166,"line":379},11,[164,381,382],{"class":170},"      \u003C\u002F",[164,384,175],{"class":174},[164,386,178],{"class":170},[164,388,390,393,395],{"class":166,"line":389},12,[164,391,392],{"class":170},"    \u003C\u002F",[164,394,33],{"class":174},[164,396,178],{"class":170},[164,398,400,403,405],{"class":166,"line":399},13,[164,401,402],{"class":170},"  \u003C\u002F",[164,404,187],{"class":174},[164,406,178],{"class":170},[164,408,410,412,414],{"class":166,"line":409},14,[164,411,372],{"class":170},[164,413,175],{"class":174},[164,415,178],{"class":170},[113,417,418],{},"During a fast scroll, the rendered window crosses dozens of pages in a second. Without a debounce, the grid requests every one of them, and the server prepares pages the user never sees. With a debounce, the grid waits until the scroll has paused for 150 ms, then requests only the pages in the rendered window it stopped on. About 150 ms is short enough that a deliberate scroll still loads quickly, and long enough to skip the pages a fast flick crosses.",[113,420,421,422,425,426,429],{},"With the default of ",[128,423,424],{},"0",", the grid requests pages at once. That is fine for ",[128,427,428],{},"createPageProvider",", which reads an array in memory.",[140,431,433,434,437],{"id":432},"reuse-query-objects-in-viewport-scroll-handlers","Reuse query objects in ",[128,435,436],{},"viewport-scroll"," handlers",[113,439,440,441,443],{},"The grid emits ",[128,442,436],{}," on every scroll event. Create the query object once, outside the handler, and update its fields on each call.",[155,445,447],{"className":157,"code":446,"language":159,"meta":160,"style":160},"\u003Cscript setup lang=\"ts\">\nimport { useTemplateRef } from \"vue\";\nimport { createRectQuery, getItemRect } from \"vvirtual-grid\u002Fprimitives\";\n\nconst grid = useTemplateRef(\"grid\");\nconst query = createRectQuery();\n\nfunction onViewportScroll() {\n  query.root = grid.value.$el;\n  query.layout = grid.value.measurement;\n  query.index = 42;\n  if (getItemRect(query)) {\n    \u002F\u002F query.rect now holds the item's position on screen\n  }\n}\n\u003C\u002Fscript>\n",[128,448,449,473,501,528,534,562,578,582,595,623,647,662,684,690,695,701],{"__ignoreMap":160},[164,450,451,453,456,459,462,464,466,469,471],{"class":166,"line":167},[164,452,171],{"class":170},[164,454,455],{"class":174},"script",[164,457,458],{"class":190}," setup",[164,460,461],{"class":190}," lang",[164,463,194],{"class":170},[164,465,197],{"class":170},[164,467,468],{"class":200},"ts",[164,470,197],{"class":170},[164,472,178],{"class":170},[164,474,475,479,482,485,488,491,494,496,498],{"class":166,"line":181},[164,476,478],{"class":477},"s7zQu","import",[164,480,481],{"class":170}," {",[164,483,484],{"class":229}," useTemplateRef",[164,486,487],{"class":170}," }",[164,489,490],{"class":477}," from",[164,492,493],{"class":170}," \"",[164,495,159],{"class":200},[164,497,197],{"class":170},[164,499,500],{"class":170},";\n",[164,502,503,505,507,510,512,515,517,519,521,524,526],{"class":166,"line":208},[164,504,478],{"class":477},[164,506,481],{"class":170},[164,508,509],{"class":229}," createRectQuery",[164,511,316],{"class":170},[164,513,514],{"class":229}," getItemRect",[164,516,487],{"class":170},[164,518,490],{"class":477},[164,520,493],{"class":170},[164,522,523],{"class":200},"vvirtual-grid\u002Fprimitives",[164,525,197],{"class":170},[164,527,500],{"class":170},[164,529,530],{"class":166,"line":217},[164,531,533],{"emptyLinePlaceholder":532},true,"\n",[164,535,536,539,542,544,547,550,552,555,557,560],{"class":166,"line":235},[164,537,538],{"class":190},"const",[164,540,541],{"class":229}," grid ",[164,543,194],{"class":170},[164,545,484],{"class":546},"s2Zo4",[164,548,549],{"class":229},"(",[164,551,197],{"class":170},[164,553,554],{"class":200},"grid",[164,556,197],{"class":170},[164,558,559],{"class":229},")",[164,561,500],{"class":170},[164,563,564,566,569,571,573,576],{"class":166,"line":253},[164,565,538],{"class":190},[164,567,568],{"class":229}," query ",[164,570,194],{"class":170},[164,572,509],{"class":546},[164,574,575],{"class":229},"()",[164,577,500],{"class":170},[164,579,580],{"class":166,"line":269},[164,581,533],{"emptyLinePlaceholder":532},[164,583,584,587,590,592],{"class":166,"line":286},[164,585,586],{"class":190},"function",[164,588,589],{"class":546}," onViewportScroll",[164,591,575],{"class":170},[164,593,594],{"class":170}," {\n",[164,596,597,600,602,605,608,611,613,616,618,621],{"class":166,"line":292},[164,598,599],{"class":229},"  query",[164,601,135],{"class":170},[164,603,604],{"class":229},"root",[164,606,607],{"class":170}," =",[164,609,610],{"class":229}," grid",[164,612,135],{"class":170},[164,614,615],{"class":229},"value",[164,617,135],{"class":170},[164,619,620],{"class":229},"$el",[164,622,500],{"class":170},[164,624,625,627,629,632,634,636,638,640,642,645],{"class":166,"line":334},[164,626,599],{"class":229},[164,628,135],{"class":170},[164,630,631],{"class":229},"layout",[164,633,607],{"class":170},[164,635,610],{"class":229},[164,637,135],{"class":170},[164,639,615],{"class":229},[164,641,135],{"class":170},[164,643,644],{"class":229},"measurement",[164,646,500],{"class":170},[164,648,649,651,653,655,657,660],{"class":166,"line":379},[164,650,599],{"class":229},[164,652,135],{"class":170},[164,654,361],{"class":229},[164,656,607],{"class":170},[164,658,659],{"class":247}," 42",[164,661,500],{"class":170},[164,663,664,667,670,673,675,678,681],{"class":166,"line":389},[164,665,666],{"class":477},"  if",[164,668,669],{"class":174}," (",[164,671,672],{"class":546},"getItemRect",[164,674,549],{"class":174},[164,676,677],{"class":229},"query",[164,679,680],{"class":174},")) ",[164,682,683],{"class":170},"{\n",[164,685,686],{"class":166,"line":399},[164,687,689],{"class":688},"sHwdD","    \u002F\u002F query.rect now holds the item's position on screen\n",[164,691,692],{"class":166,"line":409},[164,693,694],{"class":170},"  }\n",[164,696,698],{"class":166,"line":697},15,[164,699,700],{"class":170},"}\n",[164,702,704,706,708],{"class":166,"line":703},16,[164,705,372],{"class":170},[164,707,455],{"class":174},[164,709,178],{"class":170},[113,711,712,713,715],{},"Bind the handler to the ",[128,714,436],{}," event.",[155,717,719],{"className":157,"code":718,"language":159,"meta":160,"style":160},"\u003Ctemplate>\n  \u003Cdiv class=\"h-96 overflow-y-auto\">\n    \u003CVirtualGrid\n      ref=\"grid\"\n      :length=\"length\"\n      :page-size=\"40\"\n      :page-provider=\"pageProvider\"\n      @viewport-scroll=\"onViewportScroll\"\n    >\n      \u003Ctemplate #default=\"{ item, index, style }\">\n        \u003Cdiv :style=\"style\" :data-index=\"index\">{{ item.name }}\u003C\u002Fdiv>\n      \u003C\u002Ftemplate>\n    \u003C\u002FVirtualGrid>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n",[128,720,721,729,747,753,766,780,794,808,824,828,860,896,904,912,920],{"__ignoreMap":160},[164,722,723,725,727],{"class":166,"line":167},[164,724,171],{"class":170},[164,726,175],{"class":174},[164,728,178],{"class":170},[164,730,731,733,735,737,739,741,743,745],{"class":166,"line":181},[164,732,184],{"class":170},[164,734,187],{"class":174},[164,736,191],{"class":190},[164,738,194],{"class":170},[164,740,197],{"class":170},[164,742,201],{"class":200},[164,744,197],{"class":170},[164,746,178],{"class":170},[164,748,749,751],{"class":166,"line":208},[164,750,211],{"class":170},[164,752,214],{"class":174},[164,754,755,758,760,762,764],{"class":166,"line":217},[164,756,757],{"class":190},"      ref",[164,759,194],{"class":170},[164,761,197],{"class":170},[164,763,554],{"class":200},[164,765,232],{"class":170},[164,767,768,770,772,774,776,778],{"class":166,"line":235},[164,769,220],{"class":170},[164,771,130],{"class":190},[164,773,194],{"class":170},[164,775,197],{"class":170},[164,777,130],{"class":229},[164,779,232],{"class":170},[164,781,782,784,786,788,790,792],{"class":166,"line":253},[164,783,220],{"class":170},[164,785,240],{"class":190},[164,787,194],{"class":170},[164,789,197],{"class":170},[164,791,248],{"class":247},[164,793,232],{"class":170},[164,795,796,798,800,802,804,806],{"class":166,"line":269},[164,797,220],{"class":170},[164,799,258],{"class":190},[164,801,194],{"class":170},[164,803,197],{"class":170},[164,805,134],{"class":229},[164,807,232],{"class":170},[164,809,810,813,815,817,819,822],{"class":166,"line":286},[164,811,812],{"class":170},"      @",[164,814,436],{"class":190},[164,816,194],{"class":170},[164,818,197],{"class":170},[164,820,821],{"class":229},"onViewportScroll",[164,823,232],{"class":170},[164,825,826],{"class":166,"line":292},[164,827,289],{"class":170},[164,829,830,832,834,836,838,840,842,844,846,848,850,852,854,856,858],{"class":166,"line":334},[164,831,295],{"class":170},[164,833,175],{"class":174},[164,835,300],{"class":170},[164,837,303],{"class":190},[164,839,194],{"class":170},[164,841,197],{"class":170},[164,843,310],{"class":170},[164,845,313],{"class":229},[164,847,316],{"class":170},[164,849,319],{"class":229},[164,851,316],{"class":170},[164,853,324],{"class":229},[164,855,327],{"class":170},[164,857,197],{"class":170},[164,859,178],{"class":170},[164,861,862,864,866,868,870,872,874,876,878,880,882,884,886,888,890,892,894],{"class":166,"line":379},[164,863,337],{"class":170},[164,865,187],{"class":174},[164,867,342],{"class":190},[164,869,194],{"class":170},[164,871,197],{"class":170},[164,873,349],{"class":200},[164,875,197],{"class":170},[164,877,354],{"class":190},[164,879,194],{"class":170},[164,881,197],{"class":170},[164,883,361],{"class":200},[164,885,197],{"class":170},[164,887,366],{"class":170},[164,889,369],{"class":229},[164,891,372],{"class":170},[164,893,187],{"class":174},[164,895,178],{"class":170},[164,897,898,900,902],{"class":166,"line":389},[164,899,382],{"class":170},[164,901,175],{"class":174},[164,903,178],{"class":170},[164,905,906,908,910],{"class":166,"line":399},[164,907,392],{"class":170},[164,909,33],{"class":174},[164,911,178],{"class":170},[164,913,914,916,918],{"class":166,"line":409},[164,915,402],{"class":170},[164,917,187],{"class":174},[164,919,178],{"class":170},[164,921,922,924,926],{"class":166,"line":697},[164,923,372],{"class":170},[164,925,175],{"class":174},[164,927,178],{"class":170},[113,929,930,932,933,936,937,940],{},[128,931,672],{}," writes its result into ",[128,934,935],{},"query.rect"," and creates no object of its own. This is the same idea as an output parameter in a C API: ",[128,938,939],{},"get_rect(index, &rect)"," fills a struct the caller owns, instead of returning a new one.",[113,942,943],{},"This matters because every new object becomes garbage. The browser has to collect it, and it does so while the user scrolls. A handler that creates one object per scroll event creates thousands during a long scroll.",[140,945,947],{"id":946},"read-layout-before-writing-styles","Read layout before writing styles",[113,949,950,951,953],{},"When you move an element in a ",[128,952,436],{}," handler, read every position first, then write every style.",[155,955,958],{"className":956,"code":957,"language":468,"meta":160,"style":160},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { useTemplateRef } from \"vue\";\n\nconst popover = useTemplateRef(\"popover\");\n\nfunction onViewportScroll() {\n  query.root = grid.value.$el;\n  query.layout = grid.value.measurement;\n  query.index = 42;\n  if (!getItemRect(query)) return;\n  const top = query.rect.top;\n\n  popover.value.style.transform = `translateY(${top}px)`;\n}\n",[128,959,960,980,984,1008,1012,1022,1044,1066,1080,1102,1127,1131,1172],{"__ignoreMap":160},[164,961,962,964,966,968,970,972,974,976,978],{"class":166,"line":167},[164,963,478],{"class":477},[164,965,481],{"class":170},[164,967,484],{"class":229},[164,969,487],{"class":170},[164,971,490],{"class":477},[164,973,493],{"class":170},[164,975,159],{"class":200},[164,977,197],{"class":170},[164,979,500],{"class":170},[164,981,982],{"class":166,"line":181},[164,983,533],{"emptyLinePlaceholder":532},[164,985,986,988,991,993,995,997,999,1002,1004,1006],{"class":166,"line":208},[164,987,538],{"class":190},[164,989,990],{"class":229}," popover ",[164,992,194],{"class":170},[164,994,484],{"class":546},[164,996,549],{"class":229},[164,998,197],{"class":170},[164,1000,1001],{"class":200},"popover",[164,1003,197],{"class":170},[164,1005,559],{"class":229},[164,1007,500],{"class":170},[164,1009,1010],{"class":166,"line":217},[164,1011,533],{"emptyLinePlaceholder":532},[164,1013,1014,1016,1018,1020],{"class":166,"line":235},[164,1015,586],{"class":190},[164,1017,589],{"class":546},[164,1019,575],{"class":170},[164,1021,594],{"class":170},[164,1023,1024,1026,1028,1030,1032,1034,1036,1038,1040,1042],{"class":166,"line":253},[164,1025,599],{"class":229},[164,1027,135],{"class":170},[164,1029,604],{"class":229},[164,1031,607],{"class":170},[164,1033,610],{"class":229},[164,1035,135],{"class":170},[164,1037,615],{"class":229},[164,1039,135],{"class":170},[164,1041,620],{"class":229},[164,1043,500],{"class":170},[164,1045,1046,1048,1050,1052,1054,1056,1058,1060,1062,1064],{"class":166,"line":269},[164,1047,599],{"class":229},[164,1049,135],{"class":170},[164,1051,631],{"class":229},[164,1053,607],{"class":170},[164,1055,610],{"class":229},[164,1057,135],{"class":170},[164,1059,615],{"class":229},[164,1061,135],{"class":170},[164,1063,644],{"class":229},[164,1065,500],{"class":170},[164,1067,1068,1070,1072,1074,1076,1078],{"class":166,"line":286},[164,1069,599],{"class":229},[164,1071,135],{"class":170},[164,1073,361],{"class":229},[164,1075,607],{"class":170},[164,1077,659],{"class":247},[164,1079,500],{"class":170},[164,1081,1082,1084,1086,1089,1091,1093,1095,1097,1100],{"class":166,"line":292},[164,1083,666],{"class":477},[164,1085,669],{"class":174},[164,1087,1088],{"class":170},"!",[164,1090,672],{"class":546},[164,1092,549],{"class":174},[164,1094,677],{"class":229},[164,1096,680],{"class":174},[164,1098,1099],{"class":477},"return",[164,1101,500],{"class":170},[164,1103,1104,1107,1110,1112,1115,1117,1120,1122,1125],{"class":166,"line":334},[164,1105,1106],{"class":190},"  const",[164,1108,1109],{"class":229}," top",[164,1111,607],{"class":170},[164,1113,1114],{"class":229}," query",[164,1116,135],{"class":170},[164,1118,1119],{"class":229},"rect",[164,1121,135],{"class":170},[164,1123,1124],{"class":229},"top",[164,1126,500],{"class":170},[164,1128,1129],{"class":166,"line":379},[164,1130,533],{"emptyLinePlaceholder":532},[164,1132,1133,1136,1138,1140,1142,1144,1146,1149,1151,1154,1157,1160,1162,1164,1167,1170],{"class":166,"line":389},[164,1134,1135],{"class":229},"  popover",[164,1137,135],{"class":170},[164,1139,615],{"class":229},[164,1141,135],{"class":170},[164,1143,349],{"class":229},[164,1145,135],{"class":170},[164,1147,1148],{"class":229},"transform",[164,1150,607],{"class":170},[164,1152,1153],{"class":170}," `",[164,1155,1156],{"class":200},"translateY(",[164,1158,1159],{"class":170},"${",[164,1161,1124],{"class":229},[164,1163,327],{"class":170},[164,1165,1166],{"class":200},"px)",[164,1168,1169],{"class":170},"`",[164,1171,500],{"class":170},[164,1173,1174],{"class":166,"line":399},[164,1175,700],{"class":170},[155,1177,1179],{"className":157,"code":1178,"language":159,"meta":160,"style":160},"\u003Ctemplate>\n  \u003Cdiv class=\"h-96 overflow-y-auto\">\n    \u003CVirtualGrid\n      ref=\"grid\"\n      :length=\"length\"\n      :page-size=\"40\"\n      :page-provider=\"pageProvider\"\n      @viewport-scroll=\"onViewportScroll\"\n    >\n      \u003Ctemplate #default=\"{ item, index, style }\">\n        \u003Cdiv :style=\"style\" :data-index=\"index\">{{ item.name }}\u003C\u002Fdiv>\n      \u003C\u002Ftemplate>\n    \u003C\u002FVirtualGrid>\n  \u003C\u002Fdiv>\n  \u003Cdiv ref=\"popover\" style=\"position: fixed\" \u002F>\n\u003C\u002Ftemplate>\n",[128,1180,1181,1189,1207,1213,1225,1239,1253,1267,1281,1285,1317,1353,1361,1369,1377,1409],{"__ignoreMap":160},[164,1182,1183,1185,1187],{"class":166,"line":167},[164,1184,171],{"class":170},[164,1186,175],{"class":174},[164,1188,178],{"class":170},[164,1190,1191,1193,1195,1197,1199,1201,1203,1205],{"class":166,"line":181},[164,1192,184],{"class":170},[164,1194,187],{"class":174},[164,1196,191],{"class":190},[164,1198,194],{"class":170},[164,1200,197],{"class":170},[164,1202,201],{"class":200},[164,1204,197],{"class":170},[164,1206,178],{"class":170},[164,1208,1209,1211],{"class":166,"line":208},[164,1210,211],{"class":170},[164,1212,214],{"class":174},[164,1214,1215,1217,1219,1221,1223],{"class":166,"line":217},[164,1216,757],{"class":190},[164,1218,194],{"class":170},[164,1220,197],{"class":170},[164,1222,554],{"class":200},[164,1224,232],{"class":170},[164,1226,1227,1229,1231,1233,1235,1237],{"class":166,"line":235},[164,1228,220],{"class":170},[164,1230,130],{"class":190},[164,1232,194],{"class":170},[164,1234,197],{"class":170},[164,1236,130],{"class":229},[164,1238,232],{"class":170},[164,1240,1241,1243,1245,1247,1249,1251],{"class":166,"line":253},[164,1242,220],{"class":170},[164,1244,240],{"class":190},[164,1246,194],{"class":170},[164,1248,197],{"class":170},[164,1250,248],{"class":247},[164,1252,232],{"class":170},[164,1254,1255,1257,1259,1261,1263,1265],{"class":166,"line":269},[164,1256,220],{"class":170},[164,1258,258],{"class":190},[164,1260,194],{"class":170},[164,1262,197],{"class":170},[164,1264,134],{"class":229},[164,1266,232],{"class":170},[164,1268,1269,1271,1273,1275,1277,1279],{"class":166,"line":286},[164,1270,812],{"class":170},[164,1272,436],{"class":190},[164,1274,194],{"class":170},[164,1276,197],{"class":170},[164,1278,821],{"class":229},[164,1280,232],{"class":170},[164,1282,1283],{"class":166,"line":292},[164,1284,289],{"class":170},[164,1286,1287,1289,1291,1293,1295,1297,1299,1301,1303,1305,1307,1309,1311,1313,1315],{"class":166,"line":334},[164,1288,295],{"class":170},[164,1290,175],{"class":174},[164,1292,300],{"class":170},[164,1294,303],{"class":190},[164,1296,194],{"class":170},[164,1298,197],{"class":170},[164,1300,310],{"class":170},[164,1302,313],{"class":229},[164,1304,316],{"class":170},[164,1306,319],{"class":229},[164,1308,316],{"class":170},[164,1310,324],{"class":229},[164,1312,327],{"class":170},[164,1314,197],{"class":170},[164,1316,178],{"class":170},[164,1318,1319,1321,1323,1325,1327,1329,1331,1333,1335,1337,1339,1341,1343,1345,1347,1349,1351],{"class":166,"line":379},[164,1320,337],{"class":170},[164,1322,187],{"class":174},[164,1324,342],{"class":190},[164,1326,194],{"class":170},[164,1328,197],{"class":170},[164,1330,349],{"class":200},[164,1332,197],{"class":170},[164,1334,354],{"class":190},[164,1336,194],{"class":170},[164,1338,197],{"class":170},[164,1340,361],{"class":200},[164,1342,197],{"class":170},[164,1344,366],{"class":170},[164,1346,369],{"class":229},[164,1348,372],{"class":170},[164,1350,187],{"class":174},[164,1352,178],{"class":170},[164,1354,1355,1357,1359],{"class":166,"line":389},[164,1356,382],{"class":170},[164,1358,175],{"class":174},[164,1360,178],{"class":170},[164,1362,1363,1365,1367],{"class":166,"line":399},[164,1364,392],{"class":170},[164,1366,33],{"class":174},[164,1368,178],{"class":170},[164,1370,1371,1373,1375],{"class":166,"line":409},[164,1372,402],{"class":170},[164,1374,187],{"class":174},[164,1376,178],{"class":170},[164,1378,1379,1381,1383,1386,1388,1390,1392,1394,1397,1399,1401,1404,1406],{"class":166,"line":697},[164,1380,184],{"class":170},[164,1382,187],{"class":174},[164,1384,1385],{"class":190}," ref",[164,1387,194],{"class":170},[164,1389,197],{"class":170},[164,1391,1001],{"class":200},[164,1393,197],{"class":170},[164,1395,1396],{"class":190}," style",[164,1398,194],{"class":170},[164,1400,197],{"class":170},[164,1402,1403],{"class":200},"position: fixed",[164,1405,197],{"class":170},[164,1407,1408],{"class":170}," \u002F>\n",[164,1410,1411,1413,1415],{"class":166,"line":703},[164,1412,372],{"class":170},[164,1414,175],{"class":174},[164,1416,178],{"class":170},[113,1418,1419,1420,1422,1423,135],{},"The handler uses the ",[128,1421,677],{}," from ",[117,1424,433,1426,437],{"href":1425},"#reuse-query-objects-in-viewport-scroll-handlers",[128,1427,436],{},[113,1429,1430,1431,1433,1434,1436],{},"With ",[128,1432,604],{}," set, ",[128,1435,672],{}," reads the layout of one element. If you change a style and then read a position, the browser has to recompute the layout of the page on the spot to give you a correct answer. Doing that in a loop, once per element, is called layout thrashing. Reading all positions first lets the browser compute the layout once.",[140,1438,1440,1441],{"id":1439},"key-items-by-id-with-getkey","Key items by id with ",[128,1442,1443],{},"getKey",[113,1445,1446],{},"By default, the grid gives each rendered slot element a key made from its index. Vue uses the key to match an element to its data when the list updates. With index keys, the element at index 5 is always matched to the data at index 5.",[113,1448,1449],{},"When your list changes, for example when an item is inserted at the top, every index shifts by one. Vue then updates the content of every element instead of moving them.",[113,1451,1452,1453,1455],{},"Pass ",[128,1454,1443],{}," to key the slot elements by your own id. Vue then matches each element to the item with that id, and moves the element when the item moves.",[155,1457,1459],{"className":157,"code":1458,"language":159,"meta":160,"style":160},"\u003Ctemplate>\n  \u003Cdiv class=\"h-96 overflow-y-auto\">\n    \u003CVirtualGrid\n      :length=\"length\"\n      :page-size=\"40\"\n      :page-provider=\"pageProvider\"\n      :get-key=\"(internalItem) => internalItem.value?.id ?? internalItem.index\"\n    >\n      \u003C!-- the default and placeholder slots -->\n    \u003C\u002FVirtualGrid>\n  \u003C\u002Fdiv>\n\u003C\u002Ftemplate>\n",[128,1460,1461,1469,1487,1493,1507,1521,1535,1582,1586,1591,1599,1607],{"__ignoreMap":160},[164,1462,1463,1465,1467],{"class":166,"line":167},[164,1464,171],{"class":170},[164,1466,175],{"class":174},[164,1468,178],{"class":170},[164,1470,1471,1473,1475,1477,1479,1481,1483,1485],{"class":166,"line":181},[164,1472,184],{"class":170},[164,1474,187],{"class":174},[164,1476,191],{"class":190},[164,1478,194],{"class":170},[164,1480,197],{"class":170},[164,1482,201],{"class":200},[164,1484,197],{"class":170},[164,1486,178],{"class":170},[164,1488,1489,1491],{"class":166,"line":208},[164,1490,211],{"class":170},[164,1492,214],{"class":174},[164,1494,1495,1497,1499,1501,1503,1505],{"class":166,"line":217},[164,1496,220],{"class":170},[164,1498,130],{"class":190},[164,1500,194],{"class":170},[164,1502,197],{"class":170},[164,1504,130],{"class":229},[164,1506,232],{"class":170},[164,1508,1509,1511,1513,1515,1517,1519],{"class":166,"line":235},[164,1510,220],{"class":170},[164,1512,240],{"class":190},[164,1514,194],{"class":170},[164,1516,197],{"class":170},[164,1518,248],{"class":247},[164,1520,232],{"class":170},[164,1522,1523,1525,1527,1529,1531,1533],{"class":166,"line":253},[164,1524,220],{"class":170},[164,1526,258],{"class":190},[164,1528,194],{"class":170},[164,1530,197],{"class":170},[164,1532,134],{"class":229},[164,1534,232],{"class":170},[164,1536,1537,1539,1542,1544,1546,1548,1552,1555,1558,1561,1563,1565,1568,1571,1574,1576,1578,1580],{"class":166,"line":269},[164,1538,220],{"class":170},[164,1540,1541],{"class":190},"get-key",[164,1543,194],{"class":170},[164,1545,197],{"class":170},[164,1547,549],{"class":170},[164,1549,1551],{"class":1550},"sHdIc","internalItem",[164,1553,1554],{"class":170},") ",[164,1556,1557],{"class":190},"=>",[164,1559,1560],{"class":229}," internalItem",[164,1562,135],{"class":170},[164,1564,615],{"class":229},[164,1566,1567],{"class":170},"?.",[164,1569,1570],{"class":229},"id",[164,1572,1573],{"class":170}," ?? ",[164,1575,1551],{"class":229},[164,1577,135],{"class":170},[164,1579,361],{"class":229},[164,1581,232],{"class":170},[164,1583,1584],{"class":166,"line":286},[164,1585,289],{"class":170},[164,1587,1588],{"class":166,"line":292},[164,1589,1590],{"class":688},"      \u003C!-- the default and placeholder slots -->\n",[164,1592,1593,1595,1597],{"class":166,"line":334},[164,1594,392],{"class":170},[164,1596,33],{"class":174},[164,1598,178],{"class":170},[164,1600,1601,1603,1605],{"class":166,"line":379},[164,1602,402],{"class":170},[164,1604,187],{"class":174},[164,1606,178],{"class":170},[164,1608,1609,1611,1613],{"class":166,"line":389},[164,1610,372],{"class":170},[164,1612,175],{"class":174},[164,1614,178],{"class":170},[113,1616,1617],{},"A placeholder has no value yet, so the function falls back to the index.",[140,1619,1621],{"id":1620},"keep-slot-content-small","Keep slot content small",[113,1623,1624,1625,131,1627,1630],{},"The grid renders the ",[128,1626,303],{},[128,1628,1629],{},"placeholder"," slots for every item in the window, and again each time the window moves by a row. A nested component tree costs once for each of the few hundred items in the window. Keep the markup in each slot to what the item shows, and move anything heavy, such as an image gallery or a menu, to the moment the user opens the item.",[140,1632,1634],{"id":1633},"check-the-result","Check the result",[113,1636,1637],{},"Open the browser's developer tools and scroll fast through the whole list.",[1639,1640,1641,1645],"ol",{},[1642,1643,1644],"li",{},"In the Network panel, filter the requests by the API URL, then scroll to the end. With a network provider and the debounce set, the count stays small, not one request per page crossed.",[1642,1646,1647],{},"In the Performance panel, click Record, scroll the grid, then stop. Look for purple \"Layout\" blocks in the recording. A forced layout has a red triangle in its corner. Handlers that read before they write still show Layout blocks, because the browser lays out the page after the styles change. They do not show the red forced-layout marker.",[349,1649,1650],{},"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 .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}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 .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 .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}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 .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}",{"title":160,"searchDepth":181,"depth":181,"links":1652},[1653,1654,1656,1657,1659,1660],{"id":142,"depth":208,"text":143},{"id":432,"depth":208,"text":1655},"Reuse query objects in viewport-scroll handlers",{"id":946,"depth":208,"text":947},{"id":1439,"depth":208,"text":1658},"Key items by id with getKey",{"id":1620,"depth":208,"text":1621},{"id":1633,"depth":208,"text":1634},"Keep scrolling responsive and cut the requests a network-backed grid sends.","md",null,{},{"icon":86},{"title":83,"description":1661},"VHxIbA61UHaCyNMollWqacPCDo3a_925-dQjmUPDgYA",[1669,1671],{"title":78,"path":79,"stem":80,"description":1670,"icon":81,"children":-1},"Give the grid a probe so it knows the item size, then make it scroll sideways.",{"title":94,"path":95,"stem":96,"description":1672,"icon":56,"children":-1},"Live grids with list, listbox, busy and keyboard patterns, and four ways to test them.",1794785668766]