position: sticky - top constraint is applied over bottom even when top is not yet constrained by scroll |
|||
Issue descriptionRepro: http://output.jsbin.com/bemazek/ When the sticky constraint rect is smaller than the sticky element, logic in LayoutBoxModelObject::UpdateStickyPositionConstraints() kicks in and removes the 'bottom' constraint: if (!Style()->Top().IsAuto() && !Style()->Bottom().IsAuto()) { if (vertical_offsets > scroll_container_relative_containing_block_rect.Height() || vertical_offsets + sticky_box_rect.Height() > constraining_size.Height()) { skip_bottom = true; } } This is unnecessarily harsh - the current scroll position can be such that the bottom constraint is valid whilst the top has not yet become active (see the repro for such an example). Instead of calculating this statically, we should be determining whether to skip the bottom calculation dynamically. Unfortunately the spec does not actually have wordage for what to do when top/bottom conflict, see https://github.com/w3c/csswg-drafts/issues/1294, but we believe the correct behavior is that top should trump bottom only when they are both active. Interestingly, Firefox exhibits the same behavior, and I intend to open a bug against them too. Note: similar behavior likely exists for left/right, thought I haven't checked.
,
May 4 2017
,
May 9 2017
We may want to wait till the relevant spec is settled.
,
Aug 22
|
|||
►
Sign in to add a comment |
|||
Comment 1 by smcgruer@chromium.org
, Apr 25 2017