remove draggable attribute if search box is open

This commit is contained in:
Araxeus
2023-01-19 19:16:01 +02:00
parent b665343fd9
commit c6bb0cfe88

View File

@ -43,9 +43,21 @@ module.exports = (options) => {
setNavbarMargin();
const playPageObserver = new MutationObserver(setNavbarMargin);
playPageObserver.observe($('ytmusic-app-layout'), { attributeFilter: ['player-page-open_', 'playerPageOpen_'] })
setupSearchOpenObserver();
}, { once: true, passive: true })
};
function setupSearchOpenObserver() {
const searchOpenObserver = new MutationObserver(mutations => {
if (mutations[0].target.opened) {
$('#nav-bar-background').style.webkitAppRegion = 'no-drag'
} else {
$('#nav-bar-background').style.webkitAppRegion = 'drag'
}
});
searchOpenObserver.observe($('ytmusic-search-box'), { attributeFilter: ["opened"] })
}
function setNavbarMargin() {
$('#nav-bar-background').style.right =
$('ytmusic-app-layout').playerPageOpen_ ?