Giter Club home page Giter Club logo

vue-auto-virtual-scroll-list's Introduction

vue-auto-virtual-scroll-list

High level component for virtual list where each item height is not known before render

npm version package-size

Properties

Prop Type Required/Default Description
totalHeight Number Container height (px): used to calculate the # of components rendered
defaultHeight Number Item expected height (px). Set to your item's minimum height
extraItems Number 1 Extra items rendered (extra items rendered to avoid empty space while scrolling)

Usage

With template

<template>
  <VueAutoVirtualScrollList
    :totalHeight="800"
    :defaultHeight="80"
    style="width: 100%;"
  >
    <div
      v-for="item in items"
        :style="{ height: `${item.height}px` }"
    >
      {{ item.name }}
    </div>
  </VueAutoVirtualScrollList>
</template>

<script>
import VueAutoVirtualScrollList from 'vue-auto-virtual-scroll-list'

export default {
  ...
  components: { VueAutoVirtualScrollList },
  ...
}
</script>

With jsx

import VueAutoVirtualScrollList from 'vue-auto-virtual-scroll-list'

export default {
  ...
  render(h) {
    return (
      <VueAutoVirtualScrollList
        totalHeight={800}
        defaultHeight={80}
      >
        {items.map((item) => (
          <div style={{ height: `${item.height}px` }}>
            { item.name }
          </div>
        ))}
      </VueAutoVirtualScrollList>
    )
  },
  ...
}

Methods

setIndex(index: number)

Scroll to the item at index. This method is not yet stable or tested.

How it works

The number of rendered components is calculated by accumulating each item height to see how many fit in totalHeight. Each item height is assumed to be defaultHeight, until it is actually rendered. When that happens the correct value is cached and used for later calculations

Motivation

The worst case scenario for lists is when each item has multi-line text mixed with other content, which make it very hard to know the component height before render happens. This component makes it easy to use this kind of list without further problems

TODO

  • Support for infinite scroll

vue-auto-virtual-scroll-list's People

Contributors

cristovao-trevisan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vue-auto-virtual-scroll-list's Issues

Some kind of memory leak causing entire Chrome tab to freeze

I've been fighting with freezing problems during scroll. Basically the scroller stops loading items and then the entire application (except for the scrolling) is totally frozen requiring ending the Process for the tab entirely in the Chrome task manager. I tried about everything to simplify my items, including making them entirely functional (stateless). I got lots more speed but no resolution on the occasional application crash.

I finally switched to another scroller (vue-virtual-scroll-list) and the crashing stopped. Now I'm seriously missing the silky scrolling and jump-free scrollbar from vue-auto-virtual-scroll-list.

Any idea what about the scrolling might be causing such a crash? I'm getting no console error and Devtools profiling always locks up at the same time so I can't even investigate.

Incorrect calculation when item is larger than container

My item heights are not being adjusted after render. I assume this is because I am using a component for the list item. Is there a work-around?

<VueAutoVirtualScrollList :totalHeight="1400" :defaultHeight="100" style="width: 100%;" >
   <block v-for="block of blocks" :key="block.id" :style="{ height: `300px` }" />
</VueAutoVirtualScrollList>

Travando a página

Olá amigo, ando fazendo alguns testes com seu plugin, e venho me deparando as vezes com travamentos, não são leves, realmente trava a aba em que o projeto está aberto. Sabe me informar o motivo?

Jerky scrolling with large items

As I scroll up or down, when a large item is above the viewport, it messes up scrolling jerking the position up or down. I've tried increasing "extraItems" dramatically but it does not seem to add extra buffer space above the viewport, only below.

Here is a screen capture showing scrolling slowly down with the scroller getting stuck in a loop as it jerks upwards when the large item leaves the visible area:

https://www.screencast.com/t/J1bWfHXRsm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.