UNPKG

1.42 kBTypeScriptView Raw
1/** Type for the callback used to revert the scrollbar compensation. */
2export declare type CompensationReverter = () => void;
3/**
4 * Utility to handle the scrollbar.
5 *
6 * It allows to compensate the lack of a vertical scrollbar by adding an
7 * equivalent padding on the right of the body, and to remove this compensation.
8 */
9export declare class ScrollBar {
10 private _document;
11 constructor(_document: any);
12 /**
13 * To be called right before a potential vertical scrollbar would be removed:
14 *
15 * - if there was a scrollbar, adds some compensation padding to the body
16 * to keep the same layout as when the scrollbar is there
17 * - if there was none, there is nothing to do
18 *
19 * @return a callback used to revert the compensation (noop if there was none,
20 * otherwise a function removing the padding)
21 */
22 compensate(): CompensationReverter;
23 /**
24 * Adds a padding of the given width on the right of the body.
25 *
26 * @return a callback used to revert the padding to its previous value
27 */
28 private _adjustBody;
29 /**
30 * Tells whether a scrollbar is currently present on the body.
31 *
32 * @return true if scrollbar is present, false otherwise
33 */
34 private _isPresent;
35 /**
36 * Calculates and returns the width of a scrollbar.
37 *
38 * @return the width of a scrollbar on this page
39 */
40 private _getWidth;
41}