Home Reference Source
public class | source

Scrollable

Extends:

* → Scrollable

Scrollable plugin which scrolls the closest scrollable parent

Constructor Summary

Public Constructor
public

constructor(draggable: Draggable)

Scrollable constructor.

Member Summary

Public Members
public

Keeps current mouse position

public

Animation frame looking for the closest scrollable element

public

Scrollable options

public

Scroll animation frame

public

scrollableElement: HTMLElement | null

Closest scrollable element

Method Summary

Public Methods
public

attach()

Attaches plugins event listeners

public

detach()

Detaches plugins event listeners

public

Returns options passed through draggable

public

getScrollableElement(target: HTMLElement): HTMLElement

Returns closest scrollable elements by element

public

hasDefinedScrollableElements(target: HTMLElement): Boolean

Returns true if at least one scrollable element have been defined via options

Private Methods
private

Drag move handler.

private

Drag start handler.

private

Drag stop handler.

private

Scroll function that does the heavylifting

Public Constructors

public constructor(draggable: Draggable) source

Scrollable constructor.

Params:

NameTypeAttributeDescription
draggable Draggable

Draggable instance

Public Members

public currentMousePosition: Object | null source

Keeps current mouse position

Properties:

NameTypeAttributeDescription
currentMousePosition Object
currentMousePosition.clientX Number
currentMousePosition.clientY Number

public findScrollableElementFrame: Number | null source

Animation frame looking for the closest scrollable element

Properties:

NameTypeAttributeDescription
findScrollableElementFrame *

public options: Object source

Scrollable options

Properties:

NameTypeAttributeDescription
options Object
options.speed Number
options.sensitivity Number
options.scrollableElements HTMLElement[]

public scrollAnimationFrame: Number | null source

Scroll animation frame

Properties:

NameTypeAttributeDescription
scrollAnimationFrame *

public scrollableElement: HTMLElement | null source

Closest scrollable element

Properties:

NameTypeAttributeDescription
scrollableElement *

Public Methods

public attach() source

Attaches plugins event listeners

public detach() source

Detaches plugins event listeners

public getOptions(): Object source

Returns options passed through draggable

Return:

Object

public getScrollableElement(target: HTMLElement): HTMLElement source

Returns closest scrollable elements by element

Params:

NameTypeAttributeDescription
target HTMLElement

Return:

HTMLElement

public hasDefinedScrollableElements(target: HTMLElement): Boolean source

Returns true if at least one scrollable element have been defined via options

Params:

NameTypeAttributeDescription
target HTMLElement

Return:

Boolean

Private Methods

private [onDragMove](dragEvent: DragMoveEvent) source

Drag move handler. Remembers mouse position and initiates scrolling

Params:

NameTypeAttributeDescription
dragEvent DragMoveEvent

private [onDragStart](dragEvent: DragStartEvent) source

Drag start handler. Finds closest scrollable parent in separate frame

Params:

NameTypeAttributeDescription
dragEvent DragStartEvent

private [onDragStop]() source

Drag stop handler. Cancels scroll animations and resets state

private [scroll]() source

Scroll function that does the heavylifting