All Projects → jfcere → ngx-malihu-scrollbar

jfcere / ngx-malihu-scrollbar

Licence: MIT license
Angular 2+ scrollbar customization using Malihu jQuery Custom Scrollbar plugin

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ngx-malihu-scrollbar

angular-ellipsis
A simple lightweight library for Angular which removes excess text and add ellipsis symbol to end of text before text overflows container
Stars: ✭ 16 (-72.88%)
Mutual labels:  directive, ngx
Ngx Daterangepicker Material
Pure Angular 2+ date range picker with material design theme, a demo here:
Stars: ✭ 169 (+186.44%)
Mutual labels:  directive, ngx
angular-scrollspy
A simple lightweight library for Angular which automatically updates links to indicate the currently active section in the viewport
Stars: ✭ 34 (-42.37%)
Mutual labels:  directive, ngx
ngx-localstorage
An Angular wrapper for localstorage/sessionstorage access.
Stars: ✭ 27 (-54.24%)
Mutual labels:  service, directive
Vuebar
(🗃️ Archived) Vue 2 directive for custom scrollbar that uses native scroll behavior. Lightweight, performant, customizable and without dependencies. Used successfully in production on https://ggather.com
Stars: ✭ 650 (+1001.69%)
Mutual labels:  directive, scrollbar
angular-inviewport
A simple lightweight library for Angular with no other dependencies that detects when an element is within the browser viewport and adds a "sn-viewport-in" or "sn-viewport-out" class to the element
Stars: ✭ 72 (+22.03%)
Mutual labels:  directive, ngx
InitWare
The InitWare Suite of Middleware allows you to manage services and system resources as logical entities called units. Its main component is a service management ("init") system.
Stars: ✭ 164 (+177.97%)
Mutual labels:  service
gps-permission-checks-livedata
Sample project to demonstrate how GPS and Runtime Location Permission checks can be done on UI and Background Service using LiveData
Stars: ✭ 37 (-37.29%)
Mutual labels:  service
api
Core service used to handle events from clients
Stars: ✭ 36 (-38.98%)
Mutual labels:  service
senlin
Clustering service for managing homogeneous objects in OpenStack. Mirror of code maintained at opendev.org.
Stars: ✭ 43 (-27.12%)
Mutual labels:  service
svg-pan-zoom-container
A vanilla-js module for adding zoom-on-wheel and pan-on-drag behavior to inline SVG elements.
Stars: ✭ 31 (-47.46%)
Mutual labels:  directive
esl
Lightweight and flexible UI component library based on web components technology for creating basic UX modules
Stars: ✭ 53 (-10.17%)
Mutual labels:  scrollbar
snippets-service
Service powering snippets on Firefox's about:home.
Stars: ✭ 32 (-45.76%)
Mutual labels:  service
acikseminer2020
servis ve süreçlerle ilgili basit örnekler
Stars: ✭ 41 (-30.51%)
Mutual labels:  service
springboot-microservice-with-spring-cloud-netflix
msa backend service example with springboot REST API
Stars: ✭ 36 (-38.98%)
Mutual labels:  service
lion
A simple, modular Discord bot from scratch
Stars: ✭ 15 (-74.58%)
Mutual labels:  service
easemesh
A service mesh implementation for connecting, control, and observe services in spring-cloud.
Stars: ✭ 454 (+669.49%)
Mutual labels:  service
react-custom-scroller
Super simple React component for creating a custom scrollbar cross-browser and cross-devices.
Stars: ✭ 30 (-49.15%)
Mutual labels:  scrollbar
chrly
Lightweight implementation of Minecraft skins system server. It's packaged and distributed as a Docker image.
Stars: ✭ 23 (-61.02%)
Mutual labels:  service
WPWatcher
Wordpress Watcher is a wrapper for WPScan that manages scans on multiple sites and reports by email and/or syslog. Schedule scans and get notified when vulnerabilities, outdated plugins and other risks are found.
Stars: ✭ 34 (-42.37%)
Mutual labels:  service

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].