File tree Expand file tree Collapse file tree 9 files changed +55
-14
lines changed
Expand file tree Collapse file tree 9 files changed +55
-14
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,8 @@ sidebar:
206206
207207 # Scroll percent label in b2t button
208208 scrollpercent : false
209+ # Enable sidebar on narrow view
210+ onmobile : false
209211
210212
211213# Blog rolls
Original file line number Diff line number Diff line change 88 </div>
99
1010 <aside id=" sidebar" class =" sidebar" >
11+ <div id=" sidebar-dimmer" ></div>
1112 <div class =" sidebar-inner" >
1213
1314 {% set display_toc = is_post and theme.toc .enable or is_page and theme.toc .enable %}
Original file line number Diff line number Diff line change 1111 the-transition ();
1212 & :hover { opacity : 0.8 ; }
1313
14- + mobile () {
15- display : none ;
16- }
1714 + tablet () {
18- display : none ;
15+ fixbutton () if hexo-config ('sidebar.onmobile' );
16+ hide () if not hexo-config ('sidebar.onmobile' );
17+ }
18+ + mobile () {
19+ fixbutton () if hexo-config ('sidebar.onmobile' );
20+ hide () if not hexo-config ('sidebar.onmobile' );
1921 }
2022
2123 & .back-to-top-on {
Original file line number Diff line number Diff line change 1616 transition-property : bottom ;
1717 the-transition ();
1818
19- + mobile () {
20- display : none ;
21- }
2219 + tablet () {
23- display : none ;
20+ fixbutton () if hexo-config ('sidebar.onmobile' );
21+ hide () if not hexo-config ('sidebar.onmobile' );
22+ }
23+ + mobile () {
24+ fixbutton () if hexo-config ('sidebar.onmobile' );
25+ hide () if not hexo-config ('sidebar.onmobile' );
2426 }
2527
2628 & .back-to-top-on {
Original file line number Diff line number Diff line change 1+ .sidebar-active #sidebar-dimmer {
2+ opacity : .7 ;
3+ -webkit- transform : translateX (- 150% );
4+ transform : translateX (- 150% );
5+ transition : opacity .2s ;
6+ }
7+
8+ #sidebar-dimmer {
9+ display : none ;
10+ position : absolute ;
11+ top : 0 ;
12+ left : 100% ;
13+ width : 200% ;
14+ height : 100% ;
15+ background : #0 0 0 ;
16+ opacity : 0 ;
17+ transition : opacity .2s ,transform 0s .2s ;
18+ + mobile () {
19+ display : block ;
20+ }
21+ }
Original file line number Diff line number Diff line change 1212 -webkit- transform : translateZ (0 );
1313
1414 + tablet () {
15- display : none ;
15+ fixbutton () if hexo-config ('sidebar.onmobile' );
16+ hide () if not hexo-config ('sidebar.onmobile' );
1617 }
1718 + mobile () {
18- display : none ;
19+ fixbutton () if hexo-config ('sidebar.onmobile' );
20+ hide () if not hexo-config ('sidebar.onmobile' );
1921 }
2022}
2123
Original file line number Diff line number Diff line change 1717 }
1818
1919 + tablet () {
20- display : none !important ;
20+ hide () if not hexo-config ( 'sidebar.onmobile' ) ;
2121 }
2222 + mobile () {
23- display : none !important ;
23+ hide () if not hexo-config ( 'sidebar.onmobile' ) ;
2424 }
25+
2526}
2627
2728.sidebar-inner {
3637@import "site-state" ;
3738@import "sidebar-feed-link" ;
3839@import "sidebar-author-links" ;
39- @import "sidebar-blogroll.styl " ;
40+ @import "sidebar-blogroll" ;
4041@import "sidebar-nav" ;
4142@import "sidebar-toc" ;
42-
43+ @import "sidebar-dimmer" ;
Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ transform() {
4040 transform : arguments
4141}
4242
43+ hide () {
44+ display : none !important ;
45+ }
46+
47+ fixbutton () {
48+ right : 20px ;
49+ opacity : 0.8 ;
50+ }
4351
4452random-color ($min , $max ) {
4553 return floor (math (0 , 'random' ) * ($max - $min + 1 ) + $min );
Original file line number Diff line number Diff line change @@ -82,10 +82,12 @@ $(document).ready(function () {
8282
8383 var sidebarToggleMotion = {
8484 toggleEl : $ ( '.sidebar-toggle' ) ,
85+ dimmerEl : $ ( '#sidebar-dimmer' ) ,
8586 sidebarEl : $ ( '.sidebar' ) ,
8687 isSidebarVisible : false ,
8788 init : function ( ) {
8889 this . toggleEl . on ( 'click' , this . clickHandler . bind ( this ) ) ;
90+ this . dimmerEl . on ( 'click' , this . clickHandler . bind ( this ) ) ;
8991 this . toggleEl . on ( 'mouseenter' , this . mouseEnterHandler . bind ( this ) ) ;
9092 this . toggleEl . on ( 'mouseleave' , this . mouseLeaveHandler . bind ( this ) ) ;
9193
You can’t perform that action at this time.
0 commit comments