This fiddle is almost what I'm looking for, I got it from MDN. The only thing missing is that I want to make it smoother. Is there a way to do that without using jQuery or any other plugins?
Fiddle
var button = document.getElementById('slide');
button.onclick = function () {
document.getElementById('container').scrollLeft += 100;
};
var back = document.getElementById('slideBack');
back.onclick = function () {
document.getElementById('container').scrollLeft -= 100;
};
you can do it vertically with jquery although i'm sure it can be adjusted to be done horizontally. The demo is here
There's a javascript smoothscroll on github too added by cfernandi
Also ccheck out iscroll.js
$(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) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
来源:https://stackoverflow.com/questions/24635884/is-there-a-way-to-make-horizontal-scrolling-smoother