【问题标题】:Menu is not closing on click单击时菜单未关闭
【发布时间】:2018-02-15 15:51:38
【问题描述】:

我有一个单击菜单,将使用 TimelineMax 启动动画。当我单击菜单时,它会正确启动菜单和动画。即使关闭动画也会正确触发。但是,我注意到当动画完成并且菜单被“隐藏”时,菜单实际上并没有隐藏,它覆盖了网站。发生这种情况时,页面上的任何链接都无法点击,因为菜单结构覆盖了它。例如,我从两个面板中删除了动画,但动画仍然存在于其他所有内容中。您将看到加载 jsfiddle 时,除了菜单按钮之外看不到任何链接。单击菜单按钮后,将显示菜单。当您关闭它时,您会看到 Contact 和 follow 仍然存在。但是,即使您看不到其他按钮,它们仍然存在。

当您单击具有打开的隐藏导航容器类的菜单时,我尝试了几种变体,但这不起作用。所以根据我的代码,我的菜单在关闭时不再可见。

更新 Nav-link 控制动画,但为了显示你想要我的意思是我删除了 nav-link 并放置了 nav-link1。

$(document).ready(function(Circ) {
	"use strict";
	$('.nav-container').addClass('hidden');
	var blocks = $('.block-reveal'),
		menuButton = $('.hamburger'),
		menuLinks = $('.nav-link');
	var blockAnimation = new TimelineMax({
		paused: true,
		reversed: true
	});
	blockAnimation.staggerTo(blocks, 0.4, {
		width: '100%',
		ease: Circ.easeInOut
	}, 0.08).staggerFromTo(menuLinks, 0.7, {
		y: 20,
		autoAlpha: 0,
		ease: Circ.easeInOut
	}, {
		y: 0,
		autoAlpha: 1
	}, 0.1);
	menuButton.click(function() {
		blockAnimation.reversed() ? blockAnimation.play() : blockAnimation.reverse();
		$('.hamburger').toggleClass('opened');
		$("a.header-logo").toggleClass('header-logo-open');
        $(".start-project").toggleClass('start-project-black');
		$('.header-logo-open').fadeIn(1000);
		$('.nav-container').removeClass('hidden'); 
					 
	});
	
	
});
/*--------------------------------------------------------------
# Elements
--------------------------------------------------------------*/
html {
	box-sizing: border-box;
}

*,
*:before,
*:after {
	box-sizing: inherit;
}

body {
	background: #FFF;
}

blockquote, q {
	quotes: "" "";
}

blockquote:before, blockquote:after, q:before, q:after {
	content: "";
}



/*--------------------------------------------------------------
# Clearings
--------------------------------------------------------------*/
.clear:before,
.clear:after,
.entry-content:before,
.entry-content:after,
.comment-content:before,
.comment-content:after,
.site-header:before,
.site-header:after,
.site-content:before,
.site-content:after,
.site-footer:before,
.site-footer:after {
	content: "";
	display: table;
	table-layout: fixed;
}

.clear:after,
.entry-content:after,
.comment-content:after,
.site-header:after,
.site-content:after,
.site-footer:after {
	clear: both;
}


/*HEADER / MENU
--------------------------------------------------------------------------------------------------------------
============================================================================================================*/

.main-header .header-logo {
	float: left
}
.main-header {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	padding: 30px;
	z-index: 100;
	


}
.header-logo {
	display: block;
	float: left;
	width: 150px;
	height: 100px;
	overflow: hidden;
	text-indent: -9999em;
	pointer-events: auto;
}
a.header-logo {
	background: url(lib/img/fe-logo.svg) no-repeat;
}
a.header-logo-open {
	background: url(lib/img/fe-logo-black.svg) no-repeat;
	display: none;
}



a.start-project {position: absolute; right: 6%; color: #FFF; text-decoration: none; font-size: .9em}
a.start-project-black {position: absolute; right: 6%; color: #000; text-decoration: none; font-size: .9em}

nav {
	width: 100vw;
	z-index: 90;
	position: relative;
}
.menu {
	background: #FFF;
	position: fixed;
	padding: 20px 30px;
	top: 50px;
	right: 20px;
	z-index: 100;
}

.block-reveal {
	background:rgba(255,255,255,1.00);
	height: 100vh;
	position: fixed;
}
#block__01 {
	right: 0%;
}

.nav-container {
	position: fixed;
	width: 80%;
	left: 10%;
	top: 20%;
	text-align: left;
}
ul.main-menu {width:60%}
ul.main-menu, ul.small-menu {
	list-style-type: none;
	margin: 0;
	padding: 0;
}
ul.small-menu {
	margin-top: 1em;
	width: 80%;
}

p.follow_title {
	color: #262626;
	margin-top: .4em;
}

@media (max-width:800px){ul.small-menu {width: 100%;}p.follow_title {margin-top: .2em;}}

ul.main-menu li {
	font-size: 6em;
	line-height: .9em
}

@media (max-height:800px){.nav-container {top: 15%;}ul.main-menu li {font-size: 4em;}}
@media (max-width:800px) {.nav-container {top: 30%;}ul.main-menu li {font-size: 4em;}}

ul.main-menu li a {
	font-weight: 800;
	color: #101317;
	text-transform: uppercase;
	text-decoration: none
}

ul.main-menu li a:before{
	content: '';
	width: 0%;
	height: 15px;
	background: #101317;
	position: absolute;
	top: 40px;
	left: -5px;
	transition-timing-function: cubic-bezier(.8,.09,1,.44);
	transition-delay: 400ms;
	transition: all 600ms cubic-bezier(1, 0, 0, 1) 0ms;
}

ul.main-menu li a:hover:before{
	content: '';
	width: 100%;
	height: 15px;
	position: absolute;
	top: 40px;
	left: -5px;
	z-index: -1;
}

@media (max-height:800px){ul.main-menu li a:before{top: 25px;}ul.main-menu li a:hover:before{top: 25px;}}















.project-thumb {
  position: relative;
  display: inline-block;
  overflow: hidden;
  margin: 1px;
  width: 32%;
	height: 200px;
  background-color: #000000;
  color: #ffffff;
  text-align: left;
}
.project-thumb * {
  -webkit-transition: all 0.35s;
  transition: all 0.35s;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
.project-thumb img {
  max-width: 100%;
	width: 100%;
  vertical-align: top;
}
.project-thumb div {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  background-image: -webkit-linear-gradient(bottom, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  background-image: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.project-thumb h4 {
  font-size: 1.3em;
	text-transform: uppercase;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 1px;
  margin: 3px 0;
}

.project-thumb a {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}
.project-thumb:hover img,
.project-thumb.hover img {
  -webkit-transform: scale(1.3) rotate(5deg);
  transform: scale(1.3) rotate(5deg);
}













ul.small-menu li a:hover, ul.project-menu li a:hover {
	color: #f15c57;
}
ul.small-menu li {
	float: left;
	padding-right: .8em;
}
ul.small-menu li a {
	text-decoration: none;
	color: #4e4d4d;
	font-size: 2em;
}
ul.project-menu {
	padding-top: 2em;
	margin: 0;
	position: fixed;
	bottom: 0;
	width: 80%
}
@media (max-height:600px){ul.project-menu {display: none}}

@media (max-width:800px){ul.project-menu {display: none}}

ul.project-menu li {
	list-style: none;
	padding-bottom: .6em
}
ul.project-menu p {font-size: 1.3em; font-weight: 900;}



#particle-canvas {
  width: 100%;
  height: 100%;
}

ul.project-menu li a {
	text-decoration: none;
	color: #4e4d4d;
}
.hamburger {
	width: 30px;
	height: 45px;
	position: absolute;
	right: 3%;
	margin-left: -25px;
	top: 34%;
	margin-top: -22.5px;
	cursor: pointer;
}
.hamburger span {
	display: block;
	position: absolute;
	height: 1px;
	width: 100%;
	background: #FFF none repeat scroll 0% 0%;
	opacity: 1;
	right: 0px;
	transition: all 0.25s ease-in-out 0s;
	transform: rotate(0deg);
}
.hamburger span:nth-child(1) {
	margin-top: 0px;
}
.hamburger span:nth-child(2) {
	margin-top: 8px;
	margin-right: 0px;
}
.hamburger span:nth-child(3) {
	margin-top: 16px;
}
.hamburger.opened span:nth-child(1) {
	transform: rotate(135deg);
	margin-top: 16px;
}
.hamburger.opened span:nth-child(2) {
	opacity: 0;
	right: -75px;
}
.hamburger.opened span:nth-child(3) {
	transform: rotate(-135deg);
	margin-top: 16px;
}
.hamburger.opened span {
	background: #f15c57 none repeat scroll 0% 0%;
}



.icon
 {
 width: 45px;
	 height: 45px;
	 display: block;
    margin: 0 auto
}
@media (max-width:800px){.icon
 {
 width: 35px;
	 height: 35px;
	 display: block;
    margin: 0 auto
}}

.icon-facebook,
.icon-twitter,
.icon-linkedin{
  fill: #262626;
}
.icon-facebook {width: 30px}
.icon-facebook :hover {
  fill: #3b5998;
}
.icon-twitter :hover {
  fill: #00acee;
}
.icon-linkedin :hover {
  fill: #007fb2;
}
/*BODY
--------------------------------------------------------------------------------------------------------------
============================================================================================================*/

.right-v {
	position: absolute;
	top: 50%;
	right: 0;
	transform: rotate(90deg);
	transform-origin: left top 0;
	z-index: 1;
}
@media (max-width:800px) {
	.right-v {
		display: none;
	}
}
.lb {
	color: #FFF;
}
.pd {
	font-family: 'Gilda Display', serif;
}
#wwa {
	font-size: .7em;
	text-transform: uppercase
}
.hidden, .show-mobile {
    display: none;
}

/*FOOTER
--------------------------------------------------------------------------------------------------------------
============================================================================================================*/

footer.home-footer {
	position: fixed;
	bottom: 0;
	right: 2%;
	z-index: 1;
}
.bottom-panel {
	color: #FFF;
	font-size: .9em
}
.bottom-panel ul {
	list-style: none;
	padding: 0;
	margin: 0;
}
.bottom-panel ul li {
	display: inline-block;
	margin: 0;
}
.call {
	padding-bottom: .5em;
}
li.social a {
	border-bottom: 4px solid #FFF;
	padding: 0 .5em 0em .5em;
	color: #FFF;
	text-decoration: none
}
li.social a:hover {
	border-bottom: 4px solid #f15c57;
}
li.social:nth-child(2) {
	margin-left: 1em !important;
}

/*HOME PANEL
--------------------------------------------------------------------------------------------------------------
============================================================================================================*/

.overlay {background: #101317; position: relative; width: 100%; height: 100vh;}

.container-fluid {
	margin-left: auto;
	margin-right: auto;
	overflow: hidden;

}
.banner-container {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: -100;

}



span.left-panel-load {
	position: absolute;
	top: 65%;
	left: 2%;
	transform: rotate(270deg);
	transform-origin: left top 0;
	z-index: 9;
	text-transform: uppercase;
	color: #FFF;
	font-weight: bold;
	font-family: 'Lato', sans-serif;
	font-size: .7em;
	letter-spacing: .1em;
}

.slider-wrapper, .slider-inner {
	position: absolute;
	height: 100%;
	width: 100%;
}

#finalelements {
	background: url(lib/img/home-banner.jpg) no-repeat center center;
	width: 100%;
	-webkit-background-size: cover;
	-moz-background-size: cover;
	-o-background-size: cover;
	background-size: cover;
}

.slider-content {
	position: relative;
	width: 40%;
	max-width: 500px;
	left: 50%;
	top: 50%;
	-webkit-transform: translate(-50%, -50%);
	transform: translate(-50%, -50%);
	font-family: 'Lato', sans-serif;
	border-style: solid;
    border-width: 70px;
    border-image: url(lib/img/border.png) 60 round;
}

.slider-content h1, .slider-content h3 {
	font-family: 'Lato', sans-serif;
	text-transform: uppercase;
}

.slider-content h1 {
	font-size: 6em;
	line-height: .8em;
	margin: 0;
	font-weight: 900 !important;
	color: #ef0c33;
	
}

.slider-content h1 strong { color: #FFF;}

.slider-content h3 {font-weight: 300; margin-top: .8em}
.slider-content h3 {
	line-height: .7em;
}
.slider-content p {
	padding-top: 2em;
	width: 90%;
	
}





.slider-content h4 {
	padding-top: 2em;
	font-family: 'Lato', sans-serif;
	text-transform: uppercase;
	font-weight: 100;
}
.distress {
	background: url(lib/img/texture.png);
	width: 95%;
	height: 95%;
	position: absolute;
	top: 0;
}
.red-line {
	width: 25%;
	height: 1px;
	background: #f0625d;
	background: -moz-linear-gradient(left, transparent 0%, #ad1f23 100%);
	background: -webkit-linear-gradient(left, transparent 0%, #ad1f23 100%);
	background: linear-gradient(to right, transparent 0%, #ad1f23 100%);
	filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='transparent', endColorstr='#ad1f23', GradientType=1);
	position: absolute;
	top: 50%;
	margin-left: 1em;
}

@media (max-width:800px) {
	.slider-content, .slider-content p {width: 80%}
	.slider-content h1 { font-size: 5em;}
}





.hp-content {padding: 7em; display: block;}
.hp-inner {width: 60% !important; margin: 0 auto;}
.hp-inner img {width: 20%;}
.hp-inner h2 {line-height: 1em; font-size: 4em;}




.hp-inner h2::after {
	 content:"";
    display: block;
    height: 0.1em;
    vertical-align: bottom;
    width: 20%;
	background: #ef0c33;
	margin: 1em 0 1em 0;
}

.hp-image {background: url(lib/img/capital.jpg)no-repeat center center;
	width: 100%;
	-webkit-background-size: cover;
	-moz-background-size: cover;
	-o-background-size: cover;
	background-size: cover;}

.hp-inner ul { list-style: none; margin: 0; padding: 0;}
.hp-inner ul li { display: inline-block; padding: 1em 2em 1em 0;}
.hp-inner ul li p {font-size: .8em;}
.hp-inner ul li a {background: #ef0c33; color: #FFF; text-decoration: none; padding: .6em}


.center {text-align: center}

.dark-bg {background: #e3e3e3; display: block; position: relative; padding: 5em 0 5em 0}


.service-panel h2 {text-align: center; margin-bottom: 1em}

.service-panel h2::after {
	 content:"";
    display: block;
    height: 0.1em;
    vertical-align: bottom;
    width: 10%;
	background: #ef0c33;
	margin: 0 auto;
}
.service-panel p {text-align: center}
.service-panel span {font-weight: 900; font-size: 3em;}
.service-grid {padding: 2em;}
.service-grid h4 {font-weight: 900; font-size: 1.3em}
.service-grid p {font-size: .9em; margin-top: .8em}


.nav-up {
    top: -40px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.13.1/TweenMax.min.js"></script>
<div class="bg">

</div>
<header class="main-header">
		<div class="header-menu">
  			<div class="hamburger">
        <p>Menu</p>
			</div>
		</div>
	</header>
	<nav class="main-nav">
		<div class="block-reveal" id="block__01"></div>
		<div class="nav-container">
			<ul class="main-menu">
				<li class="nav-link"><a href="#">Agency</a></li>
				<li class="nav-link"><a href="#">Work</a></li>
				<li class="nav-link"><a href="#">Services</a></li>
				<li class="nav-link1"><a href="#">Contact</a></li>
			</ul>
			<ul class="small-menu nav-link1">
				<li><p class="follow_title h3">Follow Us</p></li>
				<li><a href="#0"><svg class="icon icon-facebook"><use xlink:href="#facebook"/></svg></a></li>
				<li><a href="#0"><svg class="icon icon-twitter"><use xlink:href="#twitter"/></svg></a></li>
				<li><a href="#0"><svg class="icon icon-linkedin"><use xlink:href="#linkedin"/></svg></a></li>
			</ul>
			
		</div>
	</nav>
</div>

https://jsfiddle.net/e8oyoLhv/37/

【问题讨论】:

    标签: javascript jquery html css gsap


    【解决方案1】:

    onReverseComplete 上添加blockAnimation.eventCallback 并在回调时隐藏导航

    $(document).ready(function(Circ) {
    	"use strict";
    	$('.nav-container').addClass('hidden');
    	var blocks = $('.block-reveal'),
    		menuButton = $('.hamburger'),
    		menuLinks = $('.nav-link');
    	var blockAnimation = new TimelineMax({
    		paused: true,
    		reversed: true
    	});
    	blockAnimation.staggerTo(blocks, 0.4, {
    		width: '100%',
    		ease: Circ.easeInOut
    	}, 0.08).staggerFromTo(menuLinks, 0.7, {
    		y: 20,
    		autoAlpha: 0,
    		ease: Circ.easeInOut
    	}, {
    		y: 0,
    		autoAlpha: 1
    	}, 0.1);
    	menuButton.click(function() {
    		blockAnimation.reversed() ? blockAnimation.play() : blockAnimation.reverse();
    		$('.hamburger').toggleClass('opened');
    		$("a.header-logo").toggleClass('header-logo-open');
            $(".start-project").toggleClass('start-project-black');
    		$('.header-logo-open').fadeIn(1000);
        $('.nav-container').removeClass('hidden');
    	  
    	});
    	blockAnimation.eventCallback("onReverseComplete", function(e){
        $('.nav-container').addClass('hidden');
      });
    	
    });
    /*--------------------------------------------------------------
    # Elements
    --------------------------------------------------------------*/
    html {
    	box-sizing: border-box;
    }
    
    *,
    *:before,
    *:after {
    	box-sizing: inherit;
    }
    
    body {
    	background: #FFF;
    }
    
    blockquote, q {
    	quotes: "" "";
    }
    
    blockquote:before, blockquote:after, q:before, q:after {
    	content: "";
    }
    
    
    
    /*--------------------------------------------------------------
    # Clearings
    --------------------------------------------------------------*/
    .clear:before,
    .clear:after,
    .entry-content:before,
    .entry-content:after,
    .comment-content:before,
    .comment-content:after,
    .site-header:before,
    .site-header:after,
    .site-content:before,
    .site-content:after,
    .site-footer:before,
    .site-footer:after {
    	content: "";
    	display: table;
    	table-layout: fixed;
    }
    
    .clear:after,
    .entry-content:after,
    .comment-content:after,
    .site-header:after,
    .site-content:after,
    .site-footer:after {
    	clear: both;
    }
    
    
    /*HEADER / MENU
    --------------------------------------------------------------------------------------------------------------
    ============================================================================================================*/
    
    .main-header .header-logo {
    	float: left
    }
    .main-header {
    	position: fixed;
    	top: 0;
    	left: 0;
    	width: 100%;
    	padding: 30px;
    	z-index: 100;
    	
    
    
    }
    .header-logo {
    	display: block;
    	float: left;
    	width: 150px;
    	height: 100px;
    	overflow: hidden;
    	text-indent: -9999em;
    	pointer-events: auto;
    }
    a.header-logo {
    	background: url(lib/img/fe-logo.svg) no-repeat;
    }
    a.header-logo-open {
    	background: url(lib/img/fe-logo-black.svg) no-repeat;
    	display: none;
    }
    
    
    
    a.start-project {position: absolute; right: 6%; color: #FFF; text-decoration: none; font-size: .9em}
    a.start-project-black {position: absolute; right: 6%; color: #000; text-decoration: none; font-size: .9em}
    
    nav {
    	width: 100vw;
    	z-index: 90;
    	position: relative;
    }
    .menu {
    	background: #FFF;
    	position: fixed;
    	padding: 20px 30px;
    	top: 50px;
    	right: 20px;
    	z-index: 100;
    }
    
    .block-reveal {
    	background:rgba(255,255,255,1.00);
    	height: 100vh;
    	position: fixed;
    }
    #block__01 {
    	right: 0%;
    }
    
    .nav-container {
    	position: fixed;
    	width: 80%;
    	left: 10%;
    	top: 20%;
    	text-align: left;
    }
    ul.main-menu {width:60%}
    ul.main-menu, ul.small-menu {
    	list-style-type: none;
    	margin: 0;
    	padding: 0;
    }
    ul.small-menu {
    	margin-top: 1em;
    	width: 80%;
    }
    
    p.follow_title {
    	color: #262626;
    	margin-top: .4em;
    }
    
    @media (max-width:800px){ul.small-menu {width: 100%;}p.follow_title {margin-top: .2em;}}
    
    ul.main-menu li {
    	font-size: 6em;
    	line-height: .9em
    }
    
    @media (max-height:800px){.nav-container {top: 15%;}ul.main-menu li {font-size: 4em;}}
    @media (max-width:800px) {.nav-container {top: 30%;}ul.main-menu li {font-size: 4em;}}
    
    ul.main-menu li a {
    	font-weight: 800;
    	color: #101317;
    	text-transform: uppercase;
    	text-decoration: none
    }
    
    ul.main-menu li a:before{
    	content: '';
    	width: 0%;
    	height: 15px;
    	background: #101317;
    	position: absolute;
    	top: 40px;
    	left: -5px;
    	transition-timing-function: cubic-bezier(.8,.09,1,.44);
    	transition-delay: 400ms;
    	transition: all 600ms cubic-bezier(1, 0, 0, 1) 0ms;
    }
    
    ul.main-menu li a:hover:before{
    	content: '';
    	width: 100%;
    	height: 15px;
    	position: absolute;
    	top: 40px;
    	left: -5px;
    	z-index: -1;
    }
    
    @media (max-height:800px){ul.main-menu li a:before{top: 25px;}ul.main-menu li a:hover:before{top: 25px;}}
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    .project-thumb {
      position: relative;
      display: inline-block;
      overflow: hidden;
      margin: 1px;
      width: 32%;
    	height: 200px;
      background-color: #000000;
      color: #ffffff;
      text-align: left;
    }
    .project-thumb * {
      -webkit-transition: all 0.35s;
      transition: all 0.35s;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
    }
    .project-thumb img {
      max-width: 100%;
    	width: 100%;
      vertical-align: top;
    }
    .project-thumb div {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      padding: 20px;
      background-image: -webkit-linear-gradient(bottom, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
      background-image: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
    }
    .project-thumb h4 {
      font-size: 1.3em;
    	text-transform: uppercase;
      font-weight: 900;
      line-height: 1;
      letter-spacing: 1px;
      margin: 3px 0;
    }
    
    .project-thumb a {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
    }
    .project-thumb:hover img,
    .project-thumb.hover img {
      -webkit-transform: scale(1.3) rotate(5deg);
      transform: scale(1.3) rotate(5deg);
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    ul.small-menu li a:hover, ul.project-menu li a:hover {
    	color: #f15c57;
    }
    ul.small-menu li {
    	float: left;
    	padding-right: .8em;
    }
    ul.small-menu li a {
    	text-decoration: none;
    	color: #4e4d4d;
    	font-size: 2em;
    }
    ul.project-menu {
    	padding-top: 2em;
    	margin: 0;
    	position: fixed;
    	bottom: 0;
    	width: 80%
    }
    @media (max-height:600px){ul.project-menu {display: none}}
    
    @media (max-width:800px){ul.project-menu {display: none}}
    
    ul.project-menu li {
    	list-style: none;
    	padding-bottom: .6em
    }
    ul.project-menu p {font-size: 1.3em; font-weight: 900;}
    
    
    
    #particle-canvas {
      width: 100%;
      height: 100%;
    }
    
    ul.project-menu li a {
    	text-decoration: none;
    	color: #4e4d4d;
    }
    .hamburger {
    	width: 30px;
    	height: 45px;
    	position: absolute;
    	right: 3%;
    	margin-left: -25px;
    	top: 34%;
    	margin-top: -22.5px;
    	cursor: pointer;
    }
    .hamburger span {
    	display: block;
    	position: absolute;
    	height: 1px;
    	width: 100%;
    	background: #FFF none repeat scroll 0% 0%;
    	opacity: 1;
    	right: 0px;
    	transition: all 0.25s ease-in-out 0s;
    	transform: rotate(0deg);
    }
    .hamburger span:nth-child(1) {
    	margin-top: 0px;
    }
    .hamburger span:nth-child(2) {
    	margin-top: 8px;
    	margin-right: 0px;
    }
    .hamburger span:nth-child(3) {
    	margin-top: 16px;
    }
    .hamburger.opened span:nth-child(1) {
    	transform: rotate(135deg);
    	margin-top: 16px;
    }
    .hamburger.opened span:nth-child(2) {
    	opacity: 0;
    	right: -75px;
    }
    .hamburger.opened span:nth-child(3) {
    	transform: rotate(-135deg);
    	margin-top: 16px;
    }
    .hamburger.opened span {
    	background: #f15c57 none repeat scroll 0% 0%;
    }
    
    
    
    .icon
     {
     width: 45px;
    	 height: 45px;
    	 display: block;
        margin: 0 auto
    }
    @media (max-width:800px){.icon
     {
     width: 35px;
    	 height: 35px;
    	 display: block;
        margin: 0 auto
    }}
    
    .icon-facebook,
    .icon-twitter,
    .icon-linkedin{
      fill: #262626;
    }
    .icon-facebook {width: 30px}
    .icon-facebook :hover {
      fill: #3b5998;
    }
    .icon-twitter :hover {
      fill: #00acee;
    }
    .icon-linkedin :hover {
      fill: #007fb2;
    }
    /*BODY
    --------------------------------------------------------------------------------------------------------------
    ============================================================================================================*/
    
    .right-v {
    	position: absolute;
    	top: 50%;
    	right: 0;
    	transform: rotate(90deg);
    	transform-origin: left top 0;
    	z-index: 1;
    }
    @media (max-width:800px) {
    	.right-v {
    		display: none;
    	}
    }
    .lb {
    	color: #FFF;
    }
    .pd {
    	font-family: 'Gilda Display', serif;
    }
    #wwa {
    	font-size: .7em;
    	text-transform: uppercase
    }
    .hidden, .show-mobile {
        display: none;
    }
    
    /*FOOTER
    --------------------------------------------------------------------------------------------------------------
    ============================================================================================================*/
    
    footer.home-footer {
    	position: fixed;
    	bottom: 0;
    	right: 2%;
    	z-index: 1;
    }
    .bottom-panel {
    	color: #FFF;
    	font-size: .9em
    }
    .bottom-panel ul {
    	list-style: none;
    	padding: 0;
    	margin: 0;
    }
    .bottom-panel ul li {
    	display: inline-block;
    	margin: 0;
    }
    .call {
    	padding-bottom: .5em;
    }
    li.social a {
    	border-bottom: 4px solid #FFF;
    	padding: 0 .5em 0em .5em;
    	color: #FFF;
    	text-decoration: none
    }
    li.social a:hover {
    	border-bottom: 4px solid #f15c57;
    }
    li.social:nth-child(2) {
    	margin-left: 1em !important;
    }
    
    /*HOME PANEL
    --------------------------------------------------------------------------------------------------------------
    ============================================================================================================*/
    
    .overlay {background: #101317; position: relative; width: 100%; height: 100vh;}
    
    .container-fluid {
    	margin-left: auto;
    	margin-right: auto;
    	overflow: hidden;
    
    }
    .banner-container {
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
      z-index: -100;
    
    }
    
    
    
    span.left-panel-load {
    	position: absolute;
    	top: 65%;
    	left: 2%;
    	transform: rotate(270deg);
    	transform-origin: left top 0;
    	z-index: 9;
    	text-transform: uppercase;
    	color: #FFF;
    	font-weight: bold;
    	font-family: 'Lato', sans-serif;
    	font-size: .7em;
    	letter-spacing: .1em;
    }
    
    .slider-wrapper, .slider-inner {
    	position: absolute;
    	height: 100%;
    	width: 100%;
    }
    
    #finalelements {
    	background: url(lib/img/home-banner.jpg) no-repeat center center;
    	width: 100%;
    	-webkit-background-size: cover;
    	-moz-background-size: cover;
    	-o-background-size: cover;
    	background-size: cover;
    }
    
    .slider-content {
    	position: relative;
    	width: 40%;
    	max-width: 500px;
    	left: 50%;
    	top: 50%;
    	-webkit-transform: translate(-50%, -50%);
    	transform: translate(-50%, -50%);
    	font-family: 'Lato', sans-serif;
    	border-style: solid;
        border-width: 70px;
        border-image: url(lib/img/border.png) 60 round;
    }
    
    .slider-content h1, .slider-content h3 {
    	font-family: 'Lato', sans-serif;
    	text-transform: uppercase;
    }
    
    .slider-content h1 {
    	font-size: 6em;
    	line-height: .8em;
    	margin: 0;
    	font-weight: 900 !important;
    	color: #ef0c33;
    	
    }
    
    .slider-content h1 strong { color: #FFF;}
    
    .slider-content h3 {font-weight: 300; margin-top: .8em}
    .slider-content h3 {
    	line-height: .7em;
    }
    .slider-content p {
    	padding-top: 2em;
    	width: 90%;
    	
    }
    
    
    
    
    
    .slider-content h4 {
    	padding-top: 2em;
    	font-family: 'Lato', sans-serif;
    	text-transform: uppercase;
    	font-weight: 100;
    }
    .distress {
    	background: url(lib/img/texture.png);
    	width: 95%;
    	height: 95%;
    	position: absolute;
    	top: 0;
    }
    .red-line {
    	width: 25%;
    	height: 1px;
    	background: #f0625d;
    	background: -moz-linear-gradient(left, transparent 0%, #ad1f23 100%);
    	background: -webkit-linear-gradient(left, transparent 0%, #ad1f23 100%);
    	background: linear-gradient(to right, transparent 0%, #ad1f23 100%);
    	filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='transparent', endColorstr='#ad1f23', GradientType=1);
    	position: absolute;
    	top: 50%;
    	margin-left: 1em;
    }
    
    @media (max-width:800px) {
    	.slider-content, .slider-content p {width: 80%}
    	.slider-content h1 { font-size: 5em;}
    }
    
    
    
    
    
    .hp-content {padding: 7em; display: block;}
    .hp-inner {width: 60% !important; margin: 0 auto;}
    .hp-inner img {width: 20%;}
    .hp-inner h2 {line-height: 1em; font-size: 4em;}
    
    
    
    
    .hp-inner h2::after {
    	 content:"";
        display: block;
        height: 0.1em;
        vertical-align: bottom;
        width: 20%;
    	background: #ef0c33;
    	margin: 1em 0 1em 0;
    }
    
    .hp-image {background: url(lib/img/capital.jpg)no-repeat center center;
    	width: 100%;
    	-webkit-background-size: cover;
    	-moz-background-size: cover;
    	-o-background-size: cover;
    	background-size: cover;}
    
    .hp-inner ul { list-style: none; margin: 0; padding: 0;}
    .hp-inner ul li { display: inline-block; padding: 1em 2em 1em 0;}
    .hp-inner ul li p {font-size: .8em;}
    .hp-inner ul li a {background: #ef0c33; color: #FFF; text-decoration: none; padding: .6em}
    
    
    .center {text-align: center}
    
    .dark-bg {background: #e3e3e3; display: block; position: relative; padding: 5em 0 5em 0}
    
    
    .service-panel h2 {text-align: center; margin-bottom: 1em}
    
    .service-panel h2::after {
    	 content:"";
        display: block;
        height: 0.1em;
        vertical-align: bottom;
        width: 10%;
    	background: #ef0c33;
    	margin: 0 auto;
    }
    .service-panel p {text-align: center}
    .service-panel span {font-weight: 900; font-size: 3em;}
    .service-grid {padding: 2em;}
    .service-grid h4 {font-weight: 900; font-size: 1.3em}
    .service-grid p {font-size: .9em; margin-top: .8em}
    
    
    .nav-up {
        top: -40px;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.13.1/TweenMax.min.js"></script>
    <div class="bg">
    
    </div>
    <header class="main-header">
    		<div class="header-menu">
      			<div class="hamburger">
            <p>Menu</p>
    			</div>
    		</div>
    	</header>
    	<nav class="main-nav">
    		<div class="block-reveal" id="block__01"></div>
    		<div class="nav-container">
    			<ul class="main-menu">
    				<li class="nav-link"><a href="#">Agency</a></li>
    				<li class="nav-link"><a href="#">Work</a></li>
    				<li class="nav-link"><a href="#">Services</a></li>
    				<li class="nav-link"><a href="#">Contact</a></li>
    			</ul>
    			<ul class="small-menu nav-link1">
    				<li><p class="follow_title h3">Follow Us</p></li>
    				<li><a href="#0"><svg class="icon icon-facebook"><use xlink:href="#facebook"/></svg></a></li>
    				<li><a href="#0"><svg class="icon icon-twitter"><use xlink:href="#twitter"/></svg></a></li>
    				<li><a href="#0"><svg class="icon icon-linkedin"><use xlink:href="#linkedin"/></svg></a></li>
    			</ul>
    			
    		</div>
    	</nav>
    </div>

    【讨论】:

    • 很抱歉,我应该在我的帖子中澄清一点。导航链接是正确的。为了演示向您展示菜单实际上并没有隐藏,我将类更改为 nav-link 1。如果我将它们全部更改为 nav-link,动画确实可以工作,但 nav-container 将页面覆盖为隐藏的 div。这意味着当我单击菜单并关闭它时,一切正常,但是如果我在页面上有链接,我无法按下它们,因为 div 实际上没有隐藏
    【解决方案2】:

    在您的点击处理程序中,您总是从菜单中删除 hidden 类。隐藏菜单时需要替换它(否则菜单不会隐藏)。所以使用toggleClass 而不是removeClass。它应该看起来像这样。

    menuButton.click(function() {
        blockAnimation.reversed() ? blockAnimation.play() : blockAnimation.reverse();
        $('.hamburger').toggleClass('opened');
        $("a.header-logo").toggleClass('header-logo-open');
        $(".start-project").toggleClass('start-project-black');
        $('.header-logo-open').fadeIn(1000);
        $('.nav-container').toggleClass('hidden'); 
    });
    

    看起来可能还有其他一些问题,但这解决了隐藏问题。

    【讨论】:

    • 这可以正常工作,唯一的问题是它会在动画开始之前杀死它
    • 大多数动画框架都会给你一个回调函数,一旦动画完成,你就可以用它来做所有这些事情。你可以把开关放在那里(如果有的话)。如果没有,您可以使用setTimeout 破解它,并将回调设置为在动画完成后发生。
    • 我试图浏览动画但没有运气。你建议用 setTimeout 做什么
    • 它确实有一个完整的回调。见the docs。向下滚动到它谈论初始化TimelineMax 对象的位置并查找onComplete。这将比setTimeout 容易得多。
    【解决方案3】:

    一行

    <li class="nav-link1"><a href="#">Contact</a></li>
    

    它有一个1应该是

    <li class="nav-link"><a href="#">Contact</a></li>
    

    在没有 1 的情况下尝试过,它可以工作

    【讨论】:

    • 我更新了我的条目,但我放置在那里以显示菜单的 nav-link1 实际上并没有隐藏。是的,导航链接删除了链接,但是当我关闭菜单时 div 仍然存在。发生的事情是当菜单以正确的类关闭时,我的页面上有一个隐藏的覆盖层,它阻止了其他 url 点击。
    猜你喜欢
    • 2015-09-21
    • 2017-07-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-13
    • 2016-11-16
    • 2018-02-14
    • 2015-05-05
    相关资源
    最近更新 更多