9.8 · Layout
Stop scroll chaining: overscroll-behavior
Keep scrolling inside a list or modal instead of scrolling the page behind it.
When you reach the end of a scrollable list and keep scrolling, the browser hands the scroll to the page behind it. In modals, chat panels and sidebars, the page suddenly moves.
overscroll-behavior: contain stops that hand-off. It also
turns off pull-to-refresh and bounce effects on that element.
none stops the bounce too.
list.addEventListener('wheel', (event) => {
const atEnd = /* …math… */
if (atEnd) event.preventDefault()
}, { passive: false })
.list {
overflow-y: auto;
overscroll-behavior: contain;
}