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

debounced:scroll on Scrollable Elements #8

Open
andrewerlanger opened this issue Nov 9, 2021 · 1 comment
Open

debounced:scroll on Scrollable Elements #8

andrewerlanger opened this issue Nov 9, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@andrewerlanger
Copy link

First and foremost, many thanks for the great library – it's a real joy to work with :)

Just thought I'd make a note of one minor hiccup I think I've found when it comes to scrolling on individual elements rather than the document.

Let's say we have an HTML structure along these lines, with elements on the page that are individually scrollable:

<body style="display: flex">
  <nav id="sidebar" style="overflow-y: scroll">
    ...
  </nav>
  <div id="main-pane" style="overflow-y: scroll">
    ...
  </div>
</body>

Here, scrolling on either the sidebar or the main-pane will fire a scroll event on the element in question, but this event will not bubble up to the document as far as I understand.

Because debounced:scroll is ultimately handled via an event listener on the document (this part here), I don’t think it’s currently possible to listen for a debounced scroll on the scrollable elements themselves. This means something like the following will not be fired on scroll:

const sidebar = document.getElementById("sidebar");
sidebar.addEventListener("debounced:scroll", () => console.log("scrolling..."));

If this is the case then I don’t have a neat solution in mind unfortunately – just thought I’d post in here in case someone else might!

@hopsoft
Copy link
Owner

hopsoft commented Mar 18, 2024

This is correct given that scroll events on Element don't bubble, but I'll give this some more consideration for the next release.

@hopsoft hopsoft added the enhancement New feature or request label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants