Hi,

I need to make one of those mouse scrolling galleries that lets you change
the direction by where your cursor is positioned. However, I'm starting to
suspect this won't be possible using javascript.

I have the main functionality worked out(see code below), but the problem
I'm coming up against is when the mouseover/mouseout events are triggered.
I've set the events to be triggered from the gallery container, but it seems
like the mouse events are called everytime the cursor goes over any of the
images within the gallery instead.

    $(gallery).parent().mouseover(function(e){
    //Finds cursor position relative to gallery
        if(e.clientY > offset.top + 286){dir = -1}
        else if(e.clientY < offset.top + 286){dir = 1}
    
    //Initiates scroll  
        scrollInterval = setInterval(scroll, 10);
    })
        
    $(gallery).parent().mouseout(function(){
    //Stops mouse scroll
        clearInterval(scrollInterval);
        
    //Scrolls gallery to nearest complete image  
        if(dir = 1){
            var y = Math.floor(currentPos / 143)* 143;
            $(gallery).animate({top: y+'px'}, speed);
            currentPos = y;
        }
        else if(dir = -1){
            var y = Math.ceil(currentPos / 143)* 143;
            $(gallery).animate({top: y+'px'}, speed);
            currentPos = y;
        }
    })
    
    function scroll(){
    //Sets scroll limits
        if(currentPos >= 0 && dir == 1){return}
        else if(currentPos <= -572 && dir == -1){return}
    
    //Animates gallery scroll
        else{
            $(gallery).css('top', currentPos+(scrollSpeed*dir)+'px');
            currentPos = currentPos+(scrollSpeed*dir);
        }
    }


Is there anyway round this? Thanks for any help you can provide.

Rich


-- 
View this message in context: 
http://www.nabble.com/Mouse-event-problem-tp23480749s27240p23480749.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to