ResizeHelper

Handles resizing of elements using handles. Handles can be actual elements or virtual handles specified as a border area on elements left and right edges.

// enable resizing all elements with class 'resizable'
let resizer = new ResizeHelper({
  targetSelector: '.resizable'
});

Configs

27

Common

listenersEvents

Other

allowResize: function

Assign a function to determine if a hovered element can be resized or not. Return true to allow resizing or false to prevent.

ParameterTypeDescription
elementHTMLElement
Returns: Boolean
bottomHandle: Boolean= true

Use bottom handle when resizing. Only applies when direction is 'vertical'

direction: horizontal | vertical= horizontal

Direction to resize in, either 'horizontal' or 'vertical'

dragThreshold: Number= 5

The amount of pixels to move mouse before it counts as a drag operation

dragWithin: HTMLElement

Outer element that limits where element can be dragged

dynamicHandleSize: Boolean= false

Automatically shrink virtual handles when available space < handleSize. The virtual handles will decrease towards width/height 1, reserving space between opposite handles to for example leave room for dragging. To configure reserved space, see reservedSpace.

A CSS selector used to determine which inner element contains handles.

A CSS selector used to determine where handles should be "displayed" when resizing. Defaults to targetSelector if unspecified

handleSize: Number= 10

Resizing handle size

invalidCls: String= b-resize-invalid

CSS class added when the resize state is invalid

A function that determines if dragging an element is allowed. Gets called with the element as argument, return true to allow dragging or false to prevent.

ParameterTypeDescription
elementHTMLElement
Returns: Boolean
leftHandle: Boolean= true

Use left handle when resizing. Only applies when direction is 'horizontal'

maxHeight: Number= 0

Max height when resizing

maxWidth: Number= 0

Max width when resizing.

minHeight: Number= 1

Minimum height when resizing

minWidth: Number= 1

Minimum width when resizing

reservedSpace: Number= 10

Room in px to leave unoccupied by handles when shrinking them dynamically (see dynamicHandleSize).

resizingCls: String= b-resizing

CSS class added when resizing

rightHandle: Boolean= true

Use right handle when resizing. Only applies when direction is 'horizontal'

Optional scroller used to read scroll position. If unspecified, the outer element will be used.

A CSS selector used to determine if resizing an element is allowed.

topHandle: Boolean= true

Use top handle when resizing. Only applies when direction is 'vertical'

touchHandleSize: Number= 30

Resizing handle size on touch devices

Misc

Properties

3

Class hierarchy

isEventsEvents

Misc

Other

Functions

11

Abort dragging

onEvents
relayAllEvents
triggerEvents
unEvents

Events

7

Fires when a resize is canceled (width & height are reverted)

// Adding a listener using the "on" method
resizeHelper.on('cancel', ({ source, context, event }) => {

});
ParameterTypeDescription
sourceResizeHelper
contextResizeContext

Resize context

eventMouseEvent | TouchEvent

Browser event

Fires after resize, and allows for asynchronous finalization by setting 'async' to true on the context object.

// Adding a listener using the "on" method
resizeHelper.on('resize', ({ source, context }) => {

});
ParameterTypeDescription
sourceResizeHelper
contextResizeContext

Context about the resize operation. Set 'async' to true to indicate asynchronous validation of the resize flow (for showing a confirmation dialog etc)

Fired when dragging starts.

// Adding a listener using the "on" method
resizeHelper.on('resizeStart', ({ source, context, event }) => {

});
ParameterTypeDescription
sourceResizeHelper
contextResizeContext

Resize context

eventMouseEvent | TouchEvent

Browser event

Fired while dragging

// Adding a listener using the "on" method
resizeHelper.on('resizing', ({ source, context, event }) => {

});
ParameterTypeDescription
sourceResizeHelper
contextResizeContext

Resize context

eventMouseEvent

Browser event

catchAllEvents
destroyEvents

Event handlers

7

Called when a resize is canceled (width & height are reverted)

new ResizeHelper({
    onCancel({ source, context, event }) {

    }
});
ParameterTypeDescription
sourceResizeHelper
contextResizeContext

Resize context

eventMouseEvent | TouchEvent

Browser event

Called after resize, and allows for asynchronous finalization by setting 'async' to true on the context object.

new ResizeHelper({
    onResize({ source, context }) {

    }
});
ParameterTypeDescription
sourceResizeHelper
contextResizeContext

Context about the resize operation. Set 'async' to true to indicate asynchronous validation of the resize flow (for showing a confirmation dialog etc)

Called when dragging starts.

new ResizeHelper({
    onResizeStart({ source, context, event }) {

    }
});
ParameterTypeDescription
sourceResizeHelper
contextResizeContext

Resize context

eventMouseEvent | TouchEvent

Browser event

Called while dragging

new ResizeHelper({
    onResizing({ source, context, event }) {

    }
});
ParameterTypeDescription
sourceResizeHelper
contextResizeContext

Resize context

eventMouseEvent

Browser event

onDestroyEvents

Typedefs

2

Contextual information available during a resize.

ParameterTypeDescription
elementHTMLElement

Element being resized

edgetop | right | bottom | left

Edge being dragged

validBoolean

true if the resize is valid, false if it is not

asyncBoolean

Set to true in a resize listener to allow asynchronous finalization of the resize

finalizefunction

Call this function to finalize the resize, required if it was flagged as async in a resize listener

newWidthNumber

New width of the element

newHeightNumber

New height of the element

newXNumber

New x coordinate of the element, when dragging left edge

newYNumber

New y coordinate of the element, when dragging top edge