8286832: JavaDoc pages call browser history API too often

Reviewed-by: prappo
This commit is contained in:
Hannes Wallnöfer 2022-05-23 20:10:46 +00:00
parent 9df93a180c
commit 6a192206b8

View File

@ -137,14 +137,14 @@ document.addEventListener("DOMContentLoaded", function(e) {
window.addEventListener("hashchange", function(e) {
history.replaceState(contentDiv.scrollTop, document.title);
});
var timeoutId;
contentDiv.addEventListener("scroll", function(e) {
var timeoutID;
if (!timeoutID) {
timeoutID = setTimeout(function() {
history.replaceState(contentDiv.scrollTop, document.title);
timeoutID = null;
}, 100);
if (timeoutId) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(function() {
history.replaceState(contentDiv.scrollTop, document.title);
}, 100);
});
if (!location.hash) {
history.replaceState(contentDiv.scrollTop, document.title);