Skip to content

Description

Plugin used to scroll Handsontable by selecting a cell and dragging outside of the visible viewport.

Options

dragToScroll

Source code

dragToScroll.dragToScroll : boolean | object

The dragToScroll option configures the DragToScroll plugin.

You can set the dragToScroll option to one of the following:

SettingDescription
true (default)Enable with default auto-scroll settings
falseDisable the plugin entirely
ObjectEnable with custom auto-scroll settings (see below)

When passing an object, the following properties control the auto-scroll speed:

dragToScroll: {
interval: {
min: 20, // Fastest scroll interval in ms (reached at rampDistance)
max: 500, // Slowest scroll interval in ms (applied at the viewport edge)
},
rampDistance: 120, // Pixels outside the edge over which speed ramps up
},

The viewport scrolls periodically while the mouse pointer stays outside the viewport edge. Speed follows a logarithmic curve: slow at the edge, fast when far outside. The active selection (regular drag-select or autofill drag) extends to follow the scroll.

Read more:

Default: true
Example

// Enable with default settings
dragToScroll: true,
// Enable with custom scroll speed
dragToScroll: {
interval: { min: 60, max: 300 },
rampDistance: 60,
},
// Disable
dragToScroll: false,

Members

boundaries

Source code

dragToScroll.boundaries : DOMRect

Size of an element and its position relative to the viewport, e.g. {bottom: 449, height: 441, left: 8, right: 814, top: 8, width: 806, x: 8, y:8}.

Methods

check

Source code

dragToScroll.check(x, y)

Checks if the mouse position (X, Y) is outside the viewport and fires a callback with calculated X an Y diffs between passed boundaries.

ParamTypeDescription
xnumberMouse X coordinate to check.
ynumberMouse Y coordinate to check.

destroy

Source code

dragToScroll.destroy()

Destroys the plugin instance.

disablePlugin

Source code

dragToScroll.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin

Source code

dragToScroll.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

isEnabled

Source code

dragToScroll.isEnabled() ⇒ boolean

Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit hook and if it returns true then the DragToScroll#enablePlugin method is called.

setBoundaries

Source code

dragToScroll.setBoundaries([boundaries])

Sets the boundaries/dimensions of the scrollable viewport.

ParamTypeDescription
[boundaries]DOMRect
Object
optional An object with coordinates. Contains the window boundaries by default. The object is compatible with DOMRect.

setCallback

Source code

dragToScroll.setCallback(callback)

Changes callback function.

ParamTypeDescription
callbackfunctionThe callback function.

updatePlugin

Source code

dragToScroll.updatePlugin()

Updates the plugin’s state.

This method is executed when updateSettings() is invoked with any of the following configuration options: