w3c / w3c/csswg-drafts

[selectors] add an :ever-been-visible pseudo-class

Open
#4,015 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

selectors-5
Dominant language
Bikeshed
Stars
4.9k
Forks
816
Avg merge
2d 18h
Merged PRs (30d)
24

Description

I think it would be useful to have a declarative way to apply styles (for example for starting animations), when an element has been scrolled into view. So this would be kind of like a declarative way to set up an intersection observer, and set a class name. And maybe you'd want to similarly have some kind of threshold.

I've seen plenty of sites that kick off animations (maybe fading in an image, or starting a complex animation) once an element is scrolled into view.

The reason for suggesting :ever-been-visible rather than :visible is to avoid cycles if the rules that apply when the selector matches cause the element to be moved out of view.

/cc @AmeliaBR @bkardell

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Start by reviewing the proposed :ever-been-visible selector and its interaction with intersection-observer-like visibility and thresholds. Done would require an agreed declarative pseudo-class design, including behavior when matching styles move an element out of view.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.