Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function() {
  2. $(function() {
  3.     var $magicLine = $("<div id='magic-line'></div>");
  4.  
  5.     $(".mainNav").append($magicLine);
  6.  
  7.     $magicLine
  8.         .width($(".current-menu-item").width())
  9.         .css("left", $(".current-menu-item a").position().left)
  10.         .data("origLeft", $magicLine.position().left)
  11.         .data("origWidth", $magicLine.width());
  12.  
  13.     $(".mainNav li a").hover(function() {
  14.         $el = $(this);
  15.         leftPos = $el.parent().position().left;
  16.         newWidth = $el.parent().width();
  17.  
  18.         $magicLine.stop().animate({ left: leftPos, width: newWidth });
  19.     }, function() {
  20.         $magicLine.stop().animate({
  21.             left: $magicLine.data("origLeft"),
  22.             width: $magicLine.data("origWidth")
  23.         });
  24.     });
  25. });
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement