Blockly. ScrollbarPair
Class for a pair of scrollbars. Horizontal and vertical.
Constructor
ScrollbarPair
new ScrollbarPair(workspace, addHorizontal, addVertical, opt_class, opt_margin)
Parameter |
|
---|---|
workspace |
Workspace to bind the scrollbars to. Value must not be null. |
addHorizontal |
Optional Whether to add a horizontal scrollbar. Defaults to true. |
addVertical |
Optional Whether to add a vertical scrollbar. Defaults to true. |
opt_class |
Optional A class to be applied to these scrollbars. |
opt_margin |
Optional The margin to apply to these scrollbars. |
Methods
canScrollHorizontally
canScrollHorizontally() returns boolean
Returns whether scrolling horizontally is enabled.
- Returns
-
boolean
True if horizontal scroll is enabled.
canScrollVertically
canScrollVertically() returns boolean
Returns whether scrolling vertically is enabled.
- Returns
-
boolean
True if vertical scroll is enabled.
dispose
dispose()
Dispose of this pair of scrollbars. Unlink from all DOM elements to prevent memory leaks.
isVisible
isVisible() returns boolean
If any of the scrollbars are visible. Non-paired scrollbars may disappear when they aren't needed.
- Returns
-
boolean
True if visible.
resize
resize()
Recalculate both of the scrollbars' locations and lengths. Also reposition the corner rectangle.
resizeContent
resizeContent(hostMetrics)
Recalculates the scrollbars' locations within their path and length. This should be called when the contents of the workspace have changed.
Parameter |
|
---|---|
hostMetrics |
A data structure describing all the required dimensions, possibly fetched from the host object. Value must not be null. |
resizeView
resizeView(hostMetrics)
Recalculates the scrollbars' locations on the screen and path length. This should be called when the layout or size of the window has changed.
Parameter |
|
---|---|
hostMetrics |
A data structure describing all the required dimensions, possibly fetched from the host object. Value must not be null. |
set
set(x, y, updateMetrics)
Set the handles of both scrollbars.
Parameter |
|
---|---|
x |
number The horizontal content displacement, relative to the view in pixels. |
y |
number The vertical content displacement, relative to the view in pixels. |
updateMetrics |
boolean Whether to update metrics on this set call. Defaults to true. |
setContainerVisible
setContainerVisible(visible)
Set whether this scrollbar's container is visible.
Parameter |
|
---|---|
visible |
boolean Whether the container is visible. |
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. |
setX
setX(x)
Set the handle of the horizontal scrollbar to be at a certain position in CSS pixels relative to its parents.
Parameter |
|
---|---|
x |
number Horizontal scroll value. |
setY
setY(y)
Set the handle of the vertical scrollbar to be at a certain position in CSS pixels relative to its parents.
Parameter |
|
---|---|
y |
number Vertical scroll value. |