[csswg-drafts] [css-values] Add clamp()?

xfq has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values] Add clamp()? ==
For background, see discussions starting at https://github.com/w3c/csswg-drafts/issues/544#issuecomment-321498156

-----

It would be useful to add a `clamp()` function. Two kinds of argument order were proposed in #544:

* `(min, value, max)`
* `(value, min, max)`

Both of them have precedents[1][2]. (I personally prefer the `(min, value, max)` version.)

Although authors can emulate it by combining `max()` and `min()`, the `clamp()` function can avoid the [confusion](https://github.com/w3c/csswg-drafts/issues/544#issuecomment-322011769) caused by the emulation.

The behavior of `clamp()` on `<angle>` and `<color>` also needs some thoughts.

-----

Links:

[1] [`clamp` in the Boost Algorithm Library](https://www.boost.org/doc/libs/1_66_0/libs/algorithm/doc/html/algorithm/Misc.html#the_boost_algorithm_library.Misc.clamp)
[2] [`qBound` in Qt](https://doc.qt.io/qt-5/qtglobal.html#qBound)

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2519 using your GitHub account

Received on Monday, 9 April 2018 10:17:28 UTC