UNPKG

5.59 kBTypeScriptView Raw
1import { Message } from '@lumino/messaging';
2import { ISignal } from '@lumino/signaling';
3import { Widget } from './widget';
4/**
5 * A widget which implements a canonical scroll bar.
6 */
7export declare class ScrollBar extends Widget {
8 /**
9 * Construct a new scroll bar.
10 *
11 * @param options - The options for initializing the scroll bar.
12 */
13 constructor(options?: ScrollBar.IOptions);
14 /**
15 * A signal emitted when the user moves the scroll thumb.
16 *
17 * #### Notes
18 * The payload is the current value of the scroll bar.
19 */
20 get thumbMoved(): ISignal<this, number>;
21 /**
22 * A signal emitted when the user clicks a step button.
23 *
24 * #### Notes
25 * The payload is whether a decrease or increase is requested.
26 */
27 get stepRequested(): ISignal<this, 'decrement' | 'increment'>;
28 /**
29 * A signal emitted when the user clicks the scroll track.
30 *
31 * #### Notes
32 * The payload is whether a decrease or increase is requested.
33 */
34 get pageRequested(): ISignal<this, 'decrement' | 'increment'>;
35 /**
36 * Get the orientation of the scroll bar.
37 */
38 get orientation(): ScrollBar.Orientation;
39 /**
40 * Set the orientation of the scroll bar.
41 */
42 set orientation(value: ScrollBar.Orientation);
43 /**
44 * Get the current value of the scroll bar.
45 */
46 get value(): number;
47 /**
48 * Set the current value of the scroll bar.
49 *
50 * #### Notes
51 * The value will be clamped to the range `[0, maximum]`.
52 */
53 set value(value: number);
54 /**
55 * Get the page size of the scroll bar.
56 *
57 * #### Notes
58 * The page size is the amount of visible content in the scrolled
59 * region, expressed in data units. It determines the size of the
60 * scroll bar thumb.
61 */
62 get page(): number;
63 /**
64 * Set the page size of the scroll bar.
65 *
66 * #### Notes
67 * The page size will be clamped to the range `[0, Infinity]`.
68 */
69 set page(value: number);
70 /**
71 * Get the maximum value of the scroll bar.
72 */
73 get maximum(): number;
74 /**
75 * Set the maximum value of the scroll bar.
76 *
77 * #### Notes
78 * The max size will be clamped to the range `[0, Infinity]`.
79 */
80 set maximum(value: number);
81 /**
82 * The scroll bar decrement button node.
83 *
84 * #### Notes
85 * Modifying this node directly can lead to undefined behavior.
86 */
87 get decrementNode(): HTMLDivElement;
88 /**
89 * The scroll bar increment button node.
90 *
91 * #### Notes
92 * Modifying this node directly can lead to undefined behavior.
93 */
94 get incrementNode(): HTMLDivElement;
95 /**
96 * The scroll bar track node.
97 *
98 * #### Notes
99 * Modifying this node directly can lead to undefined behavior.
100 */
101 get trackNode(): HTMLDivElement;
102 /**
103 * The scroll bar thumb node.
104 *
105 * #### Notes
106 * Modifying this node directly can lead to undefined behavior.
107 */
108 get thumbNode(): HTMLDivElement;
109 /**
110 * Handle the DOM events for the scroll bar.
111 *
112 * @param event - The DOM event sent to the scroll bar.
113 *
114 * #### Notes
115 * This method implements the DOM `EventListener` interface and is
116 * called in response to events on the scroll bar's DOM node.
117 *
118 * This should not be called directly by user code.
119 */
120 handleEvent(event: Event): void;
121 /**
122 * A method invoked on a 'before-attach' message.
123 */
124 protected onBeforeAttach(msg: Message): void;
125 /**
126 * A method invoked on an 'after-detach' message.
127 */
128 protected onAfterDetach(msg: Message): void;
129 /**
130 * A method invoked on an 'update-request' message.
131 */
132 protected onUpdateRequest(msg: Message): void;
133 /**
134 * Handle the `'keydown'` event for the scroll bar.
135 */
136 private _evtKeyDown;
137 /**
138 * Handle the `'mousedown'` event for the scroll bar.
139 */
140 private _evtMouseDown;
141 /**
142 * Handle the `'mousemove'` event for the scroll bar.
143 */
144 private _evtMouseMove;
145 /**
146 * Handle the `'mouseup'` event for the scroll bar.
147 */
148 private _evtMouseUp;
149 /**
150 * Release the mouse and restore the node states.
151 */
152 private _releaseMouse;
153 /**
154 * Move the thumb to the specified position.
155 */
156 private _moveThumb;
157 /**
158 * A timeout callback for repeating the mouse press.
159 */
160 private _onRepeat;
161 private _value;
162 private _page;
163 private _maximum;
164 private _repeatTimer;
165 private _orientation;
166 private _pressData;
167 private _thumbMoved;
168 private _stepRequested;
169 private _pageRequested;
170}
171/**
172 * The namespace for the `ScrollBar` class statics.
173 */
174export declare namespace ScrollBar {
175 /**
176 * A type alias for a scroll bar orientation.
177 */
178 type Orientation = 'horizontal' | 'vertical';
179 /**
180 * An options object for creating a scroll bar.
181 */
182 interface IOptions {
183 /**
184 * The orientation of the scroll bar.
185 *
186 * The default is `'vertical'`.
187 */
188 orientation?: Orientation;
189 /**
190 * The value for the scroll bar.
191 *
192 * The default is `0`.
193 */
194 value?: number;
195 /**
196 * The page size for the scroll bar.
197 *
198 * The default is `10`.
199 */
200 page?: number;
201 /**
202 * The maximum value for the scroll bar.
203 *
204 * The default is `100`.
205 */
206 maximum?: number;
207 }
208}