Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-27-2008, 05:13 PM   PM User | #1
jamesaallen
New to the CF scene

 
Join Date: Jun 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jamesaallen is an unknown quantity at this point
[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 05:15 PM.. Reason: didnt put the first bit of the title in, still not sure if thats the right one...?!
jamesaallen is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:42 AM.


Advertisement
Log in to turn off these ads.