1 | import { ChangeDetectorRef, OnDestroy } from '@angular/core';
|
2 | import { Observable } from 'rxjs';
|
3 | import { NgbScrollSpyRef } from './scrollspy';
|
4 | import * as i0 from "@angular/core";
|
5 | export type NgbScrollSpyProcessChanges = (state: {
|
6 | entries: IntersectionObserverEntry[];
|
7 | rootElement: HTMLElement;
|
8 | fragments: Set<Element>;
|
9 | scrollSpy: NgbScrollSpyService;
|
10 | options: NgbScrollSpyOptions;
|
11 | }, changeActive: (active: string) => void, context: object) => void;
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | export interface NgbScrollSpyOptions extends Pick<IntersectionObserverInit, 'root' | 'rootMargin' | 'threshold'> {
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | changeDetectorRef?: ChangeDetectorRef;
|
29 | |
30 |
|
31 |
|
32 | initialFragment?: string | HTMLElement;
|
33 | |
34 |
|
35 |
|
36 |
|
37 | fragments?: (string | HTMLElement)[];
|
38 | |
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | processChanges?: NgbScrollSpyProcessChanges;
|
49 | |
50 |
|
51 |
|
52 | root?: HTMLElement;
|
53 | |
54 |
|
55 |
|
56 | rootMargin?: string;
|
57 | |
58 |
|
59 |
|
60 | scrollBehavior?: 'auto' | 'smooth';
|
61 | |
62 |
|
63 |
|
64 | threshold?: number | number[];
|
65 | }
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | export interface NgbScrollToOptions extends ScrollOptions {
|
73 | |
74 |
|
75 |
|
76 | behavior?: 'auto' | 'smooth';
|
77 | }
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | export declare class NgbScrollSpyService implements NgbScrollSpyRef, OnDestroy {
|
86 | private _observer;
|
87 | private _containerElement;
|
88 | private _fragments;
|
89 | private _preRegisteredFragments;
|
90 | private _active$;
|
91 | private _distinctActive$;
|
92 | private _active;
|
93 | private _config;
|
94 | private _document;
|
95 | private _platformId;
|
96 | private _scrollBehavior;
|
97 | private _diChangeDetectorRef;
|
98 | private _changeDetectorRef;
|
99 | private _zone;
|
100 | constructor();
|
101 | /**
|
102 | * Getter for the currently active fragment id. Returns empty string if none.
|
103 | */
|
104 | get active(): string;
|
105 | /**
|
106 | * An observable emitting the currently active fragment. Emits empty string if none.
|
107 | */
|
108 | get active$(): Observable<string>;
|
109 | /**
|
110 | * Starts the scrollspy service and observes specified fragments.
|
111 | *
|
112 | * You can specify a list of options to pass, like the root element, initial fragment, scroll behavior, etc.
|
113 | * See the [`NgbScrollSpyOptions`](#/components/scrollspy/api#NgbScrollSpyOptions) interface for more details.
|
114 | */
|
115 | start(options?: NgbScrollSpyOptions): void;
|
116 | /**
|
117 | * Stops the service and unobserves all fragments.
|
118 | */
|
119 | stop(): void;
|
120 | /**
|
121 | * Scrolls to a fragment, it must be known to the service and contained in the root element.
|
122 | * An id or an element reference can be passed.
|
123 | *
|
124 | * [`NgbScrollToOptions`](#/components/scrollspy/api#NgbScrollToOptions) can be passed.
|
125 | */
|
126 | scrollTo(fragment: string | HTMLElement, options?: NgbScrollToOptions): void;
|
127 | /**
|
128 | * Adds a fragment to observe. It must be contained in the root element.
|
129 | * An id or an element reference can be passed.
|
130 | */
|
131 | observe(fragment: string | HTMLElement): void;
|
132 | /**
|
133 | * Unobserves a fragment.
|
134 | * An id or an element reference can be passed.
|
135 | */
|
136 | unobserve(fragment: string | HTMLElement): void;
|
137 | ngOnDestroy(): void;
|
138 | private _cleanup;
|
139 | static ɵfac: i0.ɵɵFactoryDeclaration<NgbScrollSpyService, never>;
|
140 | static ɵprov: i0.ɵɵInjectableDeclaration<NgbScrollSpyService>;
|
141 | }
|