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-virtual-scroller

v1.2.2

Published

virtualScroll component with vue2

Downloads

4

Readme

v-virtual-scroller

基于vue的虚拟滚动组件

特性

  • 支持横向、纵向、横纵使用三种虚拟滚动方式。
  • 支持不同长度的元素。

用法

  1. 安装插件

    npm i v-virtual-scroller
  2. 使用

注册为全局组件

import virtualScroller from 'v-virtual-scroller';
Vue.use(virtualScroller,'g'); //第二个参数为组件名前缀,选填。

或者按需引用

import {virtualScroller,virtualScrollerTable} from 'v-virtual-scroller';

export default {
    name: 'App',
    components: { virtualScroller,virtualScrollerTable },
}

virtual-scroller

单向虚拟滚动组件

基本用法

<template>
<virtual-scroller :items="items" v-slot="{ index, size, active }">
                <div>{{ index }}{{ size }} {{ active }}</div>
  </virtual-scroller>
</tempalte>
<script>
export default {
    data() {
        return {
            items: [20, 20, 20, 20, 20],
        };
    },
};
</script>

组件props参数

| 参数 | 说明 | 类型 | 是否必填 | 可选值 | 默认值 | | --------- | -------------------------- | ------ | -------- | ----------------------- | ---------- | | items | 元素长度集合(以px为单位) | array | 是 | | | | direction | 虚拟滚动方向 | string | 否 | vertical,horizontal | vertical |

元素slot参数

| 参数 | 说明 | 类型 | | ------ | ---------------- | ------- | | size | 元素的长度 | number | | index | 元素在集合的位置 | number | | active | 元素激活状态 | Boolean |

组件事件

| 参数 | 说明 | 回调参数 | | ------ | -------------- | -------- | | scroll | 列表滚动时触发 | 偏移值 | | | | |

virtual-scroller-table

同时支持横向纵向的虚拟滚动组件

基本用法

<template>
    <virtual-scroller-table
                            :cols="cols"
                            :rows="rows"
                            v-slot="{ rowIndex, colIndex, active }"
                            >
        <div>{{ colIndex }}{{ colIndex }} {{ active }}</div>
    </virtual-scroller-table>
</tempalte>
<script>
export default {
    data() {
        return {
            rows: [20, 20, 20, 20, 20],
            cols: [20, 20, 20, 20, 20]
        };
    },
};
</script>

组件props参数

| 参数 | 说明 | 类型 | 是否必填 | 可选值 | 默认值 | 举例 | | ---- | ---------------------------- | ----- | -------- | ------ | ------ | ---------------- | | rows | 元素行长度集合(以px为单位) | array | 是 | | | [20,20,20,20,20] | | cols | 元素列长度集合(以px为单位) | array | 是 | | | [20,20,20,20,20] | | | | | | | | | | | | | | | | |

元素slot参数

| 参数 | 说明 | 类型 | | -------- | ------------------ | ------- | | rowIndex | 元素在行集合的位置 | number | | colIndex | 元素在列集合的位置 | number | | height | 元素高度 | number | | width | 元素宽度 | number | | active | 元素激活状态 | Boolean |

组件事件

| 参数 | 说明 | 回调参数 | | ------ | -------------- | --------------------------------------- | | scroll | 列表滚动时触发 | left :横向偏移值, top:纵向偏移值 | | | | |

参考

再谈前端虚拟列表的实现

无尽滚动的复杂度 -- 来自 Google 大神的拆解