blockly > Scrollbar

Scrollbar class

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.

Signature:

export declare class Scrollbar 

Constructors

Constructor Modifiers Description
(constructor)(workspace, horizontal, opt_pair, opt_class, opt_margin) Constructs a new instance of the Scrollbar class

Properties

Property Modifiers Type Description
lengthAttribute_ string The DOM attribute that controls the length of the scrollbar. Different for horizontal and vertical scrollbars.
onMouseDownBarWrapper_ browserEvents.Data Handler for mouse down events on the background of the scrollbar.
onMouseDownHandleWrapper_ browserEvents.Data Handler for mouse down events on the handle of the scrollbar.
onMouseMoveWrapper_ browserEvents.Data | null Handler for mouse up events to end scrollbar drags.
onMouseUpWrapper_ browserEvents.Data | null Handler for mouse move events during scrollbar drags.
positionAttribute_ string The DOM attribute that controls the position of the scrollbar. Different for horizontal and vertical scrollbars.
scrollbarThickness static number Width of vertical scrollbar or height of horizontal scrollbar in CSS pixels. Scrollbars should be larger on touch devices.

Methods

Method Modifiers Description
dispose() Dispose of this scrollbar. Remove DOM elements, event listeners, and theme subscriptions.
isVisible() Is the scrollbar visible. Non-paired scrollbars disappear when they aren't needed.
resize(opt_metrics) Recalculate the scrollbar's location and its length.
resizeContentHorizontal(hostMetrics) Recalculate a horizontal scrollbar's location within its path and length. This should be called when the contents of the workspace have changed.
resizeContentVertical(hostMetrics) Recalculate a vertical scrollbar's location within its path and length. This should be called when the contents of the workspace have changed.
resizeViewHorizontal(hostMetrics) 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.
resizeViewVertical(hostMetrics) 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.
set(value, updateMetrics) Set the scrollbar handle's position.
setContainerVisible(visible) Set whether the scrollbar's container is visible and update display accordingly if visibility has changed.
setHandlePosition(newPosition) Set the offset of the scrollbar's handle from the scrollbar's position, and change the SVG attribute accordingly.
setOrigin(x, y) 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.)
setVisible(visible) 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.