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

vue-windowing

v0.14.6

Published

Set of components used for virtualizing DOM

Downloads

49

Readme

vue-windowing

Set of components used for virtualizing DOM.

Installation

npm install --save vue-windowing

Import

Install all as a plugin:

import Vue from 'vue'
import ViewWindowing from 'vue-windowing';

Vue.use(ViewWindowing)

Install only those which you want:

import Vue from 'vue'
import {
    VirtualScroll,
    // ...
    NestedList,
} from 'vue-windowing';

Vue.component(VirtualScroll, 'VirtualScroll');
Vue.component(NestedList, 'NestedList');

Usage

There are several components used for DOM virtualization:

VirtualScroll

Component used for virtualizing vertical scrolling elements. It may handle dynamic height elements calculated on fly by AutoHeightMeasurer.

Example:

<template>
    <VirtualScroll
        style="height: 200px"
        :items="items"
        :render-ahead="renderAhead"
        :estimated-height="estimatedHeight">
        <template #header>
            <!-- Might be added sticky / floating header -->
        </template>
        <template #body>
            <!-- Might be added custom body which will overwrite DOM virtualization - useful for presenting placeholders in case that there is no data -->
        </template>
        <template #item="{ item, index }">
            <div v-text="item" />
        </template>
        <template #footer>
            <!-- Might be added sticky / floating footer -->
        </template>
    </VirtualScroll>
</template>

<script>
export default {
    data() {
        return {
            items: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
            renderAhead: 2, // Buffer, +2 at top / bottom in queue
            estimatedHeight: 20, // We need to assume that there is some default height for each row which will be recalculated later
        };       
    },
}
</script>

NestedList

Wrapper for VirtualScroll. It adds simple functionality of flattening passed items. Allowing to render tree data structures.

Example:

<template>
    <NestedList
        style="height: 200px"
        :items="items"
        :render-ahead="renderAhead"
        :estimated-height="estimatedHeight">
        <template #header>
            <!-- Might be added sticky / floating header -->
        </template>
        <template #body>
            <!-- Might be added custom body which will overwrite DOM virtualization - useful for presenting placeholders in case that there is no data -->
        </template>
        <template #item="{ item, index }">
            <div v-text="item" />
        </template>
        <template #footer>
            <!-- Might be added sticky / floating footer -->
        </template>
    </NestedList>
</template>

<script>
export default {
    data() {
        return {
            items: [
                {
                    id: 'root',
                    children: [
                        {
                            id: 'firstLevel - 1',
                            children: [
                                {
                                    id: 'secondLevel - 1',
                                }
                            ],
                        },
                        {
                            id: 'firstLevel - 2',
                        }
                    ]
                }
            ],
            renderAhead: 2, // Buffer, +2 at top / bottom in queue
            estimatedHeight: 20, // We need to assume that there is some default height for each row which will be recalculated later
        };       
    },
}
</script>

ExpandingList

Wrapper for VirtualScroll. It adds simple functionality of flattening passed items and toggling visibility of groups. Allowing to render tree data structures.

Example:

<template>
    <ExpandingList
        style="height: 200px"
        :items="items"
        :render-ahead="renderAhead"
        :estimated-height="estimatedHeight"
        @expand="onExpandGroup">
        <template #header>
            <!-- Might be added sticky / floating header -->
        </template>
        <template #body>
            <!-- Might be added custom body which will overwrite DOM virtualization - useful for presenting placeholders in case that there is no data -->
        </template>
        <template #item="{ item, onExpand }">
            <div v-text="item" @click="onExpand(item)" />
        </template>
        <template #footer>
            <!-- Might be added sticky / floating footer -->
        </template>
    </ExpandingList>
</template>

<script>
export default {
    data() {
        return {
            items: [
                {
                    id: 'root',
                    children: [
                        {
                            id: 'firstLevel - 1',
                            children: [
                                {
                                    id: 'secondLevel - 1',
                                }
                            ],
                        },
                        {
                            id: 'firstLevel - 2',
                        }
                    ]
                }
            ],
            renderAhead: 2, // Buffer, +2 at top / bottom in queue
            estimatedHeight: 20, // We need to assume that there is some default height for each row which will be recalculated later
        };       
    },
    methods: {
        onExpandGroup(item) {
            // We might want to asynchronously prefetch data for expanded group
        }
    }
}
</script>

Props:

| Prop name | Description | Default value | | ------------- |:-------------:| -----:| | items | list of items | [] or {} for Nested/Expanding List | | renderAhead | number of buffered items at the top/bottom | 2 | | estimatedHeight | approximated value of each row height | 30 | | expanded | the flag which toggles between state of all items - only for ExpandingList | '' |

Events:

  • expand: click event for group element which toggles between visible state of group items - only for ExpandingList

Tips

:x: Do not use margin directly for styling node items! Height won't be measured well.

:information_source: Each virtualized component by default will fully expand, to make things happening you either have to set height / max-height of component or by implementing dynamic height content with flexbox / grid.

License

MIT