Search code examples
jquerymenudelay

JQuery animate - delay issue


I've got this site:

http://p33.yamandi.com/

Almost everything works fine, except one little annoying thing - the delay. If you click on Rossman menu item, then close it with "zamknij" icon and then try to click another menu item at once. You'll notice the 1-2 second delay. I have no idea what is the reason for this issue. It happens in all browsers. Can anyone help?

Regards, David


Solution

  • Not entirely sure if this is your problem, but try calling stop() before animate() on all the elements that you're animating. Something like this:

    $(window).load(function() {
      mCustomScrollbars();
      $(function(){
        $("ul#menu a").click(function() {
          myId = this.id;
          $('.text').stop();
          $("ul#menu, h1#logo").stop().animate({left: '-=572'}, 500, function() {
            $("#lang").css("display", "none");
            $("#"+myId+"pr").stop().animate({left: 0}, 200);
            if(myId == "dojazd") {
              $("#outer-mapka").css("left", "50%").css("margin-left", "-213px");
            } else {
              api.goTo(myId.charAt(myId.length-1));
            }
          });
        });
        $("a.close").click(function() {
          api.goTo(1); 
          $(".text").stop().animate({left: "-=950"}, 200, function() { 
            $(".text, #outer-mapka").css("left", "-950px");
            $("ul#menu, h1#logo").stop().animate({left: '0'}, 500, function() {} );
            $("#lang").css("display", "block");
          });
        });
      });
    });