Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular2-infinite-scroll

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular2-infinite-scroll

An infinite scroll directive for angular2

  • 0.0.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
871
decreased by-1.25%
Maintainers
1
Weekly downloads
 
Created
Source

Angular 2 Infinite Scroll

A port & modification of ng-infinite-scroll directive for angular 2.

Supported API

The directive triggers Currently supported attributes:

  • (number) "infiniteDcrollDistance" (optional, default: 2) - should get a number
  • (number) "infiniteScrollThrottle" (optional, default: 300) - should get a number of milliseconds for throttle
  • (function) - instead of defining a callback function on the "infinite-scroll" attribute, you should use the event binding (scrolled)="handleScrollCallback()"
  • (boolean) - "scrollWindow" (optional, default: true) - listens to the window scroll instead of the actual element scroll. this allows to invoke a callback function in the scope of the element while listenning to the window scroll.
  • (boolean) - "immediateCheck" (optional, default: false) - invokes the handler immediately to check if a scroll event has been already triggred when the page has been loaded (i.e. - when you refresh a page that has been scrolled).

Behavior

By default, the directive listens to a window scroll event and invoked the callback. To trigger the callback when the actual element is scrolled, these settings should be configured:

  • [scrollWindow]="false"
  • set an explict css "height" value to the element

Usage

In this example, the onScroll callback will be invoked when the window is scrolled:

import { Component } from 'angular2/core';
import { InfiniteScroll } from 'angular2-infinite-scroll';

@Component({
	selector: 'app',
	directives: [ InfiniteScroll ],
	template: `
		<div class="search-results"
		    infinite-scroll
		    [infiniteScrollDistance]="2"
		    [infiniteScrollThrottle]="500"
		    (scrolled)="onScroll()">
		</div>
	`
})
export class App {
	onScroll () {
	    console.log('scrolled!!')
	}
}

in this example, whenever the "search-results" is scrolled, the callback will be invoked:

import { Component } from 'angular2/core';
import { InfiniteScroll } from 'angular2-infinite-scroll';

@Component({
	selector: 'app',
	directives: [ InfiniteScroll ],
	styles: [
		`.search-results {
			height: 20rem;
			overflow: scroll;
		}`
	],
	template: `
		<div class="search-results"
		    infinite-scroll
		    [infiniteScrollDistance]="2"
		    [infiniteScrollThrottle]="500"
		    (scrolled)="onScroll()"
		    [scrollWindow]="false">
		</div>
	`
})
export class App {
	onScroll () {
	    console.log('scrolled!!')
	}
}

Showcase Examples

Keywords

FAQs

Package last updated on 01 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc