Angular Body Scroll Lock
This is an Angular library that implements the body-scroll-lock, which can have minor problems in an Angular Project. The Angular Body Scroll Lock purpose is to optimize and implements Angular features, but without changing the original script logic. Every change on the body-scroll-lock package will be synchronized in this project too.
Install
$ yarn add ng-body-scroll-lock or $ npm install ng-body-scroll-lock
Usage
Import Module/Service in your Module
Import the NgBodyScrollLockModule in your module or import NgBodyScrollLockService in your providers.
!!! Be aware that on some Angular versions it would not work importing the NgBodyScrollLockModule, in that case, you have to import the NgBodyScrollLockService in providers!
Example with module
;;;; ;;
Example with service
typescript;;;; ;;
Import Service to use Body Scroll Lock
Import the NgBodyScrollLockService where you want to use it
Example
;;
Functions
Function | Arguments | Return | Description |
---|---|---|---|
DisableBodyScroll |
targetElement: HTMLElement , options: BodyScrollOptions |
void |
Disables body scroll while enabling scroll on target element |
EnableBodyScroll |
targetElement: HTMLElement |
void |
Enables body scroll and removing listeners on target element |
ClearAllBodyScrollLocks |
null |
void |
Clears all scroll locks |