Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit 3eff002

Browse files
committed
readme
1 parent 12e9c03 commit 3eff002

File tree

4 files changed

+94
-3
lines changed

4 files changed

+94
-3
lines changed

README.md

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,87 @@
1-
# vue-list-scroller
1+
# vue-list-scroller
2+
3+
It can help with creating Twitter-like feed with thousands of items. It renders only visible part of the list.
4+
5+
## Notes
6+
7+
* Only page mode
8+
* Uses ResizeObserver
9+
* Items can have any size and change dynamicaly
10+
* Items can have margins
11+
* Supports infinite scroll
12+
13+
# Usage
14+
15+
Add package to your project
16+
17+
```bash
18+
npm install vue-list-scroller --save
19+
```
20+
21+
Create item component
22+
```vue
23+
<template>
24+
<div>{{ 'Item ' + index + ' ' + data.text }}</div>
25+
</template>
26+
27+
<script>
28+
export default {
29+
props: {
30+
data: Object,
31+
index: Number,
32+
},
33+
}
34+
</script>
35+
```
36+
37+
Add ListScroller component to your project
38+
39+
```vue
40+
<template>
41+
<div>
42+
<list-scroller :itemComponent="item" :itemsData="items" :itemHeight="350" />
43+
</div>
44+
</template>
45+
46+
<script>
47+
import ListScroller from '@/listscroller'
48+
import Item from './item'
49+
50+
export default {
51+
components: { ListScroller },
52+
data() {
53+
return {
54+
items: [{ text: 'first' }, { text: 'second' }],
55+
item: Item,
56+
}
57+
},
58+
}
59+
</script>
60+
```
61+
62+
# Example
63+
64+
You can clone this project and start example with these commands. It's in the dev folder.
65+
66+
```bash
67+
npm install
68+
npm run serve
69+
```
70+
71+
# Props
72+
73+
* `itemsData`: array of the data that is passed to items
74+
* `itemHeight`: approximate item height in pixels. it's used only at first rendering
75+
* `itemComponent`: vue js item component
76+
* `renderViewports`: height of the rendered part relative to viewport height. For example, if it's set to 5 and window inner height is 400, it will render 800 pixels before and after visible part of the list
77+
78+
# Events
79+
80+
* `bottom`: emits when the last item is rendered. Used for infinite scroll
81+
82+
83+
# Similar projects
84+
85+
* [vue-virtual-scroll-list](https://github.com/tangbc/vue-virtual-scroll-list)
86+
* [vue-virtual-scroller](https://github.com/Akryum/vue-virtual-scroller)
87+

dev/item.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default {
3232
border-width: 3px;
3333
img {
3434
width: 100%;
35-
height: 100%;
35+
max-height: 200px;
3636
object-fit: contain;
3737
}
3838
}

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
module.exports = {
22
preset: '@vue/cli-plugin-unit-jest',
33
testMatch: ['<rootDir>/tests/*.test.js'],
4+
collectCoverage: true,
5+
collectCoverageFrom: ["src/**/*.{js,vue}"],
6+
coverageReporters: ["text-summary"]
47
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"name": "vue-list-scroller",
33
"version": "1.0.0",
4-
"description": "Simple Vue component for efficiant rendering large lists",
4+
"description": "Simple Vue.js component for efficiant rendering large lists",
55
"private": true,
6+
"homepage": "https://github.com/IvanSafonov/vue-list-scroller",
7+
"license": "MIT",
68
"main": "dist/list-scroller.ssr.js",
79
"browser": "dist/list-scroller.esm.js",
810
"module": "dist/list-scroller.esm.js",

0 commit comments

Comments
 (0)