idle-js icon indicating copy to clipboard operation
idle-js copied to clipboard

Handle scroll events for the whole document

Open joeheyming opened this issue 5 years ago • 1 comments

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.

joeheyming avatar Jul 16 '20 16:07 joeheyming

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.

gabrielstuff avatar Jan 06 '22 01:01 gabrielstuff