【问题标题】:CSS3 animation with jQuery使用 jQuery 的 CSS3 动画
【发布时间】:2015-09-13 16:28:54
【问题描述】:

这是一个有点远的镜头,但这里是 - 我是 css3 动画的新手,所以请光顾..

Codepen link

	$(document).ready(function(){
				$("#menu").mmenu({
					extensions 	: [ "theme-dark", "effect-slide-menu", "effect-slide-listitems" ],
					iconPanels	: {
						add 		: true,
						visible		: 1,
						hideNavbars	: true
					}
					
					})
				
	
		
		
	        $("#hamburger").click(function(){
	           $(".burger .one, .burger .two, .burger  .three, .circle").css("-webkit-animation-play-state", "running");
	       });
		});	
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.mmenu/5.3.1/js/jquery.mmenu.min.all.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jQuery.mmenu/5.3.1/css/jquery.mmenu.all.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="page">
	         <div class="header">
	            
		       <a href="#menu" id="hamburger">

					  <div class="burger">
					    <div class="one"></div>
					    <div class="two"></div>
					    <div class="three"></div>
					  </div>
					
					  <div class="circle"></div>
				
				</a>
	            Demo
	         </div>
	         <div class="content">
	            <p><strong>This is a demo.</strong><br />
	               Click the menu icon to open the menu.</p>
	         </div>
	      </div>
      
      <!-- The page End-->
      
			  <!-- The menu -->
		  <nav id="menu">
	         <ul>
	            <li><a href="/">Home</a></li>
	            <li><a href="/about">About us</a>
	               <ul>
	                  <li><a href="/about/history">History</a></li>
	                  <li><a href="/about/team">The team</a></li>
	                  <li><a href="/about/address">Our address</a></li>
	               </ul>
	            </li>
	            <li><a href="/contact">Contact</a></li>
	         </ul>

当汉堡菜单打开时,动画在图标上开始,但当您关闭它时,动画保持在打开状态。我想让它恢复到原来的状态

提前致谢

【问题讨论】:

标签: jquery css animation


【解决方案1】:

使用 mm-blocker 的 mousedown 事件重置之前的样式。我使用动画方向反转来做到这一点。这是代码笔http://codepen.io/anon/pen/gpoPqQ

     $("#mm-blocker").on( "mousedown",function(){
     $(".burger .one, .burger .two, .burger  .three, .circle").css("-webkit-animation-direction", "normal");
    } );


        $("#hamburger").click(function(){
        $(".burger .one, .burger .two, .burger  .three, .circle").css("-webkit-animation-direction", "reverse");
        $(".burger .one, .burger .two, .burger  .three, .circle").css("-webkit-animation-direction", "running");

       });

【讨论】:

  • 您好,感谢您的帮助。我现在唯一的问题是打开动画不起作用,有什么想法吗??
猜你喜欢
  • 2013-09-09
  • 2012-11-16
  • 2012-03-10
  • 2013-11-28
  • 1970-01-01
  • 2012-01-25
  • 2013-03-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多