ANovokmet / svelte-gantt

:calendar: Interactive JavaScript Gantt chart/resource booking component

Home Page:https://anovokmet.github.io/svelte-gantt/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event `gantt.api.timeranges.on.resized` returns previous `from` and `to` values

gubeils opened this issue · comments

Issue Description

I've encountered an issue while using the gantt.api.timeranges.on.resized event where each trigger of the event is returning the from and to values from the previous state, rather than the updated values after the current resizing operation.

Yeah, the same is true for resizing tasks, although that event is not exposed through the gantt.api interface. Updating the from and to is delayed till the dragging ends (although ondrop event is not exposed for the timeRanges... :( ), as there is a bit of calculation involved and I wanted to "commit" the data only after the drag succeeds for one reason or another.

If you need the current times you can use the following code:

gantt.api.timeranges.on.resized(([e]) => {
  const from = new Date(gantt.columnService.getDateByPosition(e.left));  
  const to = new Date(gantt.columnService.getDateByPosition(e.left + e.width));
  // ...
});

But because this event is happening right before a successful resize (because onDrop is not currently exposed) you can not get the final values.

The thing that needs to be done is to consolidate all the events happening in the library, eg. exposing the timerange.ondrop event.

Is timerange.ondrop event available now?