npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

v-endless-list

v3.0.0

Published

Minimalistic and tiny Vue.js scroll list components for an endless amount of data

Downloads

58

Readme

v-endless-list

Minimalistic and tiny Vue.js scroll list components for an endless amount of data

Note: Version 3.x of v-endless-list is compatible with Vue 3 only. Install version 2.x if you use Vue 2.

Provides two components:

  • v-endless-virtual-list: Renders only items in the viewport for performance. Supports lazy loading and jumping to given items. Requires fixed item height. Recommended for extremely large data sets.

  • v-endless-lazy-list: Simple list with lazy loading. Supports variable height items but is less efficient for large data sets (slower when scrolling far down). Recommended for small to medium data sets.

Table of Contents

Installation

Install v-endless-list:

npm install --save v-endless-list

Then import it in your project:

import { createApp, h } from 'vue';

const app = Vue.createApp(App);
app.use(vEndlessList, { h });
app.mount('#app');

Or include the files via <script> tag:

<script src="https://unpkg.com/[email protected]/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/v-endless-list/dist/vEndlessList.min.js"></script>
<script>
    const app = Vue.createApp(App);
    app.use(vEndlessList, { h: Vue.h });
    app.mount('#app');
</script>

Usage

Most basic usage example for both components (read about Vue Scoped Slots to understand the syntax):

<v-endless-virtual-list :items="items" item-height="100">
    <template #default="item">
        <div>{{ item }}</div>
    </template>
</v-endless-virtual-list>
<v-endless-lazy-list :items="items">
    <template #default="item">
        <div>{{ item }}</div>
    </template>
</v-endless-lazy-list>

Advanced usage example for both components:

<v-endless-virtual-list
    :items="items"
    height="50vh"
    item-height="100"
    @reached-bottom="lazyLoadItems()"
>
    <template #empty-list>
        <b>No items in this list.</b>
    </template>
    <template #default="item">
        <my-component :my-data="item.myData"></my-component>
    </template>
</v-endless-virtual-list>
<v-endless-lazy-list
    :items="items"
    height="50vh"
    increment="100"
    loading-threshold="42"
    list-change-behavior="keep"
    @reached-top="onReachedTop()"
>
    <template #empty-list>
        <b>No items in this list.</b>
    </template>
    <template #default="item">
        <my-component :my-data="item.myData"></my-component>
    </template>
</v-endless-lazy-list>

Also check the demo in the demo directory. You can run the demos with npm run demo. Open your browser at http://127.0.0.1:1337/demo.

API

v-endless-virtual-list

Properties

  • items: Array, required. List of items you want to display.
  • item-height: Number, required. Height of an individual list item in pixels. Overflow will be hidden.
  • height: String, optional, default "100%". CSS height of the entire list component.

Slots

  • default (scoped slot, required): Component to render for each list item, receives the list item in the slot scope.
  • empty-list (optional): Text or content to show when there are no items in the list.

Emitted Events

  • reached-top: Emitted when the list is scrolled to the very top.
  • reached-bottom: Emitted when the list is scrolled to the very bottom. Can be used for lazy loading new items.

Methods

  • scrollTo: Can be used to scroll the list to a given item. Valid parameters are:
    • "top": scroll to top
    • "bottom": scroll to bottom
    • index (Number): scroll to the item with the given index

v-endless-lazy-list

Properties

  • items: Array, required. List of items you want to display.
  • height: String, optional, default "100%". CSS height of the entire list component.
  • increment: Number, optional, default 10. Number of items to add to the end of the list on lazy loading.
  • loadingThreshold: Number, optional, default 10. Threshold after which lazy loading is triggered, i.e. number of pixels before reaching the end of the list when scrolling.
  • listChangeBehavior: Either "reset" or "keep", optional, default "reset". Behavior of the list when the data set length changes.
    • "reset": Reset the number of items to increment and scroll to the top.
    • "keep": Keep the number of currently shown items as well as scroll state.

Slots

  • default (scoped slot, required): Component to render for each list item, receives the list item in the slot scope.
  • empty-list (optional): Text or content to show when there are no items in the list.

Emitted Events

  • reached-top: Emitted when the list is scrolled to the very top.
  • reached-bottom: Emitted when the list is scrolled to the very bottom.

Methods

  • scrollTo: Can be used to scroll the list to a given item. Valid parameters are:
    • "top": scroll to top
    • "bottom": scroll to bottom. Forces loading of all items. Note that this can have a huge performance impact and might freeze the browser temporarily. Use with caution.
    • index (Number): scroll to the item with the given index. See note on performance above.