EventResize

Feature that allows resizing an event by dragging its end.

By default, it displays a tooltip with the new start and end dates, formatted using displayDateFormat.

Event resize
//<code-header>
fiddle.title = 'Event resize';
//</code-header>
targetElement.innerHTML = '<p>Grab either end of an event and drag to resize it:</p>';
const scheduler         = new Scheduler({
    appendTo : targetElement,

    // makes scheduler as high as it needs to be to fit rows
    autoHeight : true,

    startDate : new Date(2018, 4, 6),
    endDate   : new Date(2018, 4, 13),

    columns : [
        { field : 'name', text : 'Name', width : 100 }
    ],

    resources : [
        { id : 1, name : 'Bernard' },
        { id : 2, name : 'Bianca' }
    ],

    events : [
        { id : 1, resourceId : 1, name : 'Resize me', startDate : '2018-05-07', endDate : '2018-05-10' },
        { id : 2, resourceId : 2, name : 'Not me', startDate : '2018-05-08', endDate : '2018-05-10', resizable : false, eventColor : 'red' }
    ]
});

Customizing the resize tooltip

To show custom HTML in the tooltip, please see the tooltipTemplate config. Example:

eventResize : {
    // A minimal end date tooltip
    tooltipTemplate : ({ record, endDate }) => {
        return DateHelper.format(endDate, 'MMM D');
    }
}

This feature is enabled by default

This feature is extended with a few overrides by the Gantt's TaskResize feature.

This feature updates the event's startDate or endDate live in order to leverage the rendering pathway to always yield a correct appearance. The changes are done in batched mode so that changes do not become eligible for data synchronization or propagation until the operation is completed.

Configs

26

Common

disabledInstancePlugin
listenersEvents

Other

allowResizeToZero: Boolean= false

Set to true to allow resizing to a zero-duration span

bottomHandle: Boolean= true

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

dragThreshold: Number= 0

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

dragTouchStartDelay: Number= 300

The amount of time (ms) to delay a touch-resize interaction.

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.

leftHandle: Boolean= true

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

lockLayout: Boolean | minimal-updates

Locks the layout during drag resize, opt out to use the same rendering pathway for drag resize as for already existing events (updating the layout of all events during the resize operation).

Keeping this config enabled also leads to cheaper resizing, only the resized event's resources are refreshed during the operation.

For even cheaper resizing, configure it as 'minimal-updates'. In this mode, only the resized event is refreshed during the operation (not the other events assigned to the same resource).

reservedSpace: Number= 1

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

resizeSelected: Boolean= true

Set to false to not resize all selected events simultaneously.

Please note that multiEventSelect needs to be enabled for it to work

rightHandle: Boolean= true

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

showExactResizePosition: Boolean= false

true to see exact event length during resizing

showTooltip: Boolean= true

false to not show a tooltip while resizing

If a tooltip is required to illustrate the resize, specify this as true, or a config object for the Tooltip.

tooltipTemplate: function

A template function returning the content to show during a resize operation.

ParameterTypeDescription
contextObject

A context object

context.startDateDate

New start date

context.endDateDate

New end date

context.recordTimeSpan

The record being resized

context.validBoolean

Whether the current resize position is valid

context.startClockHtmlString

Predefined HTML to show the start time

context.endClockHtmlString

Predefined HTML to show the end time

Returns: String -

String representing the HTML markup

topHandle: Boolean= true

Use top handle when resizing. Only applies when owning client's direction` is 'vertical'

validatorFn: function

An empty function by default, but provided so that you can perform custom validation on the item being resized. Return true if the new duration is valid, false to signal that it is not.

ParameterTypeDescription
contextObject

The resize context, contains the record & dates.

context.recordTimeSpan

The record being resized.

context.startDateDate

The new start date.

context.endDateDate

The new end date.

context.originalStartDateDate

Start date before resize

context.originalEndDateDate

End date before resize

eventEvent

The browser Event object

Returns: Boolean

this reference for the validatorFn

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Properties

17

Common

disabledInstancePlugin

Class hierarchy

isEventResize: Boolean= truereadonly
Identifies an object as an instance of EventResize class, or subclass thereof.
isEventResize: Boolean= truereadonlystatic
Identifies an object as an instance of EventResize class, or subclass thereof.
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable

Other

isResizing: Booleanreadonly

Returns true if a resize operation is active

Setting this property may change the configuration of the tip, or cause it to be destroyed if null is passed.

Reading this property returns the Tooltip instance.

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Functions

28

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Events

10

Fired on the owning Scheduler before resizing starts. Return false to prevent the action.

// Adding a listener using the "on" method
eventResize.on('beforeEventResize', ({ source, eventRecord, resourceRecord, event }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordEventModel

Event record being resized

resourceRecordResourceModel

Resource record the resize starts within

eventMouseEvent

Browser event

Fired on the owning Scheduler to allow implementer to prevent immediate finalization by returning a promise in the listener, to show a confirmation popup etc

 scheduler.on('beforeeventresizefinalize', event => {
     event.async = true;
     setTimeout(() => {
         // async code don't forget to call finalize
         event.finalize();
     }, 1000);
 })
// Adding a listener using the "on" method
eventResize.on('beforeEventResizeFinalize', ({ source, context, eventRecord, startDate, endDate, originalStartDate, originalEndDate, async, finalize, event, resizeData }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

contextObject

[DEPRECATED] de-nested to outer params object

eventRecordEventModel

Event record being resized

startDateDate

New startDate (changed if resizing start side)

endDateDate

New endDate (changed if resizing end side)

originalStartDateDate

Start date before resize

originalEndDateDate

End date before resize

asyncBoolean

Set true to handle resize asynchronously (e.g. to wait for user confirmation)

finalizefunction

Call this method to finalize resize. This method accepts one argument: pass true to update records, or false, to ignore changes

eventEvent

Browser event

resizeDataEventResizeData[]

Data of all events that are being resized

Fires on the owning Scheduler on each resize move event

// Adding a listener using the "on" method
eventResize.on('eventPartialResize', ({ source, eventRecord, startDate, endDate, element, resizeData }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordEventModel

Event record being resized

startDateDate
endDateDate
elementHTMLElement
resizeDataEventResizeData[]

Resize data for selected events

Fires on the owning Scheduler after the resizing gesture has finished.

// Adding a listener using the "on" method
eventResize.on('eventResizeEnd', ({ source, changed, eventRecord, resizeData }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

changedBoolean

Shows if the record has been changed by the resize action

eventRecordEventModel

Event record being resized

resizeDataEventResizeData[]

Resize data for selected events

Fires on the owning Scheduler when event resizing starts

// Adding a listener using the "on" method
eventResize.on('eventResizeStart', ({ source, eventRecord, resourceRecord, event, resizeData }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordEventModel

Event record being resized

resourceRecordResourceModel

Resource record the resize starts within

eventMouseEvent

Browser event

resizeDataEventResizeData[]

Resize data for selected events. Only available when resizeSelected is true

catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

10

Called on the owning Scheduler before resizing starts. Return false to prevent the action.

new EventResize({
    onBeforeEventResize({ source, eventRecord, resourceRecord, event }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordEventModel

Event record being resized

resourceRecordResourceModel

Resource record the resize starts within

eventMouseEvent

Browser event

Called on the owning Scheduler to allow implementer to prevent immediate finalization by returning a promise in the listener, to show a confirmation popup etc

 scheduler.on('beforeeventresizefinalize', event => {
     event.async = true;
     setTimeout(() => {
         // async code don't forget to call finalize
         event.finalize();
     }, 1000);
 })
new EventResize({
    onBeforeEventResizeFinalize({ source, context, eventRecord, startDate, endDate, originalStartDate, originalEndDate, async, finalize, event, resizeData }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

contextObject

[DEPRECATED] de-nested to outer params object

eventRecordEventModel

Event record being resized

startDateDate

New startDate (changed if resizing start side)

endDateDate

New endDate (changed if resizing end side)

originalStartDateDate

Start date before resize

originalEndDateDate

End date before resize

asyncBoolean

Set true to handle resize asynchronously (e.g. to wait for user confirmation)

finalizefunction

Call this method to finalize resize. This method accepts one argument: pass true to update records, or false, to ignore changes

eventEvent

Browser event

resizeDataEventResizeData[]

Data of all events that are being resized

Called on the owning Scheduler on each resize move event

new EventResize({
    onEventPartialResize({ source, eventRecord, startDate, endDate, element, resizeData }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordEventModel

Event record being resized

startDateDate
endDateDate
elementHTMLElement
resizeDataEventResizeData[]

Resize data for selected events

Called on the owning Scheduler after the resizing gesture has finished.

new EventResize({
    onEventResizeEnd({ source, changed, eventRecord, resizeData }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

changedBoolean

Shows if the record has been changed by the resize action

eventRecordEventModel

Event record being resized

resizeDataEventResizeData[]

Resize data for selected events

Called on the owning Scheduler when event resizing starts

new EventResize({
    onEventResizeStart({ source, eventRecord, resourceRecord, event, resizeData }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordEventModel

Event record being resized

resourceRecordResourceModel

Resource record the resize starts within

eventMouseEvent

Browser event

resizeDataEventResizeData[]

Resize data for selected events. Only available when resizeSelected is true

onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

2

An object containing data related to event resize.

ParameterTypeDescription
eventRecordEventModel

Event record being resized

startDateDate

New startDate (changed if resizing start side)

endDateDate

New endDate (changed if resizing end side)

originalStartDateDate

Start date before resize

originalEndDateDate

End date before resize

elementHTMLElement

The event element

CSS variables

10
NameDescription
--b-event-resize-handle-other-sizeResize handle width in horizontal mode, height in vertical mode. Must use px values
--b-event-resize-handle-border-radiusResize handle border-radius
--b-event-resize-handle-insetResize handle inset from event edge. Must use px values
--b-event-resize-handle-sizeResize handle height in horizontal mode, width in vertical mode
--b-event-resize-handle-max-sizeResize handle max height in horizontal mode, max width in vertical mode
--b-event-resize-handle-zindexResize handle z-index
--b-event-resize-handle-backgroundResize handle background color
Hovered
--b-event-resize-handle-hover-other-sizeResize handle size when hovered. Width in horizontal mode, height in vertical mode. Must use px values
--b-event-resize-handle-hover-sizeResize handle height in horizontal mode, width in vertical mode when hovered
--b-event-resize-handle-hover-backgroundResize handle background color when hovered