Open tabatkins opened 1 year ago
Since the spec doesn't say this behavior only applies to non-auto 'offset-position', this also means that the circle()/ellipse() defaults to being centered on the top-left corner of the element's laid-out position, which similarly doesn't seem very useful.
A different take with larger potential compat issues - what if we defined that ray() takes an optional initial position, similar to the circle() function, and just dropped offset-position entirely? I think offset-position is, in general, just a relic of the old "based on abspos" spec. It gets completely ignored by most of the basic shapes (and is only hacked into working with circle()/ellipse()).
Do we have any data on usage of the property? If it is usually set to 'center' when paired with ray(), we might be able to just default the ray() position to center, like Shapes does for circle()/ellipse().
Okay, looking into this more, the "offset-position affects circle()/ellipse()" behavior was committed in https://github.com/w3c/fxtf-drafts/commit/a1faed1aee67b2acd5f49c17ad782b029bcb800f, claiming to fix #78. However, #78 ended without any resolutions, and just some topics we needed to address:
(1) paths can't be specified relative to the container. One suggestion for fixing this was to define a CSS path syntax.
Done now, via shape().
(2) there's no simple rectangle or polygon shape that can be positioned relative to the element. CSS path syntax somewhat fixes this, but for rectangles we thought that adding a new rect() type that included a position and width/height information would be useful.
Done now, via xywh().
(3) we need to specify the fallback behavior for circle and ellipse
After rereading the issue a few times, still not sure what this is referring to.
(4) we need to specify path() positioning and make sure it makes sense
I think this was about the "path relative to element's current position" thing.
So I think the edits ended up doing the one thing we agreed to punt on (making offset-position interact with basic shapes) and failed to add the one thing we seemed to agree needed doing (allowing path() to be specified relative to the element's current position).
If we added the ability for path() to respond to offset-position, we have an issue - ray() pays attention to offset-position by default, but path doesn't pay attention by default. We need to resolve this somehow.
My proposal, then:
at <position>
argument to ray(), path(), and shape(), following circle()/ellipse().
center
by default.left top
by default.none
value to offset-position, and make it the initial value. When none
, it does nothing.at ...
positions in the offset-path functions. auto
, as it does now, effectively gives you element-relative positioning. A <position>
lets you provide a separately-cascaded/animated starting position.Hopefully this minimizes the chance of breakage, since rays will default to coming from the center if the author didn't touch offset-position, identical to what is probably the common case today where the element is abspos'd with left:50%; top:50%
and offset-position:auto
is used by default. But it gives us a more consistent approach to positioning shapes in general, and gives some useful new functionality to path() and shape(). (Today you could only achieve that if you wrote your path entirely with relative coordinates; with the new functionality you can use absolute coords if that's easier to understand, and they'll all effectively shift for you.)
This requires an edit to Shapes 1 as well, so /cc @astearns .
The CSS Working Group just discussed [motion-1] offset-position + circle()
, and agreed to the following:
RESOLVED: Add "at <position>" to path(), shape(), and ray()
RESOLVED: Add 'normal' keyword to 'offset-position'
In the definition of
<basic-shape>
for 'offset-path', there's a paragraph that states:This contradicts Shapes 1, which simply defaults an omitted center-position to "center" without making it configurable.
Worse, this means that 'offset-position' now does two completely unrelated things - for ray(), it sets where the ray emerges from (aka where
offset-distance: 0%
places you), but for circle() and ellipse() it (sometimes!) sets the center of the ellipse, which is not a point on the path at all.I don't understand why this is necessary; you can just set the center position directly in the function if you need to, and if you omit it I think it's confusing for it not to act like an omitted position in other contexts. To get the default behavior that Shapes defines I have to explicitly say
circle(... at center)
.Can we just drop this odd behavior and have circle()/ellipse() default their center position as normal?