@thejlifex/ngx-scroll-spy
Version:
An Angular library that can spy the position of elements (inside a scrollable container) and emit the currently active (visible) element in the viewport.
59 lines (58 loc) • 2.22 kB
TypeScript
import { OnDestroy } from '@angular/core';
import { Observable } from 'rxjs';
import { SpyTarget } from './models/spy-target';
import { SpyTargetIsIntersectingEvent } from './models/spy-target-is-intersecting-event';
import * as i0 from "@angular/core";
/**
* Scroll spy service.
*
* Creates a scroll-spy on the Document/Body per default and destroys it when the service is destroyed.
*
* Allows you to create (and destroy) scroll-spy on a scroll-container (any scrollable element).
*/
export declare class ScrollSpyService implements OnDestroy {
private platformId;
/**
* Default scroll-spy on the default scroll element (Document/Body).
*/
private readonly defaultScrollSpy;
/**
* Map containing created scroll-spies (on any scrollable elements).
*
* @key scrollContainerId
* @value ScrollSpy
*/
private readonly scrollSpies;
constructor(platformId: string);
ngOnDestroy(): void;
/**
* Create a scroll-spy for the provided `scrollContainer`.
*/
createScrollSpy(scrollContainerId: string, scrollContainer: Element): void;
/**
* Destroy the scroll-spy with ID equals the provided `scrollContainerId`.
*/
destroyScrollSpy(scrollContainerId: string): void;
/**
* Get the `spyTargetIsIntersecting$` observable for the provided `scrollContainerId`,
*
* Or the `spyTargetIsIntersecting$` of the `defaultScrollSpy` when `scrollContainerId` is `undefined`.
*/
getSpyTargetIsIntersecting$(scrollContainerId?: string): Observable<SpyTargetIsIntersectingEvent>;
/**
* Adds a spy-target and starts to observe that target.
*/
addTarget(spyTarget: SpyTarget): void;
/**
* Removes a spy-target and stops observing that target.
*/
removeTarget(spyTarget: SpyTarget): void;
/**
* Get the scroll-spy for the proivded `scrollContainerId`.
*
* When `scrollContainerId` is `undefined` the `defaultScrollSpy` is returned.
*/
private getScrollSpy;
static ɵfac: i0.ɵɵFactoryDeclaration<ScrollSpyService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<ScrollSpyService>;
}