Closed
Description
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'
.
Activity
PaperStrike commentedon 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 commentedon 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 asauto
, so it's safe to simply drop the property unless you needsmooth
.ObjectAssign commentedon Sep 17, 2022
@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
replaced `scrollTo(behaviour: "instant")` with `scrollTo(behaviour: "β¦
Pass CI TypeScript
Pass CI TypeScript
jiri-thiemel-te commentedon May 30, 2024
That most definitely is not true. It depends on the CSS property
scroll-behaviour
value . Theinstant
value needs to be allowed forbehavior
property ofscrollTo
andscrollIntoView
.The default value is
auto
. That one you can omit as developer. Not this one. When thescroll-behaviour
is set tosmooth
and you want to scroll to an element without the animation then you need to passbehavior: instant
. See https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo#behaviorhelloint commentedon Sep 26, 2024
not ideally solution but this works for me when upgrading typescript might not be an option.