Constructor

Scrollbar

new Scrollbar(workspace, horizontal, opt_pair, opt_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.

Parameter

workspace

Blockly.Workspace

Workspace to bind the scrollbar to.

Value must not be null.

horizontal

boolean

True if horizontal, false if vertical.

opt_pair

Optional

boolean

True if scrollbar is part of a horiz/vert pair.

opt_class

Optional

string

A class to be applied to this scrollbar.

Properties

scrollbarThickness

static

Width of vertical scrollbar or height of horizontal scrollbar in CSS pixels. Scrollbars should be larger on touch devices.

startDragMouse_

goog.math.Coordinate

The position of the mouse along this scrollbar's major axis at the start of the most recent drag. Units are CSS pixels, with (0, 0) at the top left of the browser window. For a horizontal scrollbar this is the x coordinate of the mouse down event; for a vertical scrollbar it's the y coordinate of the mouse down event.

Methods

dispose

dispose()

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

isVisible

isVisible() returns boolean

Is the scrollbar visible. Non-paired scrollbars disappear when they aren't needed.

Returns

boolean True if visible.

resize

resize(opt_metrics)

Recalculate the scrollbar's location and its length.

Parameter

opt_metrics

Optional

Object

A data structure of from the describing all the required dimensions. If not provided, it will be fetched from the host object.

resizeContentHorizontal

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.

Parameter

hostMetrics

Object

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

Value must not be null.

resizeContentVertical

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.

Parameter

hostMetrics

Object

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

Value must not be null.

resizeViewHorizontal

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.

Parameter

hostMetrics

Object

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

Value must not be null.

resizeViewVertical

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.

Parameter

hostMetrics

Object

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

Value must not be null.

set

set(value)

Set the scrollbar handle's position.

Parameter

value

number

The distance from the top/left end of the bar, in CSS pixels. It may be larger than the maximum allowable position of the scrollbar handle.

setContainerVisible

setContainerVisible(visible)

Set whether the scrollbar's container is visible and update display accordingly if visibility has changed.

Parameter

visible

boolean

Whether the container is visible

setHandleLength_

setHandleLength_(newLength)

Set the length of the scrollbar's handle and change the SVG attribute accordingly.

Parameter

newLength

number

The new scrollbar handle length in CSS pixels.

setHandlePosition

setHandlePosition(newPosition)

Set the offset of the scrollbar's handle from the scrollbar's position, and change the SVG attribute accordingly.

Parameter

newPosition

number

The new scrollbar handle offset in CSS pixels.

setOrigin

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.)

Parameter

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.

setVisible

setVisible(visible)

Set whether the scrollbar is visible. Only applies to non-paired scrollbars.

Parameter

visible

boolean

True if visible.

updateDisplay_

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.