### Install Dependencies and Run Dev Server Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/demo/README.md Installs project dependencies using yarn and starts the development server with hot reload. ```bash # install dependencies yarn install # serve with hot reload at localhost:8080 yarn run dev ``` -------------------------------- ### Full Example of useWindowScroller Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/use-window-scroller.md This example demonstrates how to set up and use the `useWindowScroller` composable to virtualize a large list of rows. It includes setup for the scroller, rendering pooled items, and a button to programmatically scroll to a specific item. ```vue ``` -------------------------------- ### Install vue-virtual-scroller and run skills-npm Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/ai-skills.md Install the `vue-virtual-scroller` package and then run `npx skills-npm` to expose the bundled skill to AI agents for one-off usage. ```bash pnpm add vue-virtual-scroller npx skills-npm ``` -------------------------------- ### Install vue-virtual-scroller with yarn Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/index.md Use this command to install the package using yarn. ```sh yarn add vue-virtual-scroller ``` -------------------------------- ### Install vue-virtual-scroller with npm Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/index.md Use this command to install the package using npm. ```sh npm install vue-virtual-scroller ``` -------------------------------- ### Install skills-npm as a dev dependency Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/ai-skills.md Install `skills-npm` as a development dependency to keep skill links up to date after package installs. ```bash npm i -D skills-npm ``` -------------------------------- ### Install vue-virtual-scroller with pnpm Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/index.md Use this command to install the package using pnpm. ```sh pnpm add vue-virtual-scroller ``` -------------------------------- ### Minimal Fixed-Size Setup Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/use-recycle-scroller.md Basic setup for useRecycleScroller with fixed item sizes. Ensure the scroller element is referenced using `useTemplateRef`. ```vue ``` -------------------------------- ### Basic DynamicScroller Usage Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/dynamic-scroller.md Demonstrates the fundamental setup for DynamicScroller with item iteration and rendering. Ensure the scroller has a defined height. ```vue ``` -------------------------------- ### Full Vue.js Virtual Scroller Example Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/use-recycle-scroller.md This example shows a complete implementation of a vertical virtual scroller with 10,000 items. It utilizes `useRecycleScroller` hook to manage the virtualized list and renders only the visible items to optimize performance. Ensure you have `vue-virtual-scroller` installed and imported. ```vue ``` -------------------------------- ### Vue Dynamic Scroller Full Example Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/use-dynamic-scroller.md This example demonstrates the full setup for using the `useDynamicScroller` composable in Vue. It includes defining reactive data, referencing the scroller element, and configuring the composable with item data, key field, direction, minimum item size, and the scroller element itself. The template then iterates over the `pool` to render items, applying the `v-dynamic-scroller-item` directive. ```vue ``` -------------------------------- ### Configure prepare script for skills-npm Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/ai-skills.md Add a `prepare` script to your project's `package.json` to automatically run `skills-npm` after installs, ensuring skill links are updated. ```json { "scripts": { "prepare": "skills-npm" } } ``` -------------------------------- ### Update useWindowScroller item styling (v2) Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/migrate-v2-to-v3.md This example shows the manual styling approach for pooled items in `useWindowScroller` before v3. ```vue
``` -------------------------------- ### Variable Item Sizes Example Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/recycle-scroller.md Example data structure for items in variable size mode. Each item must have a numeric field representing its size, specified by the `sizeField` prop (defaults to 'size'). ```javascript const items = [ { id: 1, label: 'Title', size: 64, }, { id: 2, label: 'Foo', size: 32, }, { id: 3, label: 'Bar', size: 32, }, ] ``` -------------------------------- ### Flow-Mode Spacer Layout Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/use-recycle-scroller.md Example of rendering spacers for flow mode. Use `v-if` to conditionally render start and end spacers based on `startSpacerSize` and `endSpacerSize`. ```vue
{{ view.item.title }}
``` -------------------------------- ### Grid Layout Example Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/recycle-scroller.md Illustrates setting up RecycleScroller for a grid layout. Requires `gridItems` and `itemSecondarySize` props in addition to a fixed `itemSize`. ```vue ``` -------------------------------- ### Install all components using Vue plugin Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/index.md Import and use the VueVirtualScroller plugin to register all available components globally in your Vue application. ```js import VueVirtualScroller from 'vue-virtual-scroller' app.use(VueVirtualScroller) ``` -------------------------------- ### Basic WindowScroller Usage Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/window-scroller.md Demonstrates the basic setup for WindowScroller, including importing the component, defining a list of items, and rendering them within the scroller. The list stays in normal page flow with content before and after it. ```vue ``` -------------------------------- ### Install All Bundled Components Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/SKILL.md Register all components from the vue-virtual-scroller package globally using app.use(). This makes all components available throughout your Vue application. ```js import { createApp } from 'vue' import VueVirtualScroller from 'vue-virtual-scroller' const app = createApp(App) app.use(VueVirtualScroller) ``` -------------------------------- ### Semantic Table with Dynamic Virtualization Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/use-table-column-widths.md This example demonstrates integrating useTableColumnWidths with useDynamicScroller for a semantic table. It sets up column widths based on content and locks them, while the table content is virtualized for performance. Ensure the table element and scroller element refs are correctly assigned. ```vue ``` -------------------------------- ### WindowScroller Component Setup Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/demos/window-scroller.md Sets up the WindowScroller component with dynamic items and variable heights. Use this when the entire browser window should be the scrollable area. ```vue ``` -------------------------------- ### Fixed-Size Rows Example Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/recycle-scroller.md Demonstrates how to use RecycleScroller for a list with fixed-size rows. Ensure the scroller and item elements are sized correctly with CSS. ```vue
{{ item.label }}
``` -------------------------------- ### Vue UseWindowScroller Composable Setup Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/use-window-scroller.md Configure the `useWindowScroller` composable with essential options like `items`, `el`, `keyField`, and `itemSize`. Adjust `buffer`, `prerender`, and other parameters as needed for performance and behavior. ```typescript const state = useWindowScroller({ items: rows, el: rootEl, keyField: 'id', itemSize: 48, minItemSize: null, sizeField: 'size', typeField: 'type', buffer: 200, prerender: 0, emitUpdate: false, updateInterval: 0, }) ``` -------------------------------- ### Resolver-Based Item Size Example Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/recycle-scroller.md Shows how to configure RecycleScroller when item sizes are determined dynamically by a resolver function based on the item and its index. This is useful for variable row heights. ```vue ``` -------------------------------- ### RecycleScroller Before Migration Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/migrate-v2-to-v3.md Example of RecycleScroller usage before migrating to v3. Note the manual handling of view positioning via transform. ```vue ``` -------------------------------- ### Update useDynamicScroller template bindings (v2) Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/migrate-v2-to-v3.md Before migrating, ensure your `useDynamicScroller` template uses the correct item access paths. This example shows the v2 structure. ```vue ``` -------------------------------- ### Basic RecycleScroller Usage Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/recycle-scroller.md Demonstrates the basic setup for RecycleScroller using a scoped slot to render list items. Ensure the scroller and item elements have defined sizes via CSS. ```vue ``` -------------------------------- ### Flow Mode Example Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/recycle-scroller.md Demonstrates using RecycleScroller in `flowMode` for vertical single-axis native-flow rendering. This mode keeps active pooled views in DOM order and inserts spacer elements. ```vue
{{ item.label }}
``` -------------------------------- ### Vue Component with useTableColumnWidths Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/use-table-column-widths.md This example demonstrates integrating `useTableColumnWidths` into a Vue component that also uses `useDynamicScroller`. It sets up a virtualized table with stable column widths based on measured content. Ensure `rows` and `filter` are reactive and that `scrollerEl` and `tableEl` are correctly referenced. ```vue ``` -------------------------------- ### RecycleScroller Component Usage Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/recycle-scroller.md Basic example of using the RecycleScroller component. It demonstrates how to bind items, set item size, and use slots for 'before' content and item rendering. ```html
``` ```vue ``` -------------------------------- ### Headless Table with Dynamic Scroller and Column Widths Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/demos/headless-table.md This component integrates `useDynamicScroller` for efficient rendering of large datasets in a table format and `useTableColumnWidths` to maintain consistent column widths. It requires setup for scroller and table elements, and defines options for dynamic scrolling. ```vue ``` -------------------------------- ### Build Project for Production Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/demo/README.md Builds the project for production with minification using yarn. ```bash # build for production with minification yarn run build ``` -------------------------------- ### RecycleScroller After Migration Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/migrate-v2-to-v3.md Example of RecycleScroller usage after migrating to v3. The `getViewStyle` function is now used for positioning pooled views. ```vue ``` -------------------------------- ### Validate Generated Skill Files Source: https://github.com/akryum/vue-virtual-scroller/blob/master/SKILLS-GENERATION.md Use these commands to validate the generated skill files. The first command prints the first 260 lines of the main skill file, and the second does the same for the references index. The third command lists all reference files. ```bash sed -n '1,260p' packages/vue-virtual-scroller/skills/vue-virtual-scroller/SKILL.md sed -n '1,260p' packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/index.md rg --files packages/vue-virtual-scroller/skills/vue-virtual-scroller/references ``` -------------------------------- ### TypeScript Generics with useWindowScroller Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/use-window-scroller.md Demonstrates how to use `useWindowScroller` with TypeScript generics for item-aware pool and helper methods. It shows the initialization with various options and accessing an item's property from the pool. ```typescript const windowScroller = useWindowScroller({ items: rows.value, keyField: 'id', direction: 'vertical', itemSize: 44, minItemSize: null, sizeField: 'size', typeField: 'type', buffer: 200, prerender: 0, emitUpdate: false, updateInterval: 0, }, rootEl) windowScroller.pool.value[0]?.item.label ``` -------------------------------- ### Server-Side Rendering with Prerender Prop Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/recycle-scroller.md Configure server-side rendering by setting the `prerender` prop to the number of items that should be rendered on the server within the virtual scroller. This improves initial load performance. ```html ``` -------------------------------- ### Record Generation Metadata and Track Changes Source: https://github.com/akryum/vue-virtual-scroller/blob/master/SKILLS-GENERATION.md After regenerating skill files, update the document with generation metadata. Use git diff commands to identify changes in docs or public exports, then map these to affected skill sections for incremental updates. ```bash git diff ..HEAD -- docs packages/vue-virtual-scroller/src/index.ts packages/vue-virtual-scroller/src/types.ts packages/vue-virtual-scroller/README.md git diff --name-only ..HEAD -- docs packages/vue-virtual-scroller/src/index.ts packages/vue-virtual-scroller/src/types.ts packages/vue-virtual-scroller/README.md ``` -------------------------------- ### Page Mode with Outer Scrollable Div Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/recycle-scroller.md Use page mode when the scroller should virtualize against an outer scrollable container. This example shows a RecycleScroller within a div that has its own scrollbar. ```vue
``` -------------------------------- ### Flow-Mode Spacers for Semantic Tables Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/use-dynamic-scroller.md This pattern is used with `flowMode` to render semantic tables, ensuring correct spacing with start and end spacers. It requires `startSpacerSize` and `endSpacerSize` to be available. ```vue {{ view.item.label }} ``` -------------------------------- ### Use Custom Tag for Item Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/dynamic-scroller-item.md This example demonstrates how to use a custom HTML tag (e.g., 'article') for the DynamicScrollerItem wrapper. Pass the desired tag name to the `tag` prop. ```vue {{ item.title }} ``` -------------------------------- ### DynamicScroller for Append-Heavy Chat Feed Source: https://github.com/akryum/vue-virtual-scroller/blob/master/packages/vue-virtual-scroller/skills/vue-virtual-scroller/references/dynamic-scroller.md Ideal for dynamic feeds where new items are frequently appended. This setup uses `DynamicScrollerItem` to render each message, with `min-item-size` set for initial estimation. ```vue ``` -------------------------------- ### Update useWindowScroller item styling (v3) Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/migrate-v2-to-v3.md In v3, `useWindowScroller` recommends using `getViewStyle(view)` for simplified and consistent pooled item styling. Manual style rebuilding is no longer needed. ```vue
``` -------------------------------- ### Initialize useRecycleScroller with TypeScript Generics Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/use-recycle-scroller.md Initialize useRecycleScroller with a specific item type for compile-time validation. Ensure the scroll container element has a fixed height and overflow style. Apply totalSize to an inner wrapper for virtual scrolling. ```typescript const recycleScroller = useRecycleScroller({ items: users.value, keyField: 'id', direction: 'vertical', itemSize: null, minItemSize: 32, sizeField: 'size', typeField: 'type', buffer: 200, pageMode: false, prerender: 0, emitUpdate: false, updateInterval: 0, }, scrollerEl) recycleScroller.pool.value[0]?.item.name ``` -------------------------------- ### TypeScript Generics with WindowScroller Source: https://github.com/akryum/vue-virtual-scroller/blob/master/docs/guide/window-scroller.md Shows how to use TypeScript generics with WindowScroller for type inference of the `item` slot prop. This example defines an explicit `Row` interface for better type safety. ```vue ```