Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make resize triggers use default CSS writing mode #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fred-wang
Copy link

The Chromium community is moving to scroll position values indicated in
the CSSOM specification [1]. In order to launch the feature and analyze
potential broken URLs, they count pages setting the scroll position of
a scroller in non-default writing mode to a positive value. Websites
using javascript-detect-element-resize in RTL or vertical mode appear
in the top results and cause a lot of false positives [2]. In order to
avoid that, ensure that the resize triggers use the default writing
mode (direction: ltr and writing-mode: horizontal-tb).

[1] https://www.chromestatus.com/feature/5759578031521792
[2] #61

The Chromium community is moving to scroll position values indicated in
the CSSOM specification [1]. In order to launch the feature and analyze
potential broken URLs, they count pages setting the scroll position of
a scroller in non-default writing mode to a positive value. Websites
using javascript-detect-element-resize in RTL or vertical mode appear
in the top results and cause a lot of false positives [2]. In order to
avoid that, ensure that the resize triggers use the default writing
mode (direction: ltr and writing-mode: horizontal-tb).

[1] https://www.chromestatus.com/feature/5759578031521792
[2] sdecima#61
@fred-wang
Copy link
Author

I verified that the resize observer still works in different writing modes in Firefox and Chrome. I also checked that the patch avoids triggering the use counter.

Patch tested with the following:

<!DOCTYPE html>
<html>
  <head>
    <title>Detect element resize demo</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="detect-element-resize.js"></script>
    <style>
      .resizable {
          resize: both;
          overflow: hidden;
          background: blue;
          width: 100px;
          height: 100px;
          margin: 10px;
      }
    </style>
  </head>
  <body>
    <h1>Detect element resize demo</h1>

    <div style="writing-mode: horizontal-tb">
      default: <div class="resizable"></div>
    </div>
    <div style="direction: rtl">
      rtl: <div class="resizable"></div>
    </div>
    <div style="writing-mode: vertical-rl">
      vertical-rl: <div class="resizable"></div>
    </div>
    <div style="writing-mode: vertical-lr">
      vertical-lr: <div class="resizable"></div>
    </div>

    <script type="text/javascript">
      Array.from(document.getElementsByClassName("resizable")).forEach((element) => {
          addResizeListener(element, () => {
              var rect = element.getBoundingClientRect();
              var css = window.getComputedStyle(element);
              console.log(`Writing mode: ${css.writingMode}, ${css.direction}`);
              console.log(`Size: ${rect.width}x${rect.height}`);
          });
      });
    </script>
  </body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant