UNPKG

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