Open andy-blum opened 1 year ago
I guess that makes sense so long as DOMRect is mostly being used in to access layout positioning info (and not as a general "rect").
Do we know of other places where DOMRect is used? Just want to be sure adding these things wouldn't cause issues in other APIs that might be relying on DOMRect.
Quickly looking at Webref IDL extracts, I end up with the following list of specs that reference DOMRect
, DOMRectReadOnly
, or DOMRectInit
:
for future reference, the same information is also readily available from WebIDLPedia via the "Referring IDL interfaces/dictionaries" and "Referring specifications" sections on the relevant pages: DOMRect, DOMRectReadOnly and DOMRectInit.
Introduction
Web APIs that deal with positioning have not kept up with CSS. While logical positioning in stylesheets has largely simplified language-agnostic designs, the same cannot be said for many web APIs. I believe extending apis dealing with positioning to include logical properties will make certain tasks easier and more performant for sites
Use Cases/Examples
1: Element.scrollLeft()
Codepen Demo
A better implementation might be
Element.scrollInline()
where the value is always between 0 and positive inifinity. 0 indicates the scroll container is at the leftmost position in LTR languages and rightmost in RTL languages.2. DOMRect
The DOMRect API has 8 instance properties:
x
y
width
height
top
bottom
left
right
All of these are helpful, but on sites that need to support both LTR and RTL languages, they leave developers to first decipher which property will actually be helpful. I propose adding four more properties to the DOMRect API:
blockStart
blockEnd
inlineStart
inlineEnd
Goal
Any API that implements a property or method based on a physical direction (top, bottom, left, right), or an X or Y coordinate also offers a logical-property alternative
Privacy & Security Considerations
No considerable privacy or security concerns are expected, but we welcome community feedback.