Skip to content

ScrollBehavior definition is missing 'instant' for scrollTo #46654

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

Closed
patik opened this issue Nov 3, 2021 · 5 comments
Closed

ScrollBehavior definition is missing 'instant' for scrollTo #46654

patik opened this issue Nov 3, 2021 · 5 comments

Comments

@patik
Copy link

patik commented Nov 3, 2021

Bug Report

πŸ”Ž Search Terms

instant
scrollbehavior
scrollTo
type definition

πŸ•— Version & Regression Information

v4.4.4, but it's also mentioned in #28755 (v3.2.1)

  • This is a crash

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

window.scrollTo({
  top: 0,
  left: 0,
  behavior: 'instant' // This should be allowed
})

πŸ™ Actual behavior

The value of 'instant' cannot be assigned to behavior when using element.scrollTo() according to https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo as well as testing it in a browser

πŸ™‚ Expected behavior

The value of 'instant' is allowed when using element.scrollTo() according to https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo as well as testing it in a browser. Note that a similar issue, #28755, was about scrollIntoView(), which indeed does not allow 'instant'.

@PaperStrike
Copy link

PaperStrike commented Nov 3, 2021

I guess it's microsoft/TypeScript-DOM-lib-generator@fe01c9a#r31507840, instant isn't valid anywhere ever since.
You may need to info MDN folks to update the docs. πŸ‘€

@patik
Copy link
Author

patik commented Nov 3, 2021

I stand corrected! For anyone else who comes across this, in my testing I found that browsers do indeed treat instant the same as auto, so it's safe to simply drop the property unless you need smooth.

@ObjectAssign
Copy link

@patik auto to me works as scrolling does, I guess that is because I have enabled smooth scroll in my browser...

However, I would really like the instant to be available

CommanderStorm added a commit to TUM-Dev/NavigaTUM that referenced this issue Jun 25, 2023
p2edwards added a commit to kobotoolbox/kpi that referenced this issue Jan 30, 2024
- Don't need {behavior: 'instant'}, acts like auto
microsoft/TypeScript#46654 (comment)
- TS config abhors unused parameter
p2edwards added a commit to kobotoolbox/kpi that referenced this issue Jan 30, 2024
- TS dislikes {behavior: 'instant'}, suggests defaulting to auto
microsoft/TypeScript#46654 (comment)
- TS config abhors unused parameter
@jiri-thiemel-te
Copy link

jiri-thiemel-te commented May 30, 2024

I stand corrected! For anyone else who comes across this, in my testing I found that browsers do indeed treat instant the same as auto, so it's safe to simply drop the property unless you need smooth.

That most definitely is not true. It depends on the CSS property scroll-behaviour value . The instant value needs to be allowed for behavior property of scrollTo and scrollIntoView.

The default value is auto. That one you can omit as developer. Not this one. When the scroll-behaviour is set to smooth and you want to scroll to an element without the animation then you need to pass behavior: instant. See https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo#behavior

@helloint
Copy link

helloint commented Sep 26, 2024

I stand corrected! For anyone else who comes across this, in my testing I found that browsers do indeed treat instant the same as auto, so it's safe to simply drop the property unless you need smooth.

not ideally solution but this works for me when upgrading typescript might not be an option.

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

No branches or pull requests

5 participants