I've been building a horizontal one page site. And for the past two days, I've been trying all kinds of different things with no luck. Finally, I figured out how to make the smooth scroll work. But not entirely.. It slides over slightly, but it does not slide the full section.
Here's the function.
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('body').animate({
scrollLeft: target.offset().top
}, 1000);
return false;
}
}
});
});
Full site can be found at levistroop.com/test
Any help is greatly appreciated!!
Best, Levi
Try setting 'scrollLeft: target.offset().left' instead of top
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments