windowObject.addEventListener('load',()=>{// The `load` event has been chosen intentionally as it is the only state when everything is loaded and the scroll will proceed correctly (it will slide to correct offset).
if(windowObject.location.hash){
// First, we need to go to top immediately (hack to prevent jump to desired element).
windowObject.scroll({top:0,left:0});
// If no hash, we do not need to run scrolling.
if(!windowObject.location.hash){
return;
}
// If performance is not present, the browser would not scroll smoothly otherwise I guess. So let's skip it completely, it's not worth fallbacking to Date() function.
if(typeofperformance==='undefined'){
return;
}
// Start timer.
conststart=performance.now();
/*
* The `load` event has been chosen intentionally as it is the state when everything is ready -
* all styles are loaded and offsets are computed correctly - so the scroll will be computed correctly.