|
@@ -23,7 +23,7 @@ const registerOnScrollEvent = (function(){
|
|
// Media query handler.
|
|
// Media query handler.
|
|
return function(mediaQuery) {
|
|
return function(mediaQuery) {
|
|
// We only apply this logic to the "desktop" resolution (defined by a media query at the bottom).
|
|
// We only apply this logic to the "desktop" resolution (defined by a media query at the bottom).
|
|
- // This handler is executed when the result of the query evaluation changes, which means that
|
|
|
|
|
|
+ // This handler is executed when the result of the query evaluation changes, which means that
|
|
// the page has moved between "desktop" and "mobile" states.
|
|
// the page has moved between "desktop" and "mobile" states.
|
|
|
|
|
|
// When entering the "desktop" state, we register scroll events and adjust elements on the page.
|
|
// When entering the "desktop" state, we register scroll events and adjust elements on the page.
|
|
@@ -57,7 +57,7 @@ const registerOnScrollEvent = (function(){
|
|
$menu.css('max-height', `calc(100% - ${menuHeightOffset_fixed}px)`);
|
|
$menu.css('max-height', `calc(100% - ${menuHeightOffset_fixed}px)`);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- // Between the top of the page and the threshold we calculate intermediate values
|
|
|
|
|
|
+ // Between the top of the page and the threshold we calculate intermediate values
|
|
// to guarantee a smooth transition.
|
|
// to guarantee a smooth transition.
|
|
$search.css('margin-top', `-${currentScroll}px`);
|
|
$search.css('margin-top', `-${currentScroll}px`);
|
|
$menu.css('margin-top', `${menuTopMargin + (scrollTopPixels - currentScroll)}px`);
|
|
$menu.css('margin-top', `${menuTopMargin + (scrollTopPixels - currentScroll)}px`);
|
|
@@ -138,12 +138,12 @@ const registerOnScrollEvent = (function(){
|
|
};
|
|
};
|
|
})();
|
|
})();
|
|
|
|
|
|
-// Subscribe to DOM changes in the sidebar container, because there is a
|
|
|
|
|
|
+// Subscribe to DOM changes in the sidebar container, because there is a
|
|
// banner that gets added at a later point, that we might not catch otherwise.
|
|
// banner that gets added at a later point, that we might not catch otherwise.
|
|
const registerSidebarObserver = (function(){
|
|
const registerSidebarObserver = (function(){
|
|
return function(callback) {
|
|
return function(callback) {
|
|
const sidebarContainer = document.querySelector('.wy-side-scroll');
|
|
const sidebarContainer = document.querySelector('.wy-side-scroll');
|
|
-
|
|
|
|
|
|
+
|
|
let sidebarEthical = null;
|
|
let sidebarEthical = null;
|
|
const registerEthicalObserver = () => {
|
|
const registerEthicalObserver = () => {
|
|
if (sidebarEthical) {
|
|
if (sidebarEthical) {
|
|
@@ -164,16 +164,16 @@ const registerSidebarObserver = (function(){
|
|
if (mutation.type !== 'childList') {
|
|
if (mutation.type !== 'childList') {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
callback();
|
|
callback();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
const ethicalObserver = new MutationObserver(ethicalObserverCallback);
|
|
const ethicalObserver = new MutationObserver(ethicalObserverCallback);
|
|
ethicalObserver.observe(sidebarEthical, ethicalObserverConfig);
|
|
ethicalObserver.observe(sidebarEthical, ethicalObserverConfig);
|
|
};
|
|
};
|
|
registerEthicalObserver();
|
|
registerEthicalObserver();
|
|
-
|
|
|
|
|
|
+
|
|
// This observer watches over direct children of the main sidebar container.
|
|
// This observer watches over direct children of the main sidebar container.
|
|
const observerConfig = { childList: true };
|
|
const observerConfig = { childList: true };
|
|
const observerCallback = (mutationsList, observer) => {
|
|
const observerCallback = (mutationsList, observer) => {
|
|
@@ -181,12 +181,12 @@ const registerSidebarObserver = (function(){
|
|
if (mutation.type !== 'childList') {
|
|
if (mutation.type !== 'childList') {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
callback();
|
|
callback();
|
|
registerEthicalObserver();
|
|
registerEthicalObserver();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
const observer = new MutationObserver(observerCallback);
|
|
const observer = new MutationObserver(observerCallback);
|
|
observer.observe(sidebarContainer, observerConfig);
|
|
observer.observe(sidebarContainer, observerConfig);
|
|
};
|
|
};
|
|
@@ -194,7 +194,7 @@ const registerSidebarObserver = (function(){
|
|
|
|
|
|
$(document).ready(() => {
|
|
$(document).ready(() => {
|
|
const mediaQuery = window.matchMedia('only screen and (min-width: 769px)');
|
|
const mediaQuery = window.matchMedia('only screen and (min-width: 769px)');
|
|
-
|
|
|
|
|
|
+
|
|
registerOnScrollEvent(mediaQuery);
|
|
registerOnScrollEvent(mediaQuery);
|
|
mediaQuery.addListener(registerOnScrollEvent);
|
|
mediaQuery.addListener(registerOnScrollEvent);
|
|
|
|
|