UNPKG

ngx-hide-on-scroll

Version:

Hide an element on scroll down or up in Angular.

58 lines (57 loc) 2.3 kB
import { ElementRef, AfterViewInit, OnDestroy, Renderer2, EventEmitter } from '@angular/core'; /** * The `ngxHideOnScroll` directive allows you to hide an html element (e.g. navbar) on scroll down and show it again on scroll up. */ export declare class NgxHideOnScrollDirective implements AfterViewInit, OnDestroy { private elementRef; private renderer2; private platformId; /** * `'Down'`: The element will be hidden on scroll down and it will be shown again on scroll up.<br/>`Up`: The element will be hidden on scroll up and it will be shown again on scroll down. */ hideOnScroll: 'Down' | 'Up'; /** * CSS class name added to the element to hide it. When this property is set, `propertyUsedToHide`, `valueWhenHidden`, and `valueWhenShown` have not effect. */ classNameWhenHidden: string; /** * The CSS property used to hide/show the element. * * @default * 'transform' */ propertyUsedToHide: 'transform' | 'top' | 'bottom' | 'height'; /** * The value of `propertyUsedToHide` when the element is hidden. * * @default * 'translateY(-100%)' */ valueWhenHidden: string; /** * The value of `propertyUsedToHide` when the element is shown. * * @default * 'translateY(0)' */ valueWhenShown: string; /** * The selector of the element you want to listen the scroll event, in case it is not the default browser scrolling element (`document.scrollingElement` or `document.documentElement`). For example [` .mat-sidenav-content`]( https://stackoverflow.com/a/52931772/12954396) if you are using [Angular Material Sidenav]( https://material.angular.io/components/sidenav) */ scrollingElementSelector: string; /** * Emitted when the element is hidden. */ eventElementHidden: EventEmitter<void>; /** * Emitted when the element is shown. */ eventElementShown: EventEmitter<void>; private unsubscribeNotifier; constructor(elementRef: ElementRef<HTMLElement>, renderer2: Renderer2, platformId: string); ngAfterViewInit(): void; ngOnDestroy(): void; private hideElement; private showElement; private getDefaultScrollingElement; }