mirror of
https://github.com/bendtherules/UiQuestions.git
synced 2026-08-18 13:52:50 +00:00
handleScrollRestoration - Add script to head
This will set history.scrollRestoration to "manual" on page start, if hash starts with "link-"
This commit is contained in:
@@ -102,4 +102,10 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
scripts: [
|
||||||
|
{
|
||||||
|
src:
|
||||||
|
'/scripts/handleScrollRestoration.js',
|
||||||
|
},
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
var hash = window.location.hash;
|
||||||
|
var hashName = hash.substring(1, hash.length);
|
||||||
|
|
||||||
|
if (hashName.startsWith("link-")) {
|
||||||
|
if ("scrollRestoration" in history) {
|
||||||
|
history.scrollRestoration = "manual";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user