W3C home > Mailing lists > Public > public-css-archive@w3.org > December 2019

Re: [csswg-drafts] [css-values] Proposal: add sibling-count() and sibling-index() (#4559)

From: Shaw via GitHub <sysbot+gh@w3.org>
Date: Thu, 05 Dec 2019 15:06:07 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-562169143-1575558366-sysbot+gh@w3.org>
@jakearchibald `child count - 1` is a value I use in Splitting demos frequently for getting a “percentage” like decimal (range from 0 to 1 of the child’s index relative to the total). Here's a quick example from the initial `sibling-count()` discussion where I use that "child count - 1" value to stagger an `animation-delay` over the course of 2s.
```
animation-delay: calc( 2s * ( var(--sibling-index) / var(--sibling-count) ) );
```
https://codepen.io/shshaw/pen/LYEEKMQ

This can of course be achieved by doing `child-count() - 1`, but if we're calling it the count of the siblings then it seems odd that it would include the element itself. I do find the `- 1` value very useful in my instances, but I'm not beholden to a `- 1` value if there's a strong case against, or if this is just a difference in semantics. 


-- 
GitHub Notification of comment by shshaw
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4559#issuecomment-562169143 using your GitHub account
Received on Thursday, 5 December 2019 15:06:13 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:57 UTC