Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested scroll events not captured #13

Open
bpfrd opened this issue Oct 29, 2024 · 0 comments
Open

Nested scroll events not captured #13

bpfrd opened this issue Oct 29, 2024 · 0 comments

Comments

@bpfrd
Copy link

bpfrd commented Oct 29, 2024

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant