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

ngx-ui-scroll-cost

v1.0.2

Published

Infinite/virtual scroll for Angular

Downloads

160

Readme

Build Status npm version

NgxUiScroll

Unlimited bidirectional scrolling over limited viewport. A directive for Angular framework (version 5). Built with angular-library-starter. Inspired by angular-ui-scroll (AngularJS, since 2013). Demo is available at dhilt.github.io/ngx-ui-scroll.

Motivation

The common way to present a list of data elements of undefined length is to start with a small portion - just enough to fill the space on the page. Additional blocks are added to the list as the user scrolls to the edge of the list. The problem with this approach is that even though blocks at the edge of the list become invisible as they scroll out of the view, they are still a part of the page and still consume resources.

The *uiScroll directive dynamically destroys elements as they become invisible and recreating them if they become visible again. This is structural directive that works like *ngFor and instantiates a template once per item from a collection. The *uiScroll directive is asking the datasource for data to build and render elements until it has enough elements to fill out the viewport. It will start retrieving new data for new elements again if the user scrolls to the edge of visible element list.

Features

  • unlimited virtual scroll
  • virtualization settings (you can specify when and how many items need to be requested/rendered by the uiScroll), demos
  • infinite mode (items rendered once are never removed), demo
  • horizontal mode, demo
  • different item heights, demo
  • special Adapter API object to manipulate and assess the scroller, demos

Getting

The *uiScroll directive is a part of UiScrollModule which is available via npm –

npm install ngx-ui-scroll

The UiScrollModule has to be imported in the App/feature module where it is going to be used.

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { UiScrollModule } from 'ngx-ui-scroll';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    UiScrollModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Usage

Basic usage template may look like

<div class="viewport">
  <div *uiScroll="let item of datasource">
    <b>{{item.text}}</b>
  </div>
</div>

where the viewport is a scrollable area of finite height.

.viewport {
    height: 300px;
    overflow-y: auto;
    overflow-anchor: none;
}

*uiScroll acts like *ngFor, but the datasource is an object of special type (IDatasource) that can be imported to the host component from UiScrollModule. It implements method get to be used by the *uiScroll directive to access the data by index and count parameters.

import { IDatasource } from 'ngx-ui-scroll';

export class AppComponent {

  public datasource: IDatasource = {
    get: (index, count, success) => {
      const data = [];
      for (let i = index; i <= index + count - 1; i++) {
        data.push({ text: 'item #' + i });
      }
      success(data);
    }
  };
}

Datasource.get must provide an array of count data-items started from index position. Datasource.get has 3 signatures: callback based, Promise based and Observable based. So, if you want some remote API to be a source of your data, basically it may look like

  public datasource: IDatasource = {
    get: (index, count) =>
      this.http.get(`${myApiUrl}?index=${index}&count=${count}`)
  };

More details could be found on the DEMO page.

Developing

There are some npm scripts available from package.json:

  • npm start to run demo App on port 4200
  • npm test to run Karma tests
  • npm run build to build the ngx-ui-scroll module into the ./dist folder
  • npm run install-package to build tar-gzipped version of package and install it locally into ./node_modules

The work has just begun. We have great plans and any participation is welcome! So, feel free to submit new issues and open Pull Requests.


2018 © dhilt, Hill30 Inc