Skip to content

Commit

Permalink
feat: Add the icon that prompt to scroll down in the header of site
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib committed Nov 4, 2019
1 parent 7933d46 commit c05223a
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ header:
enable: false
# Opacity of mask (value: 0 ~ 1).
opacity: 0.5
# The icon that prompt to scroll down.
scroll_down_icon:
enable: false
animation: true

# Creative Commons 4.0 International License.
creative_commons:
Expand Down
8 changes: 8 additions & 0 deletions layout/_partials/config.pug
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
});
}
var header = "undefined";
if (theme.header) {
header = JSON.stringify({
scrollDownIcon: theme.header.scroll_down_icon.enable,
});
}
var gallery_waterfall = "undefined";
if (theme.gallery_waterfall.enable) {
gallery_waterfall = JSON.stringify(theme.gallery_waterfall);
Expand Down Expand Up @@ -88,6 +95,7 @@ script.
algolia: !{ algolia },
fontawesome: !{ fontawesome },
sidebar: !{ sidebar },
header: !{ header },
back2top: !{ back2top },
reward: !{ theme.reward.enable },
fancybox: !{ theme.fancybox },
Expand Down
4 changes: 4 additions & 0 deletions layout/_partials/header/header.pug
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ div.header-info(style=`${
div.header-info-inner
div.header-info-title= config.title
div.header-info-subtitle= config.subtitle

if theme.header.scroll_down_icon && theme.header.scroll_down_icon.enable
div.header-info-scrolldown
i.fa.fa-angle-down.header-info-scrolldown__icon
1 change: 1 addition & 0 deletions layout/_third-party/pjax.pug
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ script.

Stun.utils.pjaxReloadBoot();
Stun.utils.pjaxReloadScroll();
Stun.utils.pjaxReloadHeader();
Stun.utils.pjaxReloadSidebar();
}, false);
}, false);
35 changes: 35 additions & 0 deletions source/css/_common/components/header/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,40 @@ if (hexo-config('header.nav_height') && match('%', hexo-config('header.nav_heigh
font-weight: $font-weight-normal;
color: $white-light;
}

if (hexo-config('header.scroll_down_icon') && hexo-config('header.scroll_down_icon.enable')) {
&-scrolldown {
position: absolute;
bottom: 0;
left: 50%;
z-index: $z-index2;
transform: translate3d(-50%, -.5rem, 0);
cursor: pointer;

if (hexo-config('header.scroll_down_icon.animation')) {
animation: arrowUpDown 1.5s infinite;

@keyframes arrowUpDown {
0%,
100% {
opacity: .8;
transform: translate3d(-50%, -.5rem, 0);
}

50% {
opacity: .4;
transform: translate3d(-50%, -1.5rem, 0);
}
}
}

&__icon {
font-size: 2rem;
font-weight: $font-weight-bolder;
text-align: center;
color: #fff;
}
}
}
}
}
13 changes: 13 additions & 0 deletions source/js/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,17 @@ $(document).ready(function () {

$submenu.length && $submenu.css('display', 'none');
});

Stun.utils.pjaxReloadHeader = function () {
if (CONFIG.header.scrollDownIcon) {
$('.header-info-scrolldown').on('click', function () {
$('#container').velocity('scroll', {
offset: $('#header').height()
});
});
}
};

// Initializaiton
Stun.utils.pjaxReloadHeader();
});

0 comments on commit c05223a

Please sign in to comment.