Hi I'm new to javascript, and I thought I had this down but I can't seem to get it to work.
I'm trying to create a horizontal scrolling website, navigable with arrow keys. I also have arrow buttons that I'd like to use the same function to animated the scroll between sections, but I'm not sure how to combine it all into one script. Right now my script scrolls a fixed 1024px, but ideally a more versatile script would scroll between anchors I could just put anywhere!
Ideally I'm trying to get a function to scroll through a series of anchors that can be called through either a click of the left or right button, or by using the arrow keys.
Any help would be great, thanks! I'm really admiring this website's structure.
$(document).bind('keydown',function(evt) {
switch(evt.keyCode) {
case 37:
evt.preventDefault();
$.scrollTo('+=1024px', 800, { axis:'x' });
break;
}
});
$(document).bind('keydown',function(evt) {
switch(evt.keyCode) {
case 39:
evt.preventDefault();
$.scrollTo('-=1024px', 800, { axis:'x' });
break;
}
});
I did see this post but I was unsuccessful in adapting it to scroll through a series of anchors :/