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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ngx-smart-scroll

v1.0.1

Published

ngx-smart-scroll is a powerful, lightweight, and highly customizable infinite scroll library for Angular. Built with performance, developer experience, and flexibility in mind — it supports window and container scrolling, both vertical and horizontal dire

Readme

🔄 ngx-smart-scroll

A blazing-fast, fully customizable infinite scroll directive for Angular.
Supports both vertical and horizontal scrolling with precision configuration, directional triggers, container targeting, and debounce/throttle controls — all baked into a single lightweight package.


🚀 Features

  • ✅ Vertical & horizontal scroll support
  • ✅ Works with container or window scroll targets
  • ✅ Supports offsetPx and percentThreshold triggers
  • ✅ Detect forward, backward, or both scroll directions
  • ✅ Debounce & throttle built-in
  • ✅ Emits rich ScrollInfo metadata (scroll positions, direction)
  • ✅ Lightweight and zone-optimized

📦 Installation

npm install ngx-smart-scroll

🧠 Usage

✅ Basic Vertical Scroll

<div
  class="size-[40rem] p-4 bg-red-400 overflow-auto flex flex-col gap-4"
  ngx-smart-scroll
  [config]="scrollConfig"
  (scrolled)="onScrolled($event)">
  
  <div class="bg-green-200 w-full h-16">Data</div>
  <!-- More content -->
</div>
import { InfiniteScrollConfig, ScrollDirection } from 'ngx-smart-scroll';

scrollConfig: InfiniteScrollConfig = {
  percentThreshold: 80,
  debounceTime: 50,
  scrollDirection: ScrollDirection.VERTICAL,
};

OR

scrollConfig: InfiniteScrollConfig={
  scrollDirection:ScrollDirection.VERTICAL,
  strictPositions:['40%','60%','90%']
}

🆕 strictPositions (Advanced Precision Mode)

Use strictPositions when you want scroll events to trigger only at specific thresholds — such as exactly 90% scrolled or 400px.

Unlike offsetPx or percentThreshold, which fire as soon as the threshold is crossed, strictPositions only fires once per configured position, ensuring no repeated triggering.

Example

scrollConfig: InfiniteScrollConfig={
  scrollDirection:ScrollDirection.VERTICAL,
  strictPositions:['40%','60%','90%','400px']
}
  • ✅ Event triggers once when scroll reaches 40%,60%,400px

🧪 Want Offset-Based Triggers?

Use one of:

offsetPx: 200
percentThreshold: 85

These will continuously trigger as the scroll crosses the offset, unlike strictPositions.

➡️ Horizontal Scroll

<div
  class="size-[40rem] p-4 bg-red-400 overflow-auto flex gap-4"
  ngx-smart-scroll
  [config]="scrollConfig"
  (scrolled)="onScrolled($event)">
  
  <div class="bg-green-200 h-[100rem] w-16">Data</div>
  <!-- More horizontal content -->
</div>
scrollConfig: InfiniteScrollConfig = {
  percentThreshold: 80,
  debounceTime: 50,
  scrollDirection: ScrollDirection.HORIZONTAL,
};

🧩 Configuration

InfiniteScrollConfig

| Property | Type | Default | Description | |--------------------|-------------------------------------------|--------------|------------------------------------------| | scrollDirection | VERTICAL | HORIZONTAL | VERTICAL | Scroll axis to observe | | scrollTarget | string | HTMLElement | ElementRef | Host element | Scroll container to observe | | offsetPx | number | null | Trigger scroll when within X px from end | | percentThreshold | number (0–100) | 100 | Trigger scroll when threshold reached | | scrollType | FORWARD | BACKWARD | ALL | ALL | Scroll direction(s) to trigger from | | debounceTime | number (ms) | 100 | Debounce scroll event frequency | | throttleTime | number (ms) | 0 | Throttle time between emits | | disable | boolean | false | Disable scroll events | | strictPositions | string[] | [] | target points |


📤 Emitted Event

The (scrolled) event returns a rich payload of type:

interface ScrollInfo {
  direction: ScrollType;
  coords: ScrollCoord;
}

interface ScrollCoord {
  scrollTop: number;
  scrollHeight: number;
  clientHeight: number;
  scrollLeft: number;
  scrollWidth: number;
  clientWidth: number;
}

Example:

onScrolled(event: ScrollInfo) {
  console.log('Scrolled:', event.direction);
  console.log('Scroll Position:', event.coords.scrollTop);
}

🔧 Advanced Use Cases

Targeting a Custom Scroll Container

scrollConfig: InfiniteScrollConfig = {
  scrollTarget: '#custom-container',
  offsetPx: 300
};
<div id="custom-container" class="overflow-auto h-[300px]">
  <div ngx-smart-scroll [config]="scrollConfig" (scrolled)="loadMore()">
    <!-- content -->
  </div>
</div>

🔒 Angular Compatibility

"peerDependencies": {
  "@angular/core": ">=14.0.0 <20.0.0",
  "@angular/common": ">=14.0.0 <20.0.0"
}

Tested with Angular v14 through v19.


🧪 Roadmap

  • [ ] Virtual scroll support
  • [ ] Auto-unsubscribe on *ngIf teardown
  • [ ] Infinite scroll loader template
  • [ ] RxJS event stream exposure (as observable)
  • [ ] Mobile-friendly enhancements

✅ License

MIT License. Created by Vishnu kumar.


🔗 Connect with Me

Feel free to connect with me on social media: