I'm trying to implement an auto-scroll feature in SVAR Gantt. When a user clicks a task, I want the chart to scroll to that task's start date. I'm using the show-editor interceptor for this, but scroll-chart doesn't seem to have any effect, even though the console.log shows the correct date.
Here is my code:
const init = useCallback(
(ganttApi: any) => {
if (!ganttApi) return;
ganttApi.intercept("show-editor", ({ id }: { id: string }) => {
const task = ganttApi.getTask(id);
if (!task || task.type === "summary") {
return false;
}
// Navigate to edit route
navigate(`/bookings/gantt/${id}/edit`, { replace: true });
// Scroll logic
console.log("Scrolling to:", task.start);
ganttApi.exec("scroll-chart", { date: new Date(task.start) });
return false; // Prevent default editor
});
setApi(ganttApi);
},
[navigate]
);
Is there any specific requirement for scroll-chart to work inside an interceptor? Should I be using a different method or perhaps a different event?
Thanks!