Skip to content

Commit

Permalink
Merge pull request #989 from Araxeus/in-app-menu-draggable-navbar
Browse files Browse the repository at this point in the history
[in-app-menu] make navbar draggable
  • Loading branch information
th-ch authored Feb 12, 2023
2 parents 34f56df + 333b695 commit 6577bcd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugins/in-app-menu/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@ 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 => {
$('#nav-bar-background').style.webkitAppRegion =
mutations[0].target.opened ? 'no-drag' : 'drag';
});
searchOpenObserver.observe($('ytmusic-search-box'), { attributeFilter: ["opened"] })
}

function setNavbarMargin() {
$('#nav-bar-background').style.right =
$('ytmusic-app-layout').playerPageOpen_ ?
Expand Down
12 changes: 12 additions & 0 deletions plugins/in-app-menu/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,15 @@ yt-page-navigation-progress,
.cet-menubar-menu-container .cet-action-item {
background-color: inherit
}

#nav-bar-background {
-webkit-app-region: drag;
}

ytmusic-nav-bar input,
ytmusic-nav-bar span,
ytmusic-nav-bar [role="button"],
ytmusic-nav-bar yt-icon,
tp-yt-iron-dropdown {
-webkit-app-region: no-drag;
}

0 comments on commit 6577bcd

Please sign in to comment.