Class: Scrollbar
Defined in: packages/blockly/core/scrollbar.ts:33
Class for a pure SVG scrollbar. This technique offers a scrollbar that is guaranteed to work, but may not look or behave like the system's scrollbars.
Properties index
| Property | Description |
|---|---|
| scrollbarThickness | Width of vertical scrollbar or height of horizontal scrollbar in CSS pixels. Scrollbars should be larger on touch devices. |
| lengthAttribute_ | The DOM attribute that controls the length of the scrollbar. Different for horizontal and vertical scrollbars. |
| positionAttribute_ | The DOM attribute that controls the position of the scrollbar. Different for horizontal and vertical scrollbars. |
| onMouseDownBarWrapper_ | Handler for mouse down events on the background of the scrollbar. |
| onMouseDownHandleWrapper_ | Handler for mouse down events on the handle of the scrollbar. |
| onMouseUpWrapper_ | Handler for mouse move events during scrollbar drags. |
| onMouseMoveWrapper_ | Handler for mouse up events to end scrollbar drags. |
Methods index
| Method | Description |
|---|---|
| dispose | Dispose of this scrollbar. Remove DOM elements, event listeners, and theme subscriptions. |
| setHandlePosition | Set the offset of the scrollbar's handle from the scrollbar's position, and change the SVG attribute accordingly. |
| resize | Recalculate the scrollbar's location and its length. |
| resizeViewHorizontal | Recalculate a horizontal scrollbar's location on the screen and path length. This should be called when the layout or size of the window has changed. |
| resizeContentHorizontal | Recalculate a horizontal scrollbar's location within its path and length. This should be called when the contents of the workspace have changed. |
| resizeViewVertical | Recalculate a vertical scrollbar's location on the screen and path length. This should be called when the layout or size of the window has changed. |
| resizeContentVertical | Recalculate a vertical scrollbar's location within its path and length. This should be called when the contents of the workspace have changed. |
| isVisible | Is the scrollbar visible. Non-paired scrollbars disappear when they aren't needed. |
| setContainerVisible | Set whether the scrollbar's container is visible and update display accordingly if visibility has changed. |
| setVisible | Set whether the scrollbar is visible. Only applies to non-paired scrollbars. |
| updateDisplay_ | Update visibility of scrollbar based on whether it thinks it should be visible and whether its containing workspace is visible. We cannot rely on the containing workspace being hidden to hide us because it is not necessarily our parent in the DOM. |
| set | Set the scrollbar handle's position. |
| setOrigin | Record the origin of the workspace that the scrollbar is in, in pixels relative to the injection div origin. This is for times when the scrollbar is used in an object whose origin isn't the same as the main workspace (e.g. in a flyout.) |
Constructors
Constructor
new Scrollbar(
workspace,
horizontal,
opt_pair?,
opt_class?,
opt_margin?
): Scrollbar;
Defined in: packages/blockly/core/scrollbar.ts:157
Parameters
| Parameter | Type | Description |
|---|---|---|
workspace | WorkspaceSvg | Workspace to bind the scrollbar to. |
horizontal | boolean | True if horizontal, false if vertical. |
opt_pair? | boolean | True if scrollbar is part of a horiz/vert pair. |
opt_class? | string | A class to be applied to this scrollbar. |
opt_margin? | number | The margin to apply to this scrollbar. |
Returns
Scrollbar
Properties
scrollbarThickness
static scrollbarThickness: number;
Defined in: packages/blockly/core/scrollbar.ts:38
Width of vertical scrollbar or height of horizontal scrollbar in CSS pixels. Scrollbars should be larger on touch devices.
lengthAttribute_
lengthAttribute_: string;
Defined in: packages/blockly/core/scrollbar.ts:130
The DOM attribute that controls the length of the scrollbar. Different for horizontal and vertical scrollbars.
positionAttribute_
positionAttribute_: string;
Defined in: packages/blockly/core/scrollbar.ts:136
The DOM attribute that controls the position of the scrollbar. Different for horizontal and vertical scrollbars.
onMouseDownBarWrapper_
onMouseDownBarWrapper_: Data;
Defined in: packages/blockly/core/scrollbar.ts:139
Handler for mouse down events on the background of the scrollbar.
onMouseDownHandleWrapper_
onMouseDownHandleWrapper_: Data;
Defined in: packages/blockly/core/scrollbar.ts:142
Handler for mouse down events on the handle of the scrollbar.
onMouseUpWrapper_
onMouseUpWrapper_: Data | null = null;
Defined in: packages/blockly/core/scrollbar.ts:145
Handler for mouse move events during scrollbar drags.
onMouseMoveWrapper_
onMouseMoveWrapper_: Data | null = null;
Defined in: packages/blockly/core/scrollbar.ts:148
Handler for mouse up events to end scrollbar drags.
Methods
dispose()
dispose(): void;
Defined in: packages/blockly/core/scrollbar.ts:258
Dispose of this scrollbar. Remove DOM elements, event listeners, and theme subscriptions.
Returns
void
setHandlePosition()
setHandlePosition(newPosition): void;
Defined in: packages/blockly/core/scrollbar.ts:322
Set the offset of the scrollbar's handle from the scrollbar's position, and change the SVG attribute accordingly.
Parameters
| Parameter | Type | Description |
|---|---|---|
newPosition | number | The new scrollbar handle offset in CSS pixels. |
Returns
void
resize()
resize(opt_metrics?): void;
Defined in: packages/blockly/core/scrollbar.ts:373
Recalculate the scrollbar's location and its length.
Parameters
| Parameter | Type | Description |
|---|---|---|
opt_metrics? | Metrics | A data structure of from the describing all the required dimensions. If not provided, it will be fetched from the host object. |
Returns
void
resizeViewHorizontal()
resizeViewHorizontal(hostMetrics): void;
Defined in: packages/blockly/core/scrollbar.ts:445
Recalculate a horizontal scrollbar's location on the screen and path length. This should be called when the layout or size of the window has changed.
Parameters
| Parameter | Type | Description |
|---|---|---|
hostMetrics | Metrics | A data structure describing all the required dimensions, possibly fetched from the host object. |
Returns
void
resizeContentHorizontal()
resizeContentHorizontal(hostMetrics): void;
Defined in: packages/blockly/core/scrollbar.ts:479
Recalculate a horizontal scrollbar's location within its path and length. This should be called when the contents of the workspace have changed.
Parameters
| Parameter | Type | Description |
|---|---|---|
hostMetrics | Metrics | A data structure describing all the required dimensions, possibly fetched from the host object. |
Returns
void
resizeViewVertical()
resizeViewVertical(hostMetrics): void;
Defined in: packages/blockly/core/scrollbar.ts:548
Recalculate a vertical scrollbar's location on the screen and path length. This should be called when the layout or size of the window has changed.
Parameters
| Parameter | Type | Description |
|---|---|---|
hostMetrics | Metrics | A data structure describing all the required dimensions, possibly fetched from the host object. |
Returns
void
resizeContentVertical()
resizeContentVertical(hostMetrics): void;
Defined in: packages/blockly/core/scrollbar.ts:578
Recalculate a vertical scrollbar's location within its path and length. This should be called when the contents of the workspace have changed.
Parameters
| Parameter | Type | Description |
|---|---|---|
hostMetrics | Metrics | A data structure describing all the required dimensions, possibly fetched from the host object. |
Returns
void
isVisible()
isVisible(): boolean;
Defined in: packages/blockly/core/scrollbar.ts:633
Is the scrollbar visible. Non-paired scrollbars disappear when they aren't needed.
Returns
boolean
True if visible.
setContainerVisible()
setContainerVisible(visible): void;
Defined in: packages/blockly/core/scrollbar.ts:643
Set whether the scrollbar's container is visible and update display accordingly if visibility has changed.
Parameters
| Parameter | Type | Description |
|---|---|---|
visible | boolean | Whether the container is visible |
Returns
void
setVisible()
setVisible(visible): void;
Defined in: packages/blockly/core/scrollbar.ts:658
Set whether the scrollbar is visible. Only applies to non-paired scrollbars.
Parameters
| Parameter | Type | Description |
|---|---|---|
visible | boolean | True if visible. |
Returns
void
updateDisplay_()
updateDisplay_(): void;
Defined in: packages/blockly/core/scrollbar.ts:690
Update visibility of scrollbar based on whether it thinks it should be visible and whether its containing workspace is visible. We cannot rely on the containing workspace being hidden to hide us because it is not necessarily our parent in the DOM.
Returns
void
set()
set(value, updateMetrics?): void;
Defined in: packages/blockly/core/scrollbar.ts:855
Set the scrollbar handle's position.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | number | The content displacement, relative to the view in pixels. |
updateMetrics? | boolean | Whether to update metrics on this set call. Defaults to true. |
Returns
void
setOrigin()
setOrigin(x, y): void;
Defined in: packages/blockly/core/scrollbar.ts:871
Record the origin of the workspace that the scrollbar is in, in pixels relative to the injection div origin. This is for times when the scrollbar is used in an object whose origin isn't the same as the main workspace (e.g. in a flyout.)
Parameters
| Parameter | Type | Description |
|---|---|---|
x | number | The x coordinate of the scrollbar's origin, in CSS pixels. |
y | number | The y coordinate of the scrollbar's origin, in CSS pixels. |
Returns
void