Skip to content

✨ [bento][amp-sidebar] Prevent scrolling in background of sidebar#32400

Merged
krdwan merged 4 commits intoampproject:masterfrom
krdwan:sidebar-overscroll
Feb 17, 2021
Merged

✨ [bento][amp-sidebar] Prevent scrolling in background of sidebar#32400
krdwan merged 4 commits intoampproject:masterfrom
krdwan:sidebar-overscroll

Conversation

@krdwan
Copy link
Copy Markdown
Contributor

@krdwan krdwan commented Feb 3, 2021

Sidebar tracker: #31366

Important Note: This PR represents a workaround to ensure overscroll-behavior works properly. The workaround includes adding a large element as the child of the backdrop to force the scroll behavior on backdrop. A bug has been filed with the chrome team here: https://bugs.chromium.org/p/chromium/issues/detail?id=1176733

Once the bug has been fixed in ALL MAJOR BROWSERS, the following fix should be implemented:

  1. Set overscroll-behavior to none and overflow to scroll on both backdrop and sidebar elements. Expected behavior is that the background does not scroll when scrolling on the sidebar or backdrop elements.
  2. See if the bug fix has other requirements and implement as needed!

When inside of the sidebar or the backdrop of the sidebar, scrolling up and down should not cause the underlying content (behind the sidebar and backdrop to scroll up and down).

Covers the following use cases:

  1. Scrolling on sidebar when sidebar scrolls
  2. Scrolling on sidebar when sidebar does not have enough content to scroll
  3. Scrolling on the backdrop

How it works:

  1. Create a larger invisible element that is the child of the backdrop. This forces the backdrop to have scroll behavior. Backdrop gets overscroll-behavior: none so that any scrolls on the child element do no propagate out of the backdrop. overscroll-behavior: none only works when the element actually has scroll behavior.
  2. Scroll chaining appears to follow z-index. i.e. since the Sidebar is on top of the backdrop, the Sidebar's scroll chaining goes to the backdrop. Since backdrop scroll chaining is disabled, we can handle the sidebar case through the backdrop.
  3. Sidebar element maintains overflow: auto so scroll bar will show up only when there is enough content to scroll.

@krdwan krdwan requested review from caroqliu and dvoytenko February 3, 2021 20:52
@krdwan krdwan marked this pull request as ready for review February 3, 2021 20:52
@krdwan krdwan force-pushed the sidebar-overscroll branch from 0af0d92 to 668033d Compare February 12, 2021 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants