Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options for sidebar Hide when clicking background #1496

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ sidebar:
offset: 12
# Enable sidebar on narrow view (only for Muse | Mist).
onmobile: false
# Click any blank part of the page to close sidebar (only for Muse | Mist).
dimmer: true

# Sidebar Avatar
avatar:
Expand Down
7 changes: 5 additions & 2 deletions source/js/schemes/muse.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ window.addEventListener('DOMContentLoaded', () => {
mousePos.Y = event.pageY;
},
mouseupHandler: function(event) {
var isdimmer = CONFIG.sidebar.dimmer;
var deltaX = event.pageX - mousePos.X;
var deltaY = event.pageY - mousePos.Y;
var clickingBlankPart = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY)) < 20 && event.target.matches('.main');
if (this.isSidebarVisible && (clickingBlankPart || event.target.matches('img.medium-zoom-image, .fancybox img'))) {
this.hideSidebar();
if (isdimmer) {
if (this.isSidebarVisible && (clickingBlankPart || event.target.matches('img.medium-zoom-image, .fancybox img'))) {
this.hideSidebar();
}
}
},
clickHandler: function() {
Expand Down