Skip to content

Commit

Permalink
fix: Submenu is not hidden after the mouse passes over it
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib committed Feb 6, 2020
1 parent d0dc5e1 commit 576f177
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions source/css/_common/components/header/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ if (hexo-config('header.nav.height') && match('%', hexo-config('header.nav.heigh
width: auto;
background-color: $header-nav-bg-color;

&.hide {
&--force {
display: none !important;
}
}

&-item {
margin: 0;
padding: 0;
Expand Down
15 changes: 10 additions & 5 deletions source/js/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ $(document).ready(function () {
'resize',
Stun.utils.throttle(function () {
isMobile = $menuBtn.is(':visible');
if (isMobile && isSubmenuShow) {
resetMenuHeight();
isSubmenuShow = false;
if (isMobile) {
$submenu.removeClass('hide--force');

if (isSubmenuShow) {
resetMenuHeight();
isSubmenuShow = false;
}
} else {
$submenu.css({ display: 'none', opacity: 0 });
}
Expand Down Expand Up @@ -158,6 +162,7 @@ $(document).ready(function () {
if (isMobile) {
$submenu.css({ display: 'block', opacity: 1 });
} else {
$submenu.removeClass('hide--force');
$submenu
.velocity('stop')
.velocity('transition.slideUpIn', { duration: 200 });
Expand All @@ -170,8 +175,8 @@ $(document).ready(function () {
if (!$submenu.length) {
return;
}
if ($submenu.is(':visible') && !isMobile) {
$submenu.css({ display: 'none', opacity: 0 });
if (!isMobile) {
$submenu.addClass('hide--force');
isSubmenuShow = false;
}
});
Expand Down

0 comments on commit 576f177

Please sign in to comment.