UNPKG

2.01 kBTypeScriptView Raw
1import BaseComponent from './base-component';
2
3declare class ScrollSpy extends BaseComponent {
4 constructor(element: string | Element, options?: Partial<ScrollSpy.Options>);
5
6 /**
7 * When using scrollspy in conjunction with adding or removing of
8 * elements from the DOM, you’ll need to call the refresh method like
9 * so:
10 */
11 refresh(): void;
12
13 /**
14 * Static method which allows you to get the scrollspy instance associated
15 * with a DOM element
16 */
17 static getInstance(element: Element, options?: Partial<ScrollSpy.Options>): ScrollSpy;
18
19 static jQueryInterface: ScrollSpy.jQueryInterface;
20
21 // static NAME: 'scrollspy';
22
23 /**
24 * Default settings of this plugin
25 *
26 * @link https://getbootstrap.com/docs/5.0/getting-started/javascript/#default-settings
27 */
28 static Default: ScrollSpy.Options;
29}
30
31declare namespace ScrollSpy {
32 enum Events {
33 /**
34 * This event fires on the scroll element whenever a new item becomes
35 * activated by the scrollspy.
36 */
37 activate = 'activate.bs.scrollspy',
38 }
39
40 interface Options {
41 /**
42 * Pixels to offset from top when calculating position of scroll.
43 *
44 * @default 10
45 */
46 offset: number;
47
48 /**
49 * Finds which section the spied element is in. auto will choose the
50 * best method to get scroll coordinates. offset will use the
51 * Element.getBoundingClientRect() method to get scroll coordinates.
52 * position will use the HTMLElement.offsetTop and
53 * HTMLElement.offsetLeft properties to get scroll coordinates.
54 *
55 * @default 'auto'
56 */
57 method: 'auto' | 'offset' | 'position';
58
59 /**
60 * Specifies element to apply Scrollspy plugin.
61 */
62 target: string | Element | JQuery;
63 }
64
65 type jQueryInterface = (config?: Partial<Options> | 'refresh' | 'dispose') => void;
66}
67
68export default ScrollSpy;