Skip to content

[css-conditional-5] scroll-state(stuck) will remain applying its @container ruleset for elements has left viewport #12302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
n0099 opened this issue Jun 7, 2025 · 0 comments

Comments

@n0099
Copy link

n0099 commented Jun 7, 2025

https://jsfiddle.net/ebkafjtp/18/

<div class="container">
  <div class="sticky">div>
  <div class="sticky">div>
  <div class="sticky">div>
  <div class="sticky">div>
  <div class="sticky">div>
div>
.sticky {
  container-type: scroll-state;
  position: sticky;
  top: 0;
  height: 30vh;
  margin-block: 2rem;
  background: gray;
}
.sticky:nth-child(even) {
  background: darkgray;
}

@container scroll-state(stuck: block-start) {
  *::before {
    content: 'block-start';
  }
}
@container scroll-state(stuck: none) {
  *::before {
    content: 'none';
  }
}

When scrolling the viewport to the end, any .sticky whose getBoundingClientRect().bottom is negative will still have their ::before { content: 'block-start'; } style that defined in the of @container.

n0099 added a commit to n0099/open-tbm that referenced this issue Jun 8, 2025
…ore their local shared state

* fix not setting ref `viewportTopmostPost` to the previous post when scrolling viewport upwards due to w3c/csswg-drafts#12302 @ `usingScrollState()`
* replace `if` statement inside `Array.forEach()` with `Array.filter()` @ `usingIntersectionObserver()`
@ `stores/viewportTopmostPost.ts`
@ fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant