Open flackr opened 1 month ago
I think to handle this in a general way we should find the common ancestor scrolling container (and tree of contained scrolling containers) of all of the scroll markers in the group, and then work from the top-down to first find the active scroller, then repeat within that until you arrive at a particular marker.
To make this proposal more concrete. The proposed way to select the active marker among targets in different scrolling containers is as follows:
Define/share an algorithm for determining the active target for a list of targets in a single scroller (which as discussed in #10917 will for now will be a bit flexible), To determine the active marker, we start from the root (or the nearest ancestor scrolling container) S. Then
This defines reasonable behavior that ensures a target is only active if all of its ancestor scrolling containers to the common ancestor scroll container are also in a position to be considered active (i.e. onscreen and more closely aligned than other targets).
I think for the siblings case, we might want to allow multiple active scroll markers. For the ancestors case, probably requiring all ancestor scroll containers to be visible makes sense; but I'm not 100% sure if that necessarily means that the ancestors would be considered active if they were the target themselves.
Hm, for the ancestors case I've seen both behaviors; for example, in a ToC scroll indicator, I've seen both "just indicate the single most relevant entry" and "indicate the most relevant entry and all ancestors, since you're also in them"; I think the latter is sometimes done with a slightly different styling on the ancestors.
We might want to track and expose both of these concepts; select the single most relevant marker in a group and let it match :target-current
, but also define a :target-current-all
pseudo that'll match the current target, its ancestors (if they're also possible scroll markers in the group) and other scroll markers that could in theory be considered "relevant", except that another visible marker target is already considered more relevant.
With
<a>
elements, it is possible to link to any content anywhere on the page. This means that we can create a scroll marker group where multiple markers might be respectively active. E.g.Nested scrollers might be used within sections of contents:
Sibling / cousin scrollers (I'm less sure of the use case but it would need a defined behavior):
In both of these cases there are many scroll markers which could be said to be
:checked
as their nearest ancestor scrolling element is currently scrolled to them.