mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
Cookbook auto-fold: target the actual scroll container (.cookbook-body)
Previous .modal-body / .cookbook-content lookup matched neither the desktop scroller (.cookbook-body) nor the mobile one (#cookbook-modal .modal-content), so the scroll listener was attached to document.body and never fired. Walk up to whichever scroller actually exists.
This commit is contained in:
@@ -1416,17 +1416,20 @@ function _wireTabEvents(body) {
|
|||||||
_setFolded(!folded);
|
_setFolded(!folded);
|
||||||
});
|
});
|
||||||
// Auto-fold when the user scrolls past the Direct Download header.
|
// Auto-fold when the user scrolls past the Direct Download header.
|
||||||
// Watches the header element: once its bottom edge passes above the
|
// Desktop scroll container is .cookbook-body; mobile is the modal
|
||||||
// scroll container's top, fold the body so the scan section below has
|
// .modal-content. Walk up via .closest() to find whichever is
|
||||||
// the full viewport. Doesn't auto-unfold (user can click ▸ to expand).
|
// actually scrollable. Doesn't auto-unfold — chevron ▸ still
|
||||||
const _scrollHost = dlFold.closest('.modal-body, .cookbook-content, .doclib-modal-content') || document.scrollingElement || document.body;
|
// expands manually.
|
||||||
let _autoFolded = false;
|
const _scrollHost = dlFold.closest('.cookbook-body')
|
||||||
|
|| dlFold.closest('#cookbook-modal .modal-content')
|
||||||
|
|| dlFold.closest('.modal-content')
|
||||||
|
|| document.scrollingElement
|
||||||
|
|| document.body;
|
||||||
const _onScroll = () => {
|
const _onScroll = () => {
|
||||||
if (dlFoldBody.style.display === 'none') return;
|
if (dlFoldBody.style.display === 'none') return;
|
||||||
const r = dlFold.getBoundingClientRect();
|
const r = dlFold.getBoundingClientRect();
|
||||||
const top = (_scrollHost && _scrollHost.getBoundingClientRect) ? _scrollHost.getBoundingClientRect().top : 0;
|
const top = (_scrollHost && _scrollHost.getBoundingClientRect) ? _scrollHost.getBoundingClientRect().top : 0;
|
||||||
if (r.bottom < top + 4) {
|
if (r.bottom < top + 4) {
|
||||||
_autoFolded = true;
|
|
||||||
_setFolded(true, /* persist */ false);
|
_setFolded(true, /* persist */ false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user