Results 1 to 2 of 2

Thread: stop animation once hover

  1. #1
    Join Date
    Aug 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking stop animation once hover

    i really wish to stop the animation once onmouseover and start the animation again when onmouseout...

    below is the code

    Code:
    <script type="text/javascript">
    
    $(document).ready(function(){
    	
    	var first = 0;
    	var speed = 100;
    	var pause = 3500;
    	
     interval = setInterval(removeFirst, pause);
    
    	
    		function removeFirst(){
    			first = $('ul#listticker li:first').html();
    			$('ul#listticker li:first')
    			.animate({opacity: 10}, speed)
    			.fadeOut('slow', function() {$(this).remove();});
    			addLast(first);
    		}
    		
    		function addLast(first){
    			last = '<li style="display:none">'+first+'</li>';
    			$('ul#listticker').append(last)
    			$('ul#listticker li:last')
    			.animate({opacity: 1}, speed)
    			.fadeIn('slow')
    		}
    	
    	
    	
    });
    </script>
    thx in advance

  2. #2
    Join Date
    Oct 2009
    Posts
    845
    Thanks
    14
    Thanked 189 Times in 188 Posts

    Default

    Maybe something like this will get you a little closer
    Code:
    <script type="text/javascript">
    $(document).ready(function(){
    	
    	var first = 0;
    	var speed = 100;
    	var pause = 3500;
    	
    
    	var runTicker = setInterval(removeFirst, pause);	
    
                    $(function () {		   
                    $('#listticker').hover(function () {
                    clearInterval(runTicker);
    	        }, function () {
                    runTicker =  setInterval(removeFirst, pause);
    	            });
                   }); 
    
    	
    		function removeFirst(){
    			first = $('ul#listticker li:first').html();
    			$('ul#listticker li:first')
    			.animate({opacity: 10}, speed)
    			.fadeOut('slow', function() {$(this).remove();});
    			addLast(first);
    		}
    		
    		function addLast(first){
    			last = '<li style="display:none">'+first+'</li>';
    			$('ul#listticker').append(last)
    			$('ul#listticker li:last')
    			.animate({opacity: 1}, speed)
    			.fadeIn('slow')
    		}	
    	
    });
    </script>

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
  •