Convert Figma logo to code with AI

Akryum logovue-virtual-scroller

⚡️ Blazing fast scrolling for any amount of data

9,451
900
9,451
233

Top Related Projects

⚡️A vue component support big amount data list with high render performance and efficient.

An infinite scroll directive for vue.js.

Mastering Large Lists with the vue-recyclerview

Quick Overview

The vue-virtual-scroller project is a Vue.js component that provides a highly performant virtual scrolling solution for large datasets. It allows for smooth and efficient scrolling of large lists, grids, or other content by only rendering the visible items, reducing the overall DOM footprint and improving the user experience.

Pros

  • Efficient Rendering: The virtual scroller only renders the visible items, reducing the overall DOM footprint and improving performance, especially for large datasets.
  • Customizable: The component provides a flexible API that allows for customization of the scrolling behavior, item rendering, and other aspects.
  • Cross-browser Compatibility: The virtual scroller works across a wide range of browsers, including legacy browsers.
  • Responsive Design: The component adapts to changes in the viewport size, ensuring a consistent user experience.

Cons

  • Learning Curve: Integrating the virtual scroller into an existing application may require some initial setup and configuration, which can have a learning curve for developers unfamiliar with the library.
  • Limited Functionality: While the virtual scroller is highly focused on its core functionality, some users may require additional features or integrations that are not provided out of the box.
  • Dependency on Vue.js: The virtual scroller is tightly coupled with the Vue.js framework, which may be a limitation for developers working with other JavaScript frameworks.
  • Potential Performance Issues: In some cases, the virtual scroller may not perform as well as expected, especially for very large datasets or complex item rendering.

Code Examples

Here are a few code examples demonstrating the usage of the vue-virtual-scroller component:

  1. Basic Usage:
<template>
  <div id="app">
    <RecycleScroller
      class="scroller"
      :items="items"
      :item-size="50"
      key-field="id"
    >
      <template v-slot="{ item }">
        <div class="item">{{ item.text }}</div>
      </template>
    </RecycleScroller>
  </div>
</template>

<script>
export default {
  data() {
    return {
      items: Array.from({ length: 1000 }).map((_, i) => ({
        id: i,
        text: `Item ${i}`,
      })),
    };
  },
};
</script>
  1. Horizontal Scrolling:
<template>
  <div id="app">
    <HorizontalScroller
      class="scroller"
      :items="items"
      :item-size="200"
      key-field="id"
    >
      <template v-slot="{ item }">
        <div class="item">{{ item.text }}</div>
      </template>
    </HorizontalScroller>
  </div>
</template>

<script>
export default {
  data() {
    return {
      items: Array.from({ length: 50 }).map((_, i) => ({
        id: i,
        text: `Item ${i}`,
      })),
    };
  },
};
</script>
  1. Dynamic Item Sizes:
<template>
  <div id="app">
    <RecycleScroller
      class="scroller"
      :items="items"
      :item-size="getItemSize"
      key-field="id"
    >
      <template v-slot="{ item }">
        <div class="item" :style="{ height: `${getItemSize(item)}px` }">
          {{ item.text }}
        </div>
      </template>
    </RecycleScroller>
  </div>
</template>

<script>
export default {
  data() {
    return {
      items: Array.from({ length: 1000 }).map((_, i) => ({
        id: i,
        text: `Item ${i}`,
        height: Math.floor(Math.random() * 100) + 50,
      })),
    };
  },
  methods: {
    getItemSize(item) {
      return item.height;
    },

Competitor Comparisons

⚡️A vue component support big amount data list with high render performance and efficient.

Pros of vue-virtual-scroll-list

  • Supports both vertical and horizontal scrolling, making it more versatile than vue-virtual-scroller.
  • Provides a more lightweight and efficient implementation, with a smaller bundle size.
  • Offers a simpler and more straightforward API, which may be easier to use for some developers.

Cons of vue-virtual-scroll-list

  • May have fewer features and customization options compared to vue-virtual-scroller.
  • Potentially less actively maintained and supported than the larger and more established vue-virtual-scroller project.
  • May not have the same level of community support and documentation as vue-virtual-scroller.

Code Comparison

Here's a brief comparison of the code for rendering a list item in both projects:

vue-virtual-scroller:

<template>
  <div class="item">
    {{ item.text }}
  </div>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      required: true
    }
  }
}
</script>

vue-virtual-scroll-list:

<template>
  <div class="item">
    {{ data.text }}
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Object,
      required: true
    }
  }
}
</script>

As you can see, the main difference is the prop name used to access the item data (item vs. data), but the overall structure is quite similar.

An infinite scroll directive for vue.js.

Pros of ElemeFE/vue-infinite-scroll

  • Simplicity: ElemeFE/vue-infinite-scroll is a lightweight and straightforward library, making it easy to integrate into existing projects.
  • Event-based Approach: The library uses a simple event-based approach to trigger the infinite scrolling, which can be more intuitive for some developers.
  • Compatibility: ElemeFE/vue-infinite-scroll is compatible with a wide range of Vue.js versions, making it a viable option for projects with different Vue.js requirements.

Cons of ElemeFE/vue-infinite-scroll

  • Limited Functionality: Compared to Akryum/vue-virtual-scroller, ElemeFE/vue-infinite-scroll lacks advanced features like virtualization, which can be important for large datasets.
  • Performance Concerns: The library may not be as efficient as Akryum/vue-virtual-scroller for handling large datasets, as it does not utilize virtualization techniques.
  • Maintenance: The ElemeFE/vue-infinite-scroll project appears to have less active maintenance compared to Akryum/vue-virtual-scroller, which may be a concern for long-term projects.

Code Comparison

Here's a brief code comparison between the two libraries:

ElemeFE/vue-infinite-scroll:

<template>
  <div v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
    <!-- Your content goes here -->
  </div>
</template>

<script>
export default {
  data() {
    return {
      busy: false
    }
  },
  methods: {
    loadMore() {
      this.busy = true;
      // Fetch more data and update the component
      this.busy = false;
    }
  }
}
</script>

Akryum/vue-virtual-scroller:

<template>
  <RecycleScroller
    class="scroller"
    :items="items"
    :item-size="50"
    key-field="id"
    v-slot="{ item }"
  >
    <div class="item">{{ item.name }}</div>
  </RecycleScroller>
</template>

<script>
import { RecycleScroller } from 'vue-virtual-scroller'

export default {
  components: {
    RecycleScroller
  },
  data() {
    return {
      items: [
        { id: 1, name: 'Item 1' },
        { id: 2, name: 'Item 2' },
        // ...
      ]
    }
  }
}
</script>

Mastering Large Lists with the vue-recyclerview

Pros of vue-recyclerview

  • Supports virtualization of large lists, improving performance and reducing memory usage.
  • Provides a simple and intuitive API for integrating with Vue.js components.
  • Supports dynamic item heights, allowing for more flexible list layouts.

Cons of vue-recyclerview

  • Lacks some of the advanced features and customization options available in vue-virtual-scroller.
  • May have less active development and community support compared to vue-virtual-scroller.
  • Potentially less mature and stable than the more established vue-virtual-scroller.

Code Comparison

vue-virtual-scroller:

<template>
  <RecycleScroller
    class="scroller"
    :items="items"
    :item-size="50"
    key-field="id"
    v-slot="{ item }"
  >
    <div class="item">{{ item.text }}</div>
  </RecycleScroller>
</template>

vue-recyclerview:

<template>
  <RecyclerView
    class="list"
    :data-source="items"
    :item-size="50"
    :key-extractor="(item) => item.id"
    :renderer="renderItem"
  />
</template>

<script>
export default {
  methods: {
    renderItem(item) {
      return <div class="item">{item.text}</div>;
    },
  },
};
</script>

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

vue-virtual-scroller

npm npm vue3

Docs

Blazing fast scrolling of any amount of data | Live demo | Video demo

For Vue 2 support, see here

💚️ Become a Sponsor

Sponsors

NPM DownloadsLast 30 Days