window.scrollTo behavior option missing "instant" string literal union
See original GitHub issueBug 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
💻 Code
window.scrollTo({behavior: 'instant'})
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For my case I have to use
instant
option notauto
because the<html>
tag is set to smooth scroll, by using inline styleHey, 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 forscrollTo
. In other words, instant scrolling behavior cannot be forced by thescrollTo
method per the spec.However, I’ve checked and both Firefox and Chrome deviate from the spec and allow the use of
'instant'
forscrollTo
. 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