Home > Web Front-end > JS Tutorial > body text

Implementing mouse click navigation menu water wave animation effect based on jQuery with source code download_jquery

WBOY
Release: 2016-05-16 15:21:18
Original
1556 people have browsed it

Based on jQuery mouse click water wave animation vertical navigation code. This is a vertical navigation bar effect with animation based on jQuery+CSS3. The rendering is as follows:

Effect display Source code download

html code:

<div class="nav">
  <ul>
   <li><a>网站首页</a></li>
   <li><a>关于我们</a></li>
   <li><a>产品中心</a></li>
   <li><a>成功案例</a></li>
   <li><a>联系我们</a></li>
   <li><a>在线留言</a></li>
  </ul>
 </div>
 <script type="text/javascript" src="js/jquery.min.js"></script>
 <script type="text/javascript">
  //jQuery time
  var parent, ink, d, x, y;
  $(".nav ul li a").click(function (e) {
   parent = $(this).parent();
   //create .ink element if it doesn't exist
   if (parent.find(".ink").length == 0)
    parent.prepend("<span class='ink'></span>");
   ink = parent.find(".ink");
   //incase of quick double clicks stop the previous animation
   ink.removeClass("animate");
   //set size of .ink
   if (!ink.height() && !ink.width()) {
    //use parent's width or height whichever is larger for the diameter to make a circle which can cover the entire element.
    d = Math.max(parent.outerWidth(), parent.outerHeight());
    ink.css({ height: d, width: d });
   }
   //get click coordinates
   //logic = click coordinates relative to page - parent's position relative to page - half of self height/width to make it controllable from the center;
   x = e.pageX - parent.offset().left - ink.width() / 2;
   y = e.pageY - parent.offset().top - ink.height() / 2;
   //set the position and add class .animate
   ink.css({ top: y + 'px', left: x + 'px' }).addClass("animate");
  })
 </script>
Copy after login

The above code is the core code of this article. It is relatively simple. You can add and delete the code appropriately according to your needs.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!