[css-scroll-snap] Re-Snap after layout/content change (and initial page load) |
||
Issue descriptionThe spec requires this as in [1]. Basically anything we change layout or style such that the scroll container snap info is modified we have to re-snap. I believe we have all the right hooks to trigger recalc snap data inside SnapCoordinator [2]. It seems most appropriate for SnapCoordinator to dirty any scroller whose snap info has change to re-snap (at some point during the document lifecycle). [1] https://drafts.csswg.org/css-scroll-snap/#snap-strictness "If the content or layout of the document changes (e.g. content is added, moved, deleted, resized) such that the content of a snapport changes, the UA must re-evaluate the resulting scroll position, and re-snap if required. If the scroll container was snapped before the content change and that same snap position still exists (e.g. its associated element was not deleted), the scroll container must be re-snapped to that same snap position after the content change." [2] codesearch.chromium.org/chromium/src/third_party/blink/renderer/core/page/scrolling/snap_coordinator.h?
,
Jul 20
I think a natural consequence of this is that we also snap after initial page load. We should test for this case separately though.
,
Dec 4
As for implementation of snap post layout, skobes@ mentioned that we should look into LocalFrameView::PerformScrollAnchoringAdjustments since it does something very similar. Another interesting point he brought up was that we should be careful that we don't cause "layout loop" which can happen if snapping causes re-layout and that causes snapping again. I don't think this should happen if our algorithm chooses the same snap-point again but we may want to have more explicit guards against this.
,
Dec 4
Note that once we have post-layout snapping scroll snap can address the same usecases as scrollbar anchoring [1][2]. So those efforts are superseded by scroll snap. [1] https://tabatkins.github.io/specs/css-sticky-scrollbars/#intro and [2] https://www.chromestatus.com/feature/5865619656278016 |
||
►
Sign in to add a comment |
||
Comment 1 by majidvp@chromium.org
, Jul 20