Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    [jQuery] Little help please

    Hello.

    This is my first post on this forum, and my first encounter with Javascript.

    I am trying to make this website where the nav in the top left is used to select a section and the images below scroll through till they get to this section.

    So far i have successfully managed to do this (please excuse the extremely messy site, all the html and css will be changed once i have the javascript working how i want it to). My problem now is trying to get the images to scroll the other way, i can navigate right, but cant navigate back left, instead it moves slightly right still...

    The website address is - http://www.jamesaallen.com/test2/issue2.html

    I have got a lot of this code from free javascript sort of sites and altered it over a long and tiresome few days. As i have said above, this is my first time doing this and have no idea what i am doing, so i dont even know what some parts of the code mean.

    Any help with this little section would be so gratefully recieved:

    function scrollToEntry(entry) {
    var el = $('e'+entry);
    var x = Position.cumulativeOffset(el)[0]-30;
    nx = getViewportScrollX();
    if (anim) clearInterval(anim);
    anim = setInterval(function() {
    nx += (nx > x) ? (nx-x)/4 : (x-nx)/4 ;
    window.scrollTo(nx,0);
    if (nx>x-1) clearInterval(anim);
    },20);
    return false;
    }



    getViewportScrollX = function() {
    var scrollX = 0;
    if( document.documentElement && document.documentElement.scrollLeft ) {
    scrollX = document.documentElement.scrollLeft;
    }
    else if( document.body && document.body.scrollLeft ) {
    scrollX = document.body.scrollLeft;
    }
    else if( window.pageXOffset ) {
    scrollX = window.pageXOffset;
    }
    else if( window.scrollX ) {
    scrollX = window.scrollX;
    }
    return scrollX;
    },

    getViewportScrollY = function() {
    var scrollY = 0;
    if( document.documentElement && document.documentElement.scrollTop ) {
    scrollY = document.documentElement.scrollTop;
    }
    else if( document.body && document.body.scrollTop ) {
    scrollY = document.body.scrollTop;
    }
    else if( window.pageYOffset ) {
    scrollY = window.pageYOffset;
    }
    else if( window.scrollY ) {
    scrollY = window.scrollY;
    }
    return scrollY;
    }



    Best,
    James.
    Last edited by jamesaallen; 06-27-2008 at 06:15 PM. Reason: didnt put the first bit of the title in, still not sure if thats the right one...?!


 

Posting Permissions

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