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

kruster

v1.3.0

Published

A small tool to help improve the rendering performance of very large HTML tables.

Downloads

21

Readme

Kruster

A small tool to help improve the rendering performance of very large HTML tables.

Build Status

Install

$ npm install --save kruster

Description

Kruster is a tool used to speed up the performance of tables which contain a lot of content.

To do this, it only renders rows which are actually visible within the client height of the specified element that wraps the table.

Kruster can handle rows of varying row height.

Example

HTML

<div id="scrollable-container">
    <table>
        <colgroup>
            <col style="width:100px" />
            <col style="width:150px" />
            <col style="width:150px" />
            <col style="width:150px" />
            <col style="width:250px" />
            <col style="width:250px" />
        </colgroup>
        <tbody id="table-body">
            <tr>
                <td colspan="1"><img src="images/31.jpg" /></td>
                <td colspan="1">0</td>
                <td colspan="1">lily</td>
                <td colspan="1">(025)-016-5434</td>
                <td colspan="1">[email protected]</td>
                <td colspan="1">43 some road<br />dean park<br /><br /><br />mega place</td>
            </tr>

            <!-- ... Plenty of other rows. Like, lots ... -->

            <tr>
                <td colspan="1"><img src="images/23.jpg" /></td>
                <td colspan="1">200</td>
                <td colspan="1">oliver</td>
                <td colspan="1">05-891-394</td>
                <td colspan="1">[email protected]</td>
                <td colspan="1">937 burnsey road<br />middle<br />nowhere</td>
            </tr>
        </tbody>
    </table>
</div>

JavaScript

/** Create an instance of Kruster and cluster the target table rows. */
var kruster = new Kruster({
    tableBody: document.getElementById("table-body"),
    scrollableParent: document.getElementById("scrollable-container")
});

Options

| Option | Type | Description | | :------------------------------ | :---------- | :------------------------------------------------------------------------------------------------------------------------------------------------ | | tableBody (required) | DOM Element | The target table which contains the rows to cluster. | | scrollableParent (required) | DOM Element | The scrollable parent that wraps the target table. Only clusters which reside in the visible portion of this element will be displayed. | | clusterSize | number | The number of rows to each cluster. Smaller clusters mean more frequent updates but minimises the number of rows being displayed. Default: 25 | | autoRefresh | boolean | Whether Kruster should refresh in response to window resize events. Default: false | | onClusterShow | function | Callback which is called when a cluster is shown. An object containing the clusters index and contained rows are passed as an argument. | | onClusterHide | function | Callback which is called when a cluster is hidden. An object containing the clusters index and contained rows are passed as an argument. |

Methods

.refresh()

Refreshes the Kruster instance. This is required when the size of the table or the heights of any rows change in order to reassess the heights of any clusters.

.getRows()

Get an array of all of the table rows, excluding any rows that were injected by Kruster.

.getRowAt(index)

Get a row at the specified index, excluding any rows that were injected by Kruster.

.getRowIndex(rowElement)

Get the index of the specified row element in the clustered table, excluding any rows that were injected by Kruster.

.getCleanTable()

Get the table body, cleansed of the DOM and style modifications made by Kruster.

.destroy([removeTableModifications])

Destroys the Kruster instance.

Takes an optional boolean argument which defines whether the table should be cleansed of any modifications made by Kruster. Default: true

License

MIT © [Nikolas Howard]