Results 1 to 4 of 4

Thread: code to stop the animation buildup in JS

  1. #1
    Join Date
    May 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default code to stop the animation buildup in JS

    Hi I am using the jQuery Drop Line Tabs - have looked at different codes .stop true true etc. But everything I tried does not solve the problem. Looked at Brandon Aaron's solution and other ones,but still not working..

    Please help:
    Where, what how do I do to Implement a .stop() to the js code already in place see below:

    Many thanks for any help.

    Code:
    var droplinemenu={
    
    arrowimage: {classname: 'downarrowclass', src: 'down.gif', leftpadding: 5}, //customize down arrow image
    animateduration: {over: 200, out: 100}, //duration of slide in/ out animation, in milliseconds
    
    buildmenu:function(menuid){
    	jQuery(document).ready(function($){
    		var $mainmenu=$("#"+menuid+">ul")
    		var $headers=$mainmenu.find("ul").parent()
    		$headers.each(function(i){
    			var $curobj=$(this)
    			var $subul=$(this).find('ul:eq(0)')
    			this._dimensions={h:$curobj.find('a:eq(0)').outerHeight()}
    			this.istopheader=$curobj.parents("ul").length==1? true : false
    			if (!this.istopheader)
    				$subul.css({left:0, top:this._dimensions.h})
    			var $innerheader=$curobj.children('a').eq(0)
    			$innerheader=($innerheader.children().eq(0).is('span'))? $innerheader.children().eq(0) : $innerheader //if header contains inner SPAN, use that
    			$innerheader.append(
    				'<img src="'+ droplinemenu.arrowimage.src
    				+'" class="' + droplinemenu.arrowimage.classname
    				+ '" style="border:0; padding-left: '+droplinemenu.arrowimage.leftpadding+'px" />'
    			)
    			$curobj.hover(
    				function(e){
    					var $targetul=$(this).children("ul:eq(0)")
    					if ($targetul.queue().length<=1) //if 1 or less queued animations
    						if (this.istopheader)
    							$targetul.css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h})
    						if (document.all && !window.XMLHttpRequest) //detect IE6 or less, fix issue with overflow
    							$mainmenu.find('ul').css({overflow: (this.istopheader)? 'hidden' : 'visible'})
    						$targetul.slideDown(droplinemenu.animateduration.over)
    				},
    				function(e){
    					var $targetul=$(this).children("ul:eq(0)")
    					$targetul.slideUp(droplinemenu.animateduration.out)
    				}
    			) //end hover
    		}) //end $headers.each()
    		$mainmenu.find("ul").css({display:'none', visibility:'visible', width:$mainmenu.width()})
    	}) //end document.ready
    }
    }
    Last edited by ddadmin; 05-09-2011 at 08:12 AM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Not what quite what the behavior you're aiming to accomplish is, but as far as eliminating animation buildup, you might try using the dequeue() function just before the animation is about to start, so in these two places inside the script:
    Code:
    $targetul.dequeue().slideDown(droplinemenu.animateduration.over)
    and

    Code:
    $targetul.dequeue().slideUp(droplinemenu.animateduration.out)
    DD Admin

  3. #3
    Join Date
    May 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hey million thanks, seems to work

    Before the sub-menu would appear and disappear rapidly many times before remaining in place long enough to click on any links. I had tried the dequeue method but got it wrong, really appreciate your response.

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    You're welcome. This looks like a nice change to the script, so I've added it to the official build as well.
    DD Admin

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •