evtrack icon indicating copy to clipboard operation
evtrack copied to clipboard

Nested scroll events not captured

Open bpfrd opened this issue 1 year ago • 0 comments

Hello,

i’m trying to collect mouse tracking data on our html but i noticed that there are a couple of indiscrepencies in the collected data for the nested elements: Firstly, the positions are not correct if there is any scroll in any nested elements, so i modified the function getMousePos slightly to

function getMousePos(event) {
            let docX = event.clientX || 0;
            let docY = event.clientY || 0;
            let element = event.target;
            while (element) {
                docX += element.scrollLeft || 0;
                docY += element.scrollTop || 0;
                element = element.parentElement;
            }
            return { x: docX, y: docY };
        }

secondly, the scrolls in nested elements are not captured. I could fix this by changing the bubbling phase to capturing phase in the tracklib file. However, I don’t know why that works. i was wondering if these two modification are fine and would not affect other things?

Best,

bpfrd avatar Oct 29 '24 17:10 bpfrd