UNPKG

6.38 kBTypeScriptView Raw
1import { AfterViewInit, OnInit } from '@angular/core';
2import { NgbScrollSpyProcessChanges, NgbScrollToOptions } from './scrollspy.service';
3import { Observable } from 'rxjs';
4import * as i0 from "@angular/core";
5/**
6 * Common interface for the scroll spy API.
7 *
8 * @internal
9 */
10export interface NgbScrollSpyRef {
11 get active(): string;
12 get active$(): Observable<string>;
13 scrollTo(fragment: string | HTMLElement, options?: NgbScrollToOptions): void;
14}
15/**
16 * A helper directive to that links menu items and fragments together.
17 *
18 * It will automatically add the `.active` class to the menu item when the associated fragment becomes active.
19 *
20 * @since 15.1.0
21 */
22export declare class NgbScrollSpyItem implements OnInit {
23 private _changeDetector;
24 private _scrollSpyMenu;
25 private _scrollSpyAPI;
26 private _destroyRef;
27 private _isActive;
28 /**
29 * References the scroll spy directive, the id of the associated fragment and the parent menu item.
30 *
31 * Can be used like:
32 * - `ngbScrollSpyItem="fragmentId"`
33 * - `[ngbScrollSpyItem]="scrollSpy" fragment="fragmentId"
34 * - `[ngbScrollSpyItem]="[scrollSpy, 'fragmentId']"` parent="parentId"`
35 * - `[ngbScrollSpyItem]="[scrollSpy, 'fragmentId', 'parentId']"`
36 *
37 * As well as together with `[fragment]` and `[parent]` inputs.
38 */
39 set data(data: NgbScrollSpy | string | [NgbScrollSpy, string, string?]);
40 /**
41 * The id of the associated fragment.
42 */
43 fragment: string;
44 /**
45 * The id of the parent scroll spy menu item.
46 */
47 parent: string | undefined;
48 ngOnInit(): void;
49 /**
50 * @internal
51 */
52 _activate(): void;
53 /**
54 * @internal
55 */
56 _deactivate(): void;
57 /**
58 * Returns `true`, if the associated fragment is active.
59 */
60 isActive(): boolean;
61 /**
62 * Scrolls to the associated fragment.
63 */
64 scrollTo(options?: NgbScrollToOptions): void;
65 static ɵfac: i0.ɵɵFactoryDeclaration<NgbScrollSpyItem, never>;
66 static ɵdir: i0.ɵɵDirectiveDeclaration<NgbScrollSpyItem, "[ngbScrollSpyItem]", ["ngbScrollSpyItem"], { "data": { "alias": "ngbScrollSpyItem"; "required": false; }; "fragment": { "alias": "fragment"; "required": false; }; "parent": { "alias": "parent"; "required": false; }; }, {}, never, never, true, never>;
67}
68/**
69 * An optional scroll spy menu directive to build hierarchical menus
70 * and simplify the [`NgbScrollSpyItem`](#/components/scrollspy/api#NgbScrollSpyItem) configuration.
71 *
72 * @since 15.1.0
73 */
74export declare class NgbScrollSpyMenu implements NgbScrollSpyRef, AfterViewInit {
75 private _scrollSpyRef;
76 private _destroyRef;
77 private _map;
78 private _lastActiveItem;
79 private _items;
80 set scrollSpy(scrollSpy: NgbScrollSpy);
81 get active(): string;
82 get active$(): Observable<string>;
83 scrollTo(fragment: string, options?: NgbScrollToOptions): void;
84 getItem(id: string): NgbScrollSpyItem | undefined;
85 ngAfterViewInit(): void;
86 private _rebuildMap;
87 static ɵfac: i0.ɵɵFactoryDeclaration<NgbScrollSpyMenu, never>;
88 static ɵdir: i0.ɵɵDirectiveDeclaration<NgbScrollSpyMenu, "[ngbScrollSpyMenu]", never, { "scrollSpy": { "alias": "ngbScrollSpyMenu"; "required": false; }; }, {}, ["_items"], never, true, never>;
89}
90/**
91 * A directive to put on a scrollable container.
92 *
93 * It will instantiate a [`NgbScrollSpyService`](#/components/scrollspy/api#NgbScrollSpyService).
94 *
95 * @since 15.1.0
96 */
97export declare class NgbScrollSpy implements NgbScrollSpyRef, AfterViewInit {
98 static ngAcceptInputType_scrollBehavior: string;
99 private _initialFragment;
100 private _service;
101 private _nativeElement;
102 /**
103 * A function that is called when the `IntersectionObserver` detects a change.
104 *
105 * See [`NgbScrollSpyOptions`](#/components/scrollspy/api#NgbScrollSpyOptions) for more details.
106 */
107 processChanges: NgbScrollSpyProcessChanges;
108 /**
109 * An `IntersectionObserver` root margin.
110 */
111 rootMargin: string;
112 /**
113 * The scroll behavior for the `.scrollTo()` method.
114 */
115 scrollBehavior: 'auto' | 'smooth';
116 /**
117 * An `IntersectionObserver` threshold.
118 */
119 threshold: number | number[];
120 set active(fragment: string);
121 /**
122 * An event raised when the active section changes.
123 *
124 * Payload is the id of the new active section, empty string if none.
125 */
126 activeChange: Observable<string>;
127 /**
128 * Getter/setter for the currently active fragment id.
129 */
130 get active(): string;
131 /**
132 * Returns an observable that emits currently active section id.
133 */
134 get active$(): Observable<string>;
135 ngAfterViewInit(): void;
136 /**
137 * @internal
138 */
139 _registerFragment(fragment: NgbScrollSpyFragment): void;
140 /**
141 * @internal
142 */
143 _unregisterFragment(fragment: NgbScrollSpyFragment): void;
144 /**
145 * Scrolls to a fragment that is identified by the `ngbScrollSpyFragment` directive.
146 * An id or an element reference can be passed.
147 */
148 scrollTo(fragment: string | HTMLElement, options?: NgbScrollToOptions): void;
149 static ɵfac: i0.ɵɵFactoryDeclaration<NgbScrollSpy, never>;
150 static ɵdir: i0.ɵɵDirectiveDeclaration<NgbScrollSpy, "[ngbScrollSpy]", ["ngbScrollSpy"], { "processChanges": { "alias": "processChanges"; "required": false; }; "rootMargin": { "alias": "rootMargin"; "required": false; }; "scrollBehavior": { "alias": "scrollBehavior"; "required": false; }; "threshold": { "alias": "threshold"; "required": false; }; "active": { "alias": "active"; "required": false; }; }, { "activeChange": "activeChange"; }, never, never, true, never>;
151}
152/**
153 * A directive to put on a fragment observed inside a scrollspy container.
154 *
155 * @since 15.1.0
156 */
157export declare class NgbScrollSpyFragment implements AfterViewInit {
158 private _destroyRef;
159 private _scrollSpy;
160 /**
161 * The unique id of the fragment.
162 * It must be a string unique to the document, as it will be set as the id of the element.
163 */
164 id: string;
165 ngAfterViewInit(): void;
166 static ɵfac: i0.ɵɵFactoryDeclaration<NgbScrollSpyFragment, never>;
167 static ɵdir: i0.ɵɵDirectiveDeclaration<NgbScrollSpyFragment, "[ngbScrollSpyFragment]", never, { "id": { "alias": "ngbScrollSpyFragment"; "required": false; }; }, {}, never, never, true, never>;
168}