Re: [csswg-drafts] [css-values-4] Add new relative length units that are relative to the size of the system cursor (#8315)

Thanks for your sharing your ideas everyone!

> Note that the cursor image may have some transparent areas, so visually the cursor can look smaller. Also, note that the cursor image doesn't have to be anchored at the top left corner, e.g.
> 
> ```css
> cursor: url(http://www.javascriptkit.com/dhtmltutors/cursor-hand.gif) 10 4, auto
> ```
> 
> So even if the cursor image is 25px wide, it will only extend 15px to the right, so that's the amount you probably want.

The goal of this proposal is to expose the system cursor size, which web developers cannot know at all for the moment. If the CSS is altering the cursor ([which is not recommended for accessibility](https://ericwbailey.website/published/dont-use-custom-css-mouse-cursors/)), then the developer should know the characteristics of the cursor they are adding, which we cannot guess, so I think that is a case where using hardcoded values instead of the extra capabilities added by this proposal would be legitimate? Am I missing something here?

> Maybe instead of new units this could be solved via [CSS Anchor Positioning](https://drafts.csswg.org/css-anchor-1/). A new `cursor` keyword could be introduced that dynamically resolves to the cursor's width or height depending on the [`<anchor-side>`](https://drafts.csswg.org/css-anchor-1/#typedef-anchor-side).
> 
> So positioning the tooltip could then look like this:
> 
> ```css
> .tooltip {
>   position: absolute;
>   left: calc(anchor(cursor right) + 10px);
>   top: calc(anchor(cursor bottom) + 10px);
> }
> ```

This is an interesting suggestion, in particular I think it reads well. This adds more new behaviors than the new units though: `anchor(cursor width)`, `anchor(cursor height)` would be the equivalent of `1scw`, `1sch`, and all other behaviors are an extra, e.g. we could now have things that automatically follow the dynamic position of the cursor in pure CSS.

To me this looks more complex to implement than the first proposal as it implies having a pseudo-anchor element for the cursor that moves with every mouse move -- something that users currently simulate with JavaScript mouse move events. But the implementation complexity may be worth it, if the extra behaviors are desirable?

-- 
GitHub Notification of comment by yjugl
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8315#issuecomment-1408174905 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 30 January 2023 08:24:54 UTC