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

Feature: Close sidebar when click any blank part (#606) #607

Merged
merged 3 commits into from
Feb 23, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 1 addition & 3 deletions layout/_macro/sidebar.swig
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
</div>

<aside id="sidebar" class="sidebar">
{% if theme.sidebar.onmobile %}
<div id="sidebar-dimmer"></div>
{% endif %}
<div class="sidebar-inner">

{% set display_toc = is_post and theme.toc.enable or is_page and theme.toc.enable %}
Expand Down Expand Up @@ -186,4 +183,5 @@

</div>
</aside>
<div id="sidebar-dimmer"></div>
{% endmacro %}
21 changes: 9 additions & 12 deletions source/css/_common/components/sidebar/sidebar-dimmer.styl
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
.sidebar-active #sidebar-dimmer {
opacity: .7;
-webkit-transform: translateX(-150%);
transform: translateX(-150%);
transition: opacity .2s;
.sidebar-active + #sidebar-dimmer {
+mobile() {
opacity: .7;
transition: opacity .5s;
}
transform: translateX(-100%);
}

#sidebar-dimmer {
display: none;
position: absolute;
display: block;
position: fixed;
top: 0;
left: 100%;
width: 200%;
width: 100%;
height: 100%;
background: #000;
opacity: 0;
transition: opacity .2s,transform 0s .2s;
+mobile() {
display: block;
}
}
2 changes: 1 addition & 1 deletion source/css/_common/components/sidebar/sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
@import "sidebar-blogroll";
@import "sidebar-nav";
@import "sidebar-toc";
@import "sidebar-dimmer" if hexo-config('sidebar.onmobile');
@import "sidebar-dimmer";