I want to use buttons to scroll to the right or left in my container. It works but I want it to work smooth..

How van I achieve this? Do I need another plugin or is there a simple fix?

$(button).on('click', function(){
  flavoursContainer.scrollLeft += 220; 
}); 

2 Answers

0
Zenoo On Best Solutions

You could use jQuery .animate() method to achieve that:

$(button).on('click', function(){
  $(flavoursContainer).animate({scrollLeft: $(flavoursContainer).scrollLeft() + 220}, 500);
}); 
0
Rajitha-d On

$(function() {
  $('#addclickable element').bind('click', function(event) {
    $('#addtargetelement or div').stop().animate({
      scrollLeft: $('.a').offset().left
    }, 500);
    event.preventDefault();
  });
});