Skip to content

fix(api): clarify Window scroll options#44116

Merged
chrisdavidmills merged 4 commits into
mdn:mainfrom
Ashish-CodeJourney:fix-window-scrollto-options
May 14, 2026
Merged

fix(api): clarify Window scroll options#44116
chrisdavidmills merged 4 commits into
mdn:mainfrom
Ashish-CodeJourney:fix-window-scrollto-options

Conversation

@Ashish-CodeJourney
Copy link
Copy Markdown
Contributor

Description

Clarifies that Window.scrollTo() options use absolute document coordinates, while Window.scrollBy() options use relative scroll amounts. Also aligns the behavior option
description between both pages.

Motivation

The previous top and left descriptions looked similar for scrollTo() and scrollBy(), which could make readers think both methods use delta values. This update makes the
absolute versus relative behavior explicit.

Additional details

Tested with:

  • npx --no-install markdownlint-cli2 files/en-us/web/api/window/scrollto/index.md files/en-us/web/api/window/scrollby/index.md
  • npx --no-install prettier -c files/en-us/web/api/window/scrollto/index.md files/en-us/web/api/window/scrollby/index.md

Related issues and pull requests

Fixes #44098

@Ashish-CodeJourney Ashish-CodeJourney requested a review from a team as a code owner May 14, 2026 07:45
@Ashish-CodeJourney Ashish-CodeJourney requested review from chrisdavidmills and removed request for a team May 14, 2026 07:45
@github-actions github-actions Bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels May 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there @Ashish-CodeJourney, and thank you for your work on this.

I have some comments for you to consider.

- `options`
- : An object containing the following properties:
- `top`
- : Specifies the number of pixels along the Y axis to scroll the window or element.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original wording was fine in these cases. In your new wording, "to scroll by along" is not grammatically good. Revert these two changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, agreed. I reverted these two descriptions to the original wording.

Comment thread files/en-us/web/api/window/scrollby/index.md Outdated
Comment thread files/en-us/web/api/window/scrollby/index.md Outdated
Comment thread files/en-us/web/api/window/scrollby/index.md Outdated
Comment thread files/en-us/web/api/window/scrollby/index.md Outdated
- : The pixel along the vertical axis of the document that you want displayed in the upper left. This is the same as the `yCoord` parameter.
- `left`
- : Specifies the number of pixels along the X axis to scroll the window or element.
- : The pixel along the horizontal axis of the document that you want displayed in the upper left. This is the same as the `xCoord` parameter.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't comment on each of xCoord, yCoord, top, and left individually, but ... isn't this wording a bit confusing in general? Shouldn't these descriptions say something more along the lines of

The x coordinate of the position in the viewport that you want to scroll to...?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ashish-CodeJourney, everything else looks fine, but I still think this kind of wording on the scrollTo pages is confusing.

Maybe this:

The x coordinate of the document that you want the viewport's left edge to scroll to.

And similar for the other descriptions?

?

@Ashish-CodeJourney
Copy link
Copy Markdown
Contributor Author

@chrisdavidmills Thanks for the review. I have worked on the suggestions,
Do let me know of any improvements

Copy link
Copy Markdown
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ashish-CodeJourney the rest of it looks fine now, but I think this comment still needs addressing:

#44116 (comment)

@Ashish-CodeJourney
Copy link
Copy Markdown
Contributor Author

@Ashish-CodeJourney the rest of it looks fine now, but I think this comment still needs addressing:

#44116 (comment)

agreed. I updated the scrollTo() coordinate descriptions to use that wording style for xCoord, yCoord, top, and left.

I also applied the equivalent wording to Element.scrollTo() so it stays consistent with Window.scrollTo().

@Ashish-CodeJourney Ashish-CodeJourney force-pushed the fix-window-scrollto-options branch from 992b69e to 4311101 Compare May 14, 2026 12:35
Copy link
Copy Markdown
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, this is looking good, thanks again for all your work on this, @Ashish-CodeJourney.

Merging.

@chrisdavidmills chrisdavidmills merged commit 3f96229 into mdn:main May 14, 2026
8 of 9 checks passed
@boiseiben
Copy link
Copy Markdown

Thanks all for your work on a quick fix!

@Ashish-CodeJourney Ashish-CodeJourney deleted the fix-window-scrollto-options branch May 15, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scrollTo object parameters described as deltas

3 participants