mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-06 10:46:34 +03:00
Merge commit 'a024bc7d76
'
This commit is contained in:
commit
304a7e5e74
817 changed files with 5301 additions and 14766 deletions
17
docs/assets/js/helpers/helpers.js
Normal file
17
docs/assets/js/helpers/helpers.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
export const scrollToActive = (when) => {
|
||||
let els = document.querySelectorAll('.scroll-active');
|
||||
if (!els.length) {
|
||||
return;
|
||||
}
|
||||
els.forEach((el) => {
|
||||
// Find scrolling container.
|
||||
let container = el.closest('[data-turbo-preserve-scroll-container]');
|
||||
if (container) {
|
||||
// Avoid scrolling if el is already in view.
|
||||
if (el.offsetTop >= container.scrollTop && el.offsetTop <= container.scrollTop + container.clientHeight) {
|
||||
return;
|
||||
}
|
||||
container.scrollTop = el.offsetTop - container.offsetTop;
|
||||
}
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue