-
Notifications
You must be signed in to change notification settings - Fork 757
Description
https://drafts.csswg.org/css-scroll-snap-1/#examples doesn't seem to have anything like the example in http://tabatkins.github.io/specs/css-sticky-scrollbars/#intro (used to demonstrate that we don't need a sticky scrollbars spec, because scroll snap can already do that).
Here, I'll just quote the relevant portion:
This spec has been superseded by other CSS technology. In particular, to implement a chatroom that "sticks" the scrollbar to the bottom of the scroller when you’re near the bottom, staying there if you add new messages to the bottom, but not messing with your scroll position when you’re scrolled elsewhere in the history, just use [css-scroll-snap-1]:
.message-container { scroll-snap-type: proximity; } .message-container::after { content: ""; height: 0; overflow: hidden; display: block; scroll-snap-align: end; }This creates a single scroll snap area in the message container, aligned with the very bottom of the container. If you scroll "near" the bottom, you’ll snap to it; if you add more content to the message container (thus pushing the ::after further down), it’ll automatically re-snap to it (because scroll containers have to re-snap to the same scroll snap area if it still exists); if you are scrolled somewhere else in the history, it won’t do anything at all.