I'm making a horizontal scroll on a div element using left and right buttons.
I initially achieved the same with refs.
onClickLeft = () => {
this.props.refELement.current.scrollLeft -= 300;
}
onClickRight = () => {
this.props.refElement.current.scrollLeft += 300;
}
But I can't seem to find a way to set animation duration to this.
Using jquery, this can be achieved as:
$('.swipeRight').click(function(){
$('.swipeBox').animate( { scrollLeft: '+=460' }, 1000);
});
$('.swipeLeft').click(function(){
$('.swipeBox').animate( { scrollLeft: '-=460' }, 1000);
});
But this code is not reproducable in reactjs.
I want to achieve this in reactjs basically.
Any help with this?