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-malihu-scrollbar

v9.0.0

Published

Angular scrollbar customization using Malihu jQuery Custom Scrollbar plugin

Downloads

4,580

Readme

ngx-malihu-scrollbar

CircleCI Coverage Status version npm dependencies Status peerDependencies Status monthly Downloads

Angular Malihu jQuery Custom Scrollbar directive and service.

Malihu jQuery Custom Scrollbar is a highly customizable scrollbar plugin that include vertical and/or horizontal scrollbar(s), adjustable scrolling momentum, mouse-wheel (via jQuery mousewheel plugin), keyboard and touch support, ready-to-use themes and customization via CSS, RTL direction support, option parameters for full control of scrollbar functionality, methods for triggering actions like scroll-to, update, destroy etc., user-defined callbacks and more.

Table of contents

Installation

Use the following command to add ngx-malihu-scrollbar library to your package.json file. Note that jQuery will automatically be downloaded as a dependency.

npm install ngx-malihu-scrollbar --save

You will need to add Malihu Custom Scrollbar javascript and css files with jQuery to your application.

If you are using Angular CLI you can follow the example below...

angular.json

"styles": [
  "src/styles.scss",
+ "node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css"
],
"scripts": [
+ "node_modules/jquery/dist/jquery.min.js",
+ "node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"
],

tsconfig.app.json

{
  "compilerOptions": {
    ...
    "types": [
+     "jquery",
+     "mcustomscrollbar"
    ]
  },
  ...
}

Usage

You must import MalihuScrollbarModule inside your module to be able to use malihu-scrollbar directive or MalihuScrollbarService.

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
+ import { MalihuScrollbarModule } from 'ngx-malihu-scrollbar';

import { HomeComponent } from './home.component';

@NgModule({
  imports: [
    CommonModule,
+   MalihuScrollbarModule.forRoot(),
  ],
  declarations: [HomeComponent],
})

ngx-malihu-scrollbar provides both a directive and a service to apply the custom scrollbar on your HTML element.

For a complete list of available customization options please refer to the original Malihu Custom Scrollbar documentation.

Directive

You can use malihu-scrollbar directive directly on an HTML element and provide plugin options using scrollbarOptions input property.

example.component.ts

public scrollbarOptions = { axis: 'yx', theme: 'minimal-dark' };

example.component.html

<div malihu-scrollbar [scrollbarOptions]="scrollbarOptions">
   Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...
</div>

Service

Alternatively, you can initialize scrollbar customizations using MalihuScrollbarService by providing either a string selector, a jQuery object or an HTML element along with the scrolling options.

The service also provide access to other Malihu Custom Scrollbar methods such as scrollTo, stop, update, disable and destroy.

constructor(
  private mScrollbarService: MalihuScrollbarService,
) { }

ngAfterViewInit() {
  this.mScrollbarService.initScrollbar('#myElementId', { axis: 'y', theme: 'dark-thick', scrollButtons: { enable: true } });
}

ngOnDestroy() {
  this.mScrollbarService.destroy('#myElementId');
}

FAQ

Can we customize the scrollbars?

Of course, the scrollbars are fully customizable. You can easily clone an existing theme and modify the CSS to apply your own styling. Follow the instructions provided on the original Malihu Custom Scrollbar Plugin documentation for more details.

The "custom-theme" example on the bottom of the demo is a good example of customization where I created a my own "metro" theme.

How can we apply scrollbar customization on the body?

Using MalihuScrollbarService you can target document.body to apply customization to the body scrollbar.

Note that this will automaticaly add some specific CSS to the <body> element that is needed to allow scrollbar customization.

import { MalihuScrollbarService } from 'ngx-malihu-scrollbar';

constructor(
  private mScrollbarService: MalihuScrollbarService,
) { }

ngOnInit() {
  this.mScrollbarService.initScrollbar(document.body, { axis: 'y', theme: 'dark-3' });
}

Demo application

You can find the demo source code inside the demo directory.

The following commands will clone the repository, install npm dependencies and serve the application @ http://localhost:4200

git clone https://github.com/jfcere/ngx-malihu-scrollbar.git

npm install

ng serve

Contribution

Contributions are always welcome, just make sure that ...

  • Your code style matches with the rest of the project
  • Unit tests pass
  • Linter passes

License

Licensed under MIT.