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.
//<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
Configs
26Other
Set to true to allow resizing to a zero-duration span
Use bottom handle when resizing. Only applies when owning client's direction is 'vertical'
The amount of pixels to move pointer/mouse before it counts as a drag operation.
The amount of time (ms) to delay a touch-resize interaction.
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.
Use left handle when resizing. Only applies when owning client's direction is 'horizontal'
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).
Room in px to leave unoccupied by handles when shrinking them dynamically (see dynamicHandleSize).
Set to false to not resize all selected events simultaneously.
Please note that multiEventSelect needs to be enabled for it to work
Use right handle when resizing. Only applies when owning client's direction is 'horizontal'
true to see exact event length during resizing
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.
A template function returning the content to show during a resize operation.
| Parameter | Type | Description |
|---|---|---|
context | Object | A context object |
context.startDate | Date | New start date |
context.endDate | Date | New end date |
context.record | TimeSpan | The record being resized |
context.valid | Boolean | Whether the current resize position is valid |
context.startClockHtml | String | Predefined HTML to show the start time |
context.endClockHtml | String | Predefined HTML to show the end time |
String representing the HTML markup
Use top handle when resizing. Only applies when owning client's direction` is 'vertical'
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.
| Parameter | Type | Description |
|---|---|---|
context | Object | The resize context, contains the record & dates. |
context.record | TimeSpan | The record being resized. |
context.startDate | Date | The new start date. |
context.endDate | Date | The new end date. |
context.originalStartDate | Date | Start date before resize |
context.originalEndDate | Date | End date before resize |
event | Event | The browser Event object |
this reference for the validatorFn
Misc
Properties
17
Properties
17Common
Class hierarchy
Other
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.
Functions
28
Functions
28Configuration
Events
Misc
Other
Events
10
Events
10Fired 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | Scheduler instance |
eventRecord | EventModel | Event record being resized |
resourceRecord | ResourceModel | Resource record the resize starts within |
event | MouseEvent | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | Scheduler instance |
context | Object | [DEPRECATED] de-nested to outer params object |
eventRecord | EventModel | Event record being resized |
startDate | Date | New startDate (changed if resizing start side) |
endDate | Date | New endDate (changed if resizing end side) |
originalStartDate | Date | Start date before resize |
originalEndDate | Date | End date before resize |
async | Boolean | Set true to handle resize asynchronously (e.g. to wait for user confirmation) |
finalize | function | Call this method to finalize resize. This method accepts one argument:
pass |
event | Event | Browser event |
resizeData | EventResizeData[] | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | Scheduler instance |
eventRecord | EventModel | Event record being resized |
startDate | Date | |
endDate | Date | |
element | HTMLElement | |
resizeData | EventResizeData[] | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | Scheduler instance |
changed | Boolean | Shows if the record has been changed by the resize action |
eventRecord | EventModel | Event record being resized |
resizeData | EventResizeData[] | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | Scheduler instance |
eventRecord | EventModel | Event record being resized |
resourceRecord | ResourceModel | Resource record the resize starts within |
event | MouseEvent | Browser event |
resizeData | EventResizeData[] | Resize data for selected events. Only available when resizeSelected is |
Event handlers
10
Event handlers
10Called on the owning Scheduler before resizing starts. Return false to prevent the action.
new EventResize({
onBeforeEventResize({ source, eventRecord, resourceRecord, event }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | Scheduler instance |
eventRecord | EventModel | Event record being resized |
resourceRecord | ResourceModel | Resource record the resize starts within |
event | MouseEvent | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | Scheduler instance |
context | Object | [DEPRECATED] de-nested to outer params object |
eventRecord | EventModel | Event record being resized |
startDate | Date | New startDate (changed if resizing start side) |
endDate | Date | New endDate (changed if resizing end side) |
originalStartDate | Date | Start date before resize |
originalEndDate | Date | End date before resize |
async | Boolean | Set true to handle resize asynchronously (e.g. to wait for user confirmation) |
finalize | function | Call this method to finalize resize. This method accepts one argument:
pass |
event | Event | Browser event |
resizeData | EventResizeData[] | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | Scheduler instance |
eventRecord | EventModel | Event record being resized |
startDate | Date | |
endDate | Date | |
element | HTMLElement | |
resizeData | EventResizeData[] | Resize data for selected events |
Called on the owning Scheduler after the resizing gesture has finished.
new EventResize({
onEventResizeEnd({ source, changed, eventRecord, resizeData }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | Scheduler instance |
changed | Boolean | Shows if the record has been changed by the resize action |
eventRecord | EventModel | Event record being resized |
resizeData | EventResizeData[] | Resize data for selected events |
Called on the owning Scheduler when event resizing starts
new EventResize({
onEventResizeStart({ source, eventRecord, resourceRecord, event, resizeData }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | Scheduler instance |
eventRecord | EventModel | Event record being resized |
resourceRecord | ResourceModel | Resource record the resize starts within |
event | MouseEvent | Browser event |
resizeData | EventResizeData[] | Resize data for selected events. Only available when resizeSelected is |
Typedefs
2
Typedefs
2An object containing data related to event resize.
| Parameter | Type | Description |
|---|---|---|
eventRecord | EventModel | Event record being resized |
startDate | Date | New startDate (changed if resizing start side) |
endDate | Date | New endDate (changed if resizing end side) |
originalStartDate | Date | Start date before resize |
originalEndDate | Date | End date before resize |
element | HTMLElement | The event element |
CSS variables
10
CSS variables
10| Name | Description |
|---|---|
--b-event-resize-handle-other-size | Resize handle width in horizontal mode, height in vertical mode. Must use px values |
--b-event-resize-handle-border-radius | Resize handle border-radius |
--b-event-resize-handle-inset | Resize handle inset from event edge. Must use px values |
--b-event-resize-handle-size | Resize handle height in horizontal mode, width in vertical mode |
--b-event-resize-handle-max-size | Resize handle max height in horizontal mode, max width in vertical mode |
--b-event-resize-handle-zindex | Resize handle z-index |
--b-event-resize-handle-background | Resize handle background color |
| Hovered | |
--b-event-resize-handle-hover-other-size | Resize handle size when hovered. Width in horizontal mode, height in vertical mode. Must use px values |
--b-event-resize-handle-hover-size | Resize handle height in horizontal mode, width in vertical mode when hovered |
--b-event-resize-handle-hover-background | Resize handle background color when hovered |