tags:

views:

83

answers:

3

Very hard to explain, I know.. especially since I'm new to the concept of programming altogether.

But I want to, on mouse over of a link to the right, change the logo so it corresponds with the link. I want it to animate so it 'scrolls' past all the other logos to get to the right one, kinda like what some websites have been doing as of late.

All the logos are contained within a div, and all have their own classes (if needed). Same goes with the links.

I'm certain one of you jQuery junkies can figure this out in a few lines of code.. or point me to a tutorial. Help me pleaase!

EDIT: Okay, whilst jAndy's submission was very handy, I'm stuck on how to code it all up. Am I going about this the right way?

<div id="nav">
    <div id="nav_left">
        <h1 class="home"><em>name</em>:home</h1>
        <h1 class="about"><em>name</em>:about</h1>
        <h1 class="folio"><em>name</em>:folio</h1>
        <h1 class="contact"><em>name</em>:contact</h1>
    </div>
    <div id="nav_right">
        <ul>
            <li><a href="#" class="lhome">Home</a></li>
            <li><a href="#" class="labout">About Me</a></li>
            <li><a href="#" class="lfolio">Portfolio</a></li>
            <li><a href="#" class="lcontact">Contact Me</a></li>
        </ul>
    </div>
</div>
+1  A: 

Check out Ariel Fleslers scrollTo plugin

redsquare
That would definitely help. Any suggestions for the code?
jordsta
+3  A: 

Easy going would look simiar to this example:

$('a.MyAnchorClass').bind('mouseenter', function(){
    $('div.MyDivClassWithLogos').animate({
       'scrollTop':    $('img.MyImgClass').offset().top
    }, 1500);
});

Example: http://jsbin.com/uliti3/2/edit

$(document).ready(function(){
    $('#nav_left').find('h1').each(function(i,v){
       $.data(this, 'pos', $(this).offset());
    });

    $('#nav_right').find('a').bind('mouseenter', function(e){
       var _target = '.' + e.target.className.substr(1);

       $('#nav_left').stop(true, false).animate({
           'scrollTop':  $(_target).data('pos').top
       }, 1500);
    });
});
jAndy
I've tried implementing this, but I really am stuck. Is it possible for you to look over the code and see if I'm div'ing everything the right way? (I've added the code above)
jordsta
@jordsta: I've added an example
jAndy
Excellent, this (nearly) does exactly what I want it to! It does seem to do this all randomly though, and always ends up at the bottom. I'll be uploading a demo shortly of what I mean..
jordsta
Okay, here's a live demo: http://jordsta.vlexofree.com/jqueryhelp/
jordsta
@jordsta: i can't see the sourcecode right now since I'm on mobile phone watching worldcup. But it looks like you aren't using my latest example code (with caching offsets) do you?
jAndy
Oh, no, I wasn't! Sorry, I thought it was a source for the first bit of code.. I'll try it out and see what happens.
jordsta
I don't think it's doing anything different.. it's probably because it needs an offset though.
jordsta
Okay, I'm still having massive troubles with this. It seems to scroll to the bottom of the div regardless of whatever link is hovered. Do you know what's wrong with it?
jordsta
A: 

Although jAndy's answer is probably what you want... I thought I would share another method seen in this demo

I answered a previous question using a menu system that worked by scrolling a div after clicking. I simply updated the demo by changing click to mouseover.

fudgey
Actually, I find your method fits well. I'll have a go at it after I get my computer back up and running, in about a day or two.
jordsta