-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathScrollPageModule.js
More file actions
25 lines (21 loc) · 828 Bytes
/
ScrollPageModule.js
File metadata and controls
25 lines (21 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
let tx_scroll_module = document.querySelector('body > .module');
if (TYPO3.settings.cache) {
// v13
tx_scroll_module = document.querySelector('body > .module > .module-body');
}
/* Prevents jumping after reload*/
window.location.hash = '';
const uid = new URL(window.location.href).searchParams.get('id') ?? '0';
window.addEventListener('unload', function () {
sessionStorage.setItem('ext-scroll-pages-' + uid, tx_scroll_module.scrollTop);
});
const pos = parseInt(sessionStorage.getItem('ext-scroll-pages-' + uid));
if (pos) {
tx_scroll_module.scrollTo(0, pos);
// This happens, when the clipboard in V11 (loaded via AJAX) is appearing
if (pos !== tx_scroll_module.scrollTop) {
window.addEventListener('load', function () {
tx_scroll_module.scrollTo(0, pos);
});
}
}