question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

window.scrollTo behavior option missing "instant" string literal union

See original GitHub issue

Bug Report

window.scrollTo behavior option has three types: “smooth”, “instant” and “auto”, but typescript doesn’t have “instant” value.

🕗 Version

v4.4.4

⏯ Playground Link

https://www.typescriptlang.org/play?#code/O4SwdgJg9sB0DOBjATlANmgKlAFAbwCMBTACwEMA3EKZALgAIByceAFzLFcYF8BKIA

💻 Code

window.scrollTo({behavior: 'instant'})

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
aquaductapecommented, Dec 12, 2021

For my case I have to use instant option not auto because the <html> tag is set to smooth scroll, by using inline style

6reactions
nickgirardocommented, Nov 23, 2021

Hey, I just ran into this issue as well. It looks like according to the CSSOM spec there is no 'instant' setting for option.

You can see in the CSS Overflow Module Level 3 that scroll-behavior only accepts the vales 'auto' | 'instant'. Furthermore, the CSSOM specifies that if behavior is auto and the element in question being scrolled to has the smooth computed for it (i.e. the scroll-behavior property of the element is set to ‘smooth’) that smooth scrolling will be used. The only case where instant scrolling should be used (per the spec) is if the element doesn’t have scroll-behavior set to smooth and auto is the behavior for scrollTo. In other words, instant scrolling behavior cannot be forced by the scrollTo method per the spec.

However, I’ve checked and both Firefox and Chrome deviate from the spec and allow the use of 'instant' for scrollTo. I’m not sure what should be done here from TypeScript’s perspective as the reality of the web and the letter of its law differ. Ideally, the spec would be revised to allow for explicitly instant scrolling

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window.scrollTo() - Web APIs | MDN
behavior. Specifies whether the scrolling should animate smoothly ( smooth ), or happen instantly in a single jump ( auto , the default...
Read more >
Scroll back to the top of scrollable div - Stack Overflow
The scrollTo() method scrolls the document to the specified coordinates. window.scrollTo(xpos, ypos); xpos Number Required. The coordinate to ...
Read more >
Underscore.js
Underscore is a JavaScript library that provides a whole mess of useful functional ... There is a quick summary of the options below,...
Read more >
Documentation - Rclone
The major advantage to using the connection string style syntax is that it only applies to the remote, not to all the remotes...
Read more >
Preferences - Notepad++ User Manual
For options where the opposite behavior might not be obvious, it may also ... of the Notepad++ window, showing file type, caret location,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found