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

Handle scroll events for the whole document #26

Open
joeheyming opened this issue Jul 16, 2020 · 1 comment
Open

Handle scroll events for the whole document #26

joeheyming opened this issue Jul 16, 2020 · 1 comment

Comments

@joeheyming
Copy link

When I pass 'scroll' to the events list, it does not work.

I read in this stackoverflow: https://stackoverflow.com/a/30723677/1222743
You have to pass true to the addEventListener.

According to the answer there:
"it tells the browser to capture the event on dispatch, even if that event does not normally bubble, like change, focus, and scroll."

A workaround I've found is to do this:

document.addEventListener('scroll', idle.idlenessEventsHandler, true);

But it would be nice for the library to support it.

@gabrielstuff
Copy link
Member

hello,
I like this idea.
I've noticed that we could simply modify the bulkAddEventListener function and default to useCapture = true.

But as this might break some behavior and usage with library like idle-vue, I'd like to post pone this change.

I propose that the events array could accept Strings or Object int the form of 👍

{eventName: `scroll`, `useCapture`: true}

This way, we can still support the previous behavior and have some sugar to handle more cases.

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

2 participants