New issue
Advanced search Search tips

Issue 715172 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

position: sticky - top constraint is applied over bottom even when top is not yet constrained by scroll

Project Member Reported by smcgruer@chromium.org, Apr 25 2017

Issue description

Repro: 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.
 

Comment 2 by yigu@chromium.org, May 4 2017

Cc: -yigu@chromium.org smcgruer@chromium.org
Owner: yigu@chromium.org

Comment 3 by yigu@chromium.org, May 9 2017

We may want to wait till the relevant spec is settled.
Cc: yigu@chromium.org
Labels: Hotlist-Polish
Owner: ----
Status: Available (was: Assigned)

Sign in to add a comment