Skip to content

[css-transforms] Have scale function accept percentage value #3399

Closed

Description

@Ernedar

Hello,
I would like to suggest adding percentage for scale function in transformations.

Current state: scale() is using [-NUM, NUM] where NUM is whole number (integer)
Suggestion: scale() will support [-NUM, NUM] and [-%, %]
Example:
transform: scale(120%) will work same as transform:scale(1.2) is working right now.

It is not a game-breaker but it is nice to have.

Thank you for your work.

Activity

  1. changed the title [-][css-transforms] [/-] [+][css-transforms] Have scale function accept percentage value[/+] on Dec 7, 2018
  2. AmeliaBR commented on Oct 2, 2019

    @AmeliaBR
    Contributor

    Agree this is a nice to have, would be more intuitive for many authors (scale(50%) instead of scale(0.5), scale(150%) instead of scale(1.5)). The impact on implementations would be restricted to parsing time — computed/serialized values would remain numbers.

    It's very similar to the change in alpha values to support percentages, which the WG re-affirmed in #3342 after browser teams emphasized their plan to ship.

  3. css-meeting-bot commented on Oct 2, 2019

    @css-meeting-bot
    Member

    The CSS Working Group just discussed Have scale function accept percentage value, and agreed to the following:

    • RESOLVED: Allow percentages inside the scale
    The full IRC log of that discussion <dael> Topic: Have scale function accept percentage value
    <dael> github: https://github.com//issues/3399
    <dael> AmeliaBR: This was a community suggestion that scale transforms that current accept number also accept % values, transform-scale: 150% instead of 1.5
    <dael> AmeliaBR: Question of author conveience and intuitiveness. We've done this recently for opacity. Just like that it would only effect parsing. Actual rendering wouldn't change.
    <dael> AmeliaBR: Question of if people think it's enough value to users to change parsing code
    <dael> Rossen_: Any expection for how computed serializes
    <dael> AmeliaBR: I would assume convert to simple number
    <dael> TabAtkins: Given this is a place where number represents same as % I'm fine with it. It's low value, but low effort and I'm good with being more consistent across the language.
    <dael> TabAtkins: Idea is it would parse into a number internally and serialize as a number
    <dael> AmeliaBR: smfr can correct, but I assume this is transforms 2. I don't think any rush to get that to PR so we have time to ship impl
    <heycam> +1 for consistency across all values that accept a proportion-like value
    <dael> smfr: I think that's true. Would effect 2d transform functions. New in transforms 2. Fine with this
    <dael> Rossen_: Obj to accept proposal Allow percentages inside the scale
    <dael> RESOLVED: Allow percentages inside the scale
  4. birtles commented on Oct 2, 2019

    @birtles
    Contributor

    Presumably this should also apply to the individual scale property (and not just the scale() function).

  5. Crissov commented on Oct 3, 2019

    @Crissov
    Contributor

    A convenient way, e.g. a keyword, to scale by √2 ≈ 1.414 or √½ ≈ 0.707 (as in ISO paper and pens) might also be nice. scale(sqrt(2)) also works, of course.

  6. added 2 commits that reference this issue on Oct 4, 2019
    48d27b5
    d849d7a
  7. tabatkins commented on Oct 7, 2019

    @tabatkins
    Member

    Yes, now that sqrt() exists, that case is well handled.

  8. added a commit that references this issue on Oct 10, 2019
    707a156
  9. added a commit that references this issue on Dec 2, 2019
    3b5fa27
  10. BorisChiou commented on Dec 3, 2019

    @BorisChiou
    Contributor

    Presumably this should also apply to the individual scale property (and not just the scale() function).

    Agree, and Gecko just landed it (based on the spec PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions