frappe/gantt

set_scroll_position not moving Gannt Chart in scrollable area when manually set.

Closed this issue · 1 comments

Hello there,

We directly forked this library into our Angular application as we where having web-pack issues.

When rendering the Gantt chart there is a method to set the scroll position of the parent container's scrollbar. It makes sense in the weekly view to not perform a scroll to the start of the current month because the scroll_pos variable calculation comes back as 0. However, if I manually attempt to set that variable to scroll left by 100-5000 it doesn't move the scroll container.

I know you probably don't support direct forks but I was curious if this was working as intended.

set_scroll_position(date) {
        if (!date || date === 'start') {
            date = this.gantt_start;
        } else if (date === 'today') {
            return this.scroll_today();
        } else if (typeof date === 'string') {
            date = date_utils.parse(date);
        }

        const parent_element = this.$svg.parentElement;
        if (!parent_element) return;

        const hours_before_first_task =
            date_utils.diff(date, this.gantt_start, 'hour') + 24;

        const scroll_pos =
            (hours_before_first_task / this.options.step) *
                this.options.column_width -
            this.options.column_width;
        parent_element.scrollTo({ left: scroll_pos, behavior: 'smooth' });
    }

I was able to get ahold of our UI developer that set this up. We were able to determine that our scroll container wasn't be correctly targeted it was actually the grandparent that was the scroll container. I am not sure if that was because we are importing this an Angular component and use hostElement but I changed it in our code. I am now able to customize the scroll for our weekly view.

I will close this out.