jQuery.Gantt icon indicating copy to clipboard operation
jQuery.Gantt copied to clipboard

Proper click event processing when scrolled down

Open Bohdan-Tereta opened this issue 12 years ago • 8 comments

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.

Bohdan-Tereta avatar Apr 23 '14 07:04 Bohdan-Tereta

Good catch, this will be investigated.

@Bohdan-Tereta, to help debugging, can you say what browser are you using? Also, in the page where you're using the plugin, what is the value of document.compatMode? If you could also provide a jsbin or jsfiddle of a simple instance of the bug, that would be very helpful. Thanks!

usmonster avatar Apr 23 '14 11:04 usmonster

Firefox 28.0 and Firefox 22.0 are my target browsers now, document.compatMode='CSS1Compat' (Strict mode). I reproduced that on Chrome 34 too, in the same document.compatMode. I will send jsfiddle instance of bug as soon as I create it.

Bohdan-Tereta avatar Apr 24 '14 15:04 Bohdan-Tereta

http://jsfiddle.net/Bohdan_Tereta/bXN3C/23/ Step 1. Just click anywhere on datapanel except for pink labels. Expected result: Alert appears. Actual result: Alert doesn't appear. Step 2. Scroll to the top of the page so the header is shown. Expected result: Alert appears. Actual result: Alert appears.

Bohdan-Tereta avatar Apr 24 '14 15:04 Bohdan-Tereta

Why is it still labeled "needs input"? Isn't provided input enough? Should I provide some more input?..

Bohdan-Tereta avatar May 19 '14 13:05 Bohdan-Tereta

Hi @Bohdan-Tereta, thanks again for your input. The bug is confirmed, I've removed the label.

usmonster avatar May 19 '14 13:05 usmonster

Is there any workaround for this?

kelmer44 avatar Jun 09 '15 07:06 kelmer44

@Bohdan-Tereta's fix detailed above has worked for me.

slovely avatar Jun 09 '15 07:06 slovely

Unfortunately it does not work on me :(

kelmer44 avatar Jun 09 '15 11:06 kelmer44