Skip to main content

Class: ScrollbarPair

Defined in: packages/blockly/core/scrollbar_pair.ts:24

Class for a pair of scrollbars. Horizontal and vertical.

Properties index​

PropertyDescription
hScroll-
vScroll-
corner_-

Methods index​

MethodDescription
disposeDispose of this pair of scrollbars. Unlink from all DOM elements to prevent memory leaks.
resizeRecalculate both of the scrollbars' locations and lengths. Also reposition the corner rectangle.
canScrollHorizontallyReturns whether scrolling horizontally is enabled.
canScrollVerticallyReturns whether scrolling vertically is enabled.
setSet the handles of both scrollbars.
setXSet the handle of the horizontal scrollbar to be at a certain position in CSS pixels relative to its parents.
setYSet the handle of the vertical scrollbar to be at a certain position in CSS pixels relative to its parents.
setContainerVisibleSet whether this scrollbar's container is visible.
isVisibleIf any of the scrollbars are visible. Non-paired scrollbars may disappear when they aren't needed.
setVisibleSets the visibility of any existing scrollbars.
resizeContentRecalculates the scrollbars' locations within their path and length. This should be called when the contents of the workspace have changed.
resizeViewRecalculates the scrollbars' locations on the screen and path length. This should be called when the layout or size of the window has changed.

Constructors​

Constructor​

new ScrollbarPair(
workspace,
addHorizontal?,
addVertical?,
opt_class?,
opt_margin?
): ScrollbarPair;

Defined in: packages/blockly/core/scrollbar_pair.ts:40

Parameters​

ParameterTypeDescription
workspaceWorkspaceSvgWorkspace to bind the scrollbars to.
addHorizontal?booleanWhether to add a horizontal scrollbar. Defaults to true.
addVertical?booleanWhether to add a vertical scrollbar. Defaults to true.
opt_class?stringA class to be applied to these scrollbars.
opt_margin?numberThe margin to apply to these scrollbars.

Returns​

ScrollbarPair

Properties​

hScroll​

hScroll: Scrollbar | null = null;

Defined in: packages/blockly/core/scrollbar_pair.ts:25


vScroll​

vScroll: Scrollbar | null = null;

Defined in: packages/blockly/core/scrollbar_pair.ts:26


corner_​

corner_: SVGRectElement | null = null;

Defined in: packages/blockly/core/scrollbar_pair.ts:27

Methods​

dispose()​

dispose(): void;

Defined in: packages/blockly/core/scrollbar_pair.ts:84

Dispose of this pair of scrollbars. Unlink from all DOM elements to prevent memory leaks.

Returns​

void


resize()​

resize(): void;

Defined in: packages/blockly/core/scrollbar_pair.ts:102

Recalculate both of the scrollbars' locations and lengths. Also reposition the corner rectangle.

Returns​

void


canScrollHorizontally()​

canScrollHorizontally(): boolean;

Defined in: packages/blockly/core/scrollbar_pair.ts:185

Returns whether scrolling horizontally is enabled.

Returns​

boolean

True if horizontal scroll is enabled.


canScrollVertically()​

canScrollVertically(): boolean;

Defined in: packages/blockly/core/scrollbar_pair.ts:194

Returns whether scrolling vertically is enabled.

Returns​

boolean

True if vertical scroll is enabled.


set()​

set(
x,
y,
updateMetrics
): void;

Defined in: packages/blockly/core/scrollbar_pair.ts:226

Set the handles of both scrollbars.

Parameters​

ParameterTypeDescription
xnumberThe horizontal content displacement, relative to the view in pixels.
ynumberThe vertical content displacement, relative to the view in pixels.
updateMetricsbooleanWhether to update metrics on this set call. Defaults to true.

Returns​

void


setX()​

setX(x): void;

Defined in: packages/blockly/core/scrollbar_pair.ts:259

Set the handle of the horizontal scrollbar to be at a certain position in CSS pixels relative to its parents.

Parameters​

ParameterTypeDescription
xnumberHorizontal scroll value.

Returns​

void


setY()​

setY(y): void;

Defined in: packages/blockly/core/scrollbar_pair.ts:271

Set the handle of the vertical scrollbar to be at a certain position in CSS pixels relative to its parents.

Parameters​

ParameterTypeDescription
ynumberVertical scroll value.

Returns​

void


setContainerVisible()​

setContainerVisible(visible): void;

Defined in: packages/blockly/core/scrollbar_pair.ts:282

Set whether this scrollbar's container is visible.

Parameters​

ParameterTypeDescription
visiblebooleanWhether the container is visible.

Returns​

void


isVisible()​

isVisible(): boolean;

Defined in: packages/blockly/core/scrollbar_pair.ts:297

If any of the scrollbars are visible. Non-paired scrollbars may disappear when they aren't needed.

Returns​

boolean

True if visible.


setVisible()​

setVisible(visible): void;

Defined in: packages/blockly/core/scrollbar_pair.ts:313

Sets the visibility of any existing scrollbars.

Parameters​

ParameterTypeDescription
visiblebooleanTrue if visible.

Returns​

void


resizeContent()​

resizeContent(hostMetrics): void;

Defined in: packages/blockly/core/scrollbar_pair.ts:325

Recalculates the scrollbars' locations within their path and length. This should be called when the contents of the workspace have changed.

Parameters​

ParameterTypeDescription
hostMetricsMetricsA data structure describing all the required dimensions, possibly fetched from the host object.

Returns​

void


resizeView()​

resizeView(hostMetrics): void;

Defined in: packages/blockly/core/scrollbar_pair.ts:341

Recalculates the scrollbars' locations on the screen and path length. This should be called when the layout or size of the window has changed.

Parameters​

ParameterTypeDescription
hostMetricsMetricsA data structure describing all the required dimensions, possibly fetched from the host object.

Returns​

void