www.webdeveloper.com
Results 1 to 1 of 1

Thread: stop at hover

  1. #1
    Join Date
    Jul 2005
    Posts
    86

    stop at hover

    Hi all,

    Well back on again ('last visite 05-27-2010') ...

    Struggling with a piece of jquery code.

    Hover on menu-item: fade in image > works fine.
    Hover on menu-item, then quick next, and repeat this many times (aka. hovering like a maniac): fade in images happens in hovering order. Which results in a delayed proces and ends long after I stopped hovering.

    My question: how can I stop that from happening?

    Code:
    if ($jquery('ul.show_pictures li').length ) {
    		$jquery('ul.show_pictures li').filter(':not(:first)').hide().end().filter(':first').addClass('showing');
    		$jquery('ul.show_menu li').filter(':first').addClass('showing_menuitem');
    		rotate = function(){
    			$jquery('ul.show_menu li').removeClass('showing_menuitem');
    			$activeM.addClass('showing_menuitem');
    			$jquery('ul.show_pictures li').removeClass('showing').fadeOut();
    			$active.addClass('showing').fadeIn();
    		};
    		rotateSwitch = function(){
    			play = setInterval(function() {
    				$active = $jquery('ul.show_pictures li.showing').next();
    				$activeM = $jquery('ul.show_menu li.showing_menuitem').next();			
    				if ($active.length === 0) {
    					$active = $jquery('ul.show_pictures li:first');
    					$activeM = $jquery('ul.show_menu li:first');
    				}
    				rotate();
    			}, 5000);	
    		};
    		rotateSwitch();      
    		$jquery('ul.show_pictures li').hover(function() {
    			clearInterval(play);
    		}, function() {
    			rotateSwitch();
    		});
    		$jquery('ul.show_menu li').hover(function() {
    			$activeM = $jquery(this);
    			$activeMnr = $jquery('ul.show_menu li').index(this);
    			//alert($activeMnr);
    			$active = $jquery('ul.show_pictures li').eq($activeMnr);
    			clearInterval(play);
    			rotate();
    			rotateSwitch();		
    		}, function() {
    			rotateSwitch();
    		});
    	}
    Last edited by 3Pinter; 04-14-2011 at 10:18 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles