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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@libs-ui/components-scroll-overlay

v0.2.356-24

Published

> Directive tạo thanh cuộn tùy chỉnh (custom scrollbar) thay thế thanh cuộn mặc định của trình duyệt.

Readme

@libs-ui/components-scroll-overlay

Directive tạo thanh cuộn tùy chỉnh (custom scrollbar) thay thế thanh cuộn mặc định của trình duyệt.

Giới thiệu

LibsUiComponentsScrollOverlayDirective là một standalone Angular directive giúp tạo ra thanh cuộn tùy chỉnh với giao diện đẹp mắt, hỗ trợ kéo thả, tự động ẩn hiện và tùy biến màu sắc.

Tính năng

  • ✅ Custom Scrollbar (thay thế native scrollbar)
  • ✅ Hỗ trợ cả chiều ngang (Horizontal) và chiều dọc (Vertical)
  • ✅ Tự động ẩn hiện khi hover
  • ✅ Hỗ trợ kéo thả (Drag & Drop) thanh cuộn
  • ✅ Tùy biến màu sắc, kích thước
  • ✅ Hỗ trợ Mobile/Touch devices (thông qua getDragEventByElement)
  • ✅ Resize Observer tự động cập nhật kích thước

Khi nào sử dụng

  • Khi cần giao diện thanh cuộn đồng bộ trên các trình duyệt/hệ điều hành khác nhau.
  • Khi cần thanh cuộn nhỏ gọn, overlay lên nội dung mà không chiếm diện tích layout.
  • Khi cần tùy biến màu sắc thanh cuộn theo theme của ứng dụng.

Cài đặt

# npm
npm install @libs-ui/components-scroll-overlay

# yarn
yarn add @libs-ui/components-scroll-overlay

Import

import { LibsUiComponentsScrollOverlayDirective } from '@libs-ui/components-scroll-overlay';

@Component({
  standalone: true,
  imports: [LibsUiComponentsScrollOverlayDirective],
  // ...
})
export class YourComponent {}

Ví dụ

Basic

Thêm directive vào phần tử có overflow: scroll hoặc overflow: auto.

<div
  LibsUiComponentsScrollOverlayDirective
  class="h-[300px] w-full overflow-y-auto">
  <!-- Content dài -->
</div>

With Options

<div
  LibsUiComponentsScrollOverlayDirective
  [options]="{
    scrollbarColor: '#e5e7eb',
    scrollThumbColor: '#9ca3af',
    scrollbarWidth: 8,
    scrollbarPadding: 0
  }"
  class="h-[300px] w-full overflow-y-auto">
  <!-- Content -->
</div>

API

LibsUiComponentsScrollOverlayDirective

Selector: [LibsUiComponentsScrollOverlayDirective]

Inputs

| Property | Type | Default | Description | | ----------------------- | ----------------------- | -------------- | ------------------------------------------------------------- | | [options] | IScrollOverlayOptions | {} | Cấu hình cho thanh cuộn (màu sắc, kích thước, behavior). | | [classContainer] | string | '' | Class CSS thêm vào container bao ngoài (do directive tạo ra). | | [elementScroll] | HTMLElement | Host Element | Element cần scroll (mặc định là element gắn directive). | | [elementCheckScrollX] | HTMLElement | undefined | Element để tính toán scroll width (nếu khác element scroll). | | [elementCheckScrollY] | HTMLElement | undefined | Element để tính toán scroll height (nếu khác element scroll). | | [debugMode] | boolean | false | Bật chế độ debug log. | | [ignoreInit] | boolean | false | Nếu true, directive sẽ không khởi tạo scrollbar. |

Outputs

| Property | Type | Description | | ------------------- | ------- | ---------------------------------------- | | (outScroll) | Event | Emit khi scroll event xảy ra. | | (outScrollX) | Event | Emit khi scroll chiều ngang thay đổi. | | (outScrollY) | Event | Emit khi scroll chiều dọc thay đổi. | | (outScrollTop) | Event | Emit khi scroll lên đầu (scrollTop = 0). | | (outScrollBottom) | Event | Emit khi scroll xuống cuối. |

Types & Interfaces

export type TYPE_SCROLL_DIRECTION = 'X' | 'Y';
export type TYPE_SCROLL_OVERFLOW = 'hidden' | 'scroll';

export interface IScrollOverlayOptions {
  ignoreTransparentScrollBarColorDefault?: boolean; // Nếu true, dùng 'auto' thay vì 'transparent' cho scrollbar-color
  scrollbarWidth?: number; // Độ rộng của track scrollbar (default: 10)
  scrollbarColor?: string; // Màu nền của track
  scrollbarHoverColor?: string; // Màu nền của track khi hover
  scrollThumbColor?: string; // Màu của thanh cuộn (thumb)
  scrollThumbHoverColor?: string; // Màu của thanh cuộn khi hover
  scrollbarPadding?: number; // Padding cho thumb (default: 2)
  scrollX?: TYPE_SCROLL_OVERFLOW; // 'scroll' hoặc 'hidden' cho chiều ngang
  scrollXOpacity0?: boolean; // Nếu true, thanh cuộn ngang vĩnh viễn ẩn (opacity 0) nhưng vẫn scroll được? (Check logic: visible but opacity 0)
  scrollY?: TYPE_SCROLL_OVERFLOW; // 'scroll' hoặc 'hidden' cho chiều dọc
  scrollYOpacity0?: boolean; // Tương tự cho chiều dọc
}

Styling

Directive tự động inject styles vào thẻ <style id="id-style-tag-custom-scroll-overlay"> trong <head>. Cấu trúc DOM được tạo ra:

<div class="lib-ui-scroll-overlay-container ...">
  <!-- Host Element -->
  <div class="scrollbar-track scrollbar-track-X">
    <div class="scrollbar-thumb scrollbar-thumb-X"></div>
  </div>
  <div class="scrollbar-track scrollbar-track-Y">
    <div class="scrollbar-thumb scrollbar-thumb-Y"></div>
  </div>
</div>

Công nghệ

| Technology | Version | Purpose | | ---------- | ------- | ------------------- | | Angular | 18+ | Framework | | RxJS | 7.x | Event Handling | | DOM API | - | Scroll Manipulation |

Demo

npx nx serve core-ui

Truy cập: http://localhost:4500/components/scroll-overlay