Is there a way to make horizontal scrolling smoother
This could probably be optimised a fair bit, but here is a basic example of how you could do it using setInterval
and clearInterval
Fiddle
Update
Here is another example of it wrapped into a function instead, bit easier to tweak the speed etc.
Fiddle
You can also use the .scrollTo method. I've modified the jsFidlle with this javascript :
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo
var container = document.getElementById('container');
var input = document.getElementById('content');
var scrollAmount = 0;
var scrollMin = 0
var scrollMax = input.clientWidth
document.getElementById('slide').onclick = function () {
container.scrollTo({
top: 0,
left: Math.max(scrollAmount += 500, scrollMax),
behavior: 'smooth'
});
};
document.getElementById('slideBack').onclick = function () {
container.scrollTo({
top: 0,
left: Math.min(scrollAmount -= 500, scrollMin),
behavior: 'smooth'
});
};