Skip to content

Proper click event processing when scrolled down #137

Open
@Bohdan-Tereta

Description

@Bohdan-Tereta

If a page is scrolled down so there are no column headers with "repdate" attribute in the viewport, click event doesn't work. Debugger shows that "col value is null'. Issue may be caused by using of custom implementation of elementFromPoint function. ElementFrom, according to documentation, should return null or element at specified position in viewport. But in case of scrolled page it will return null for any element outside visible part of the page.
Here's the code that fixed the problem for me (commented code replaced with uncommented part). I'd like to see it tested for different configurations and in the end included into library.

                // Find column where click occurred
                //var col = core.elementFromPoint(e.pageX, datapanel.offset().top + corrY);
                //// Was the label clicked directly?
                //if (col.className === "fn-label") {
                //    col = $(col.parentNode);
                //} else {
                //    col = $(col);
                //}

                var col;
                $(document).find("div[class^='row date']").each(function () {
                    var boundingClientRect = this.getBoundingClientRect();
                    if (boundingClientRect.right > e.pageX && boundingClientRect.left < e.pageX
                        && boundingClientRect.bottom + tools.getCellSize() < e.pageY) //optional, prevents click on gantt header
                    {
                        col = $(this);
                    }
                });

P.S. I think something similar should be applied for row variable in order to enable proper click event processing when left panel gets out of viewport.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions