W3C home > Mailing lists > Public > public-css-archive@w3.org > July 2018

Re: [csswg-drafts] [css-values] random() function

From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
Date: Mon, 02 Jul 2018 12:23:18 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-401786655-1530534197-sysbot+gh@w3.org>
In my previous musings on the topic, I stated that there are two ways we can evaluate random(), both of which are useful:

1. Evaluated once per occurrence in the stylesheet, at parse time.
2. Evaluated once per occurrence in the stylesheet per element, at specified-value time.

The first means that `.foo:hover { color: rgb(random(0, 255), 0, 0); }` evaluates to the same color for every .foo element, and doesn't change if you repeatedly hover/unhover.  The second means it'll be different on each .foo element, but will still be consistent if you repeatedly hover/unhover a given element.

There's possibly a third, even less stable mode: evaluated freshly at "application" time, whenever the rule would trigger a transition due to it winning the cascade over a different specified value.  This is different per element, *and* is different each time you hover the element.

--------

We'd also want a few different types of randomness; numeric ranges are okay, but getting a random value from a list is very useful and handles colors well, too.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2826#issuecomment-401786655 using your GitHub account
Received on Monday, 2 July 2018 12:23:24 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 July 2018 12:23:25 UTC