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

virtual-scroll-list

v0.7.3

Published

Think of it as UITableView for the DOM elements

Downloads

307

Readme

Virtual Scroll

Build Status

            _    ___      __              __   _____                 ____
            | |  / (_)____/ /___  ______ _/ /  / ___/______________  / / /
            | | / / / ___/ __/ / / / __ `/ /   \__ \/ ___/ ___/ __ \/ / /
            | |/ / / /  / /_/ /_/ / /_/ / /   ___/ / /__/ /  / /_/ / / /  
            |___/_/_/   \__/\__,_/\__,_/_/   /____/\___/_/   \____/_/_/

Virtual list that is able to render infinite ammount of DOm element using UITableView techniques and. This is already been done in a lot of ways but Here I am trying to use CSS translate to scroll the container which more performant than changing the top. Paul Irish made a great benchmark here http://www.paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/

Example Usage

Getting the library

git clone https://github.com/Khaledgarbaya/virtual-scroll.git
cd virtual-scroll
npm install

Code

// BASIC INITIALIZATION

import VirtualScroll from 'VirtualScroll';


let listSource = [];
for (let i = 0; i < 3000; i++) listSource.push({ itemId: i });

let virtualScroll1 = new VirtualScroll({
  // DOMnode the list will be renderd inside
  root: document.getElementsByClassName('NAME_THE_CONTAINER_WHATEVER_YOU_LIKE')[0],
  itemHeight: 50,
  // ARRAY containg all the objects to be displayed inside the list
  source: listSource,

  /**
   * FUNCTION to be called while creating a single item
   *
   * @param  {object}  itemNodes       empty object provided by the list logic
   * @param  {DOMnode} itemContainer   item container provided by the list logic
   */
  createItemFn: (itemNodes, itemContainer) => {
    // EXAMPLE
    // itemNodes.text1 = document.createElement('span');
    // itemContainer.appendChild(itemNodes.text1);
  },

  /**
   * FUNCTION to be called while updating a single item
   *
   * @param  {object}  itemNodes       object previously filled by createItemFn()
   * @param  {DOMnode} itemContainer   item container provided by the list logic
   * @param  {object}  itemData        object inside listSource array at the current index
   */
  updateItemFn: (itemNodes, itemContainer, itemData) => {
    // EXAMPLE
    // update itemNodes.text1 with itemData.itemId
  }
});

Improvement/TODO

  • Documentation
  • More Unit tests
  • Adding Scrolling using mouse wheel
  • Adding e2e tests
  • handling images (only load the visible items)