我正在使用左右按钮在div元素上制作水平滚动。我最初使用引用(refs)实现了相同的效果。
onClickLeft = () => {
this.props.refELement.current.scrollLeft -= 300;
}
onClickRight = () => {
this.props.refElement.current.scrollLeft += 300;
}
但我似乎找不到设置动画持续时间的方法。
使用jQuery,可以通过以下方式实现:
$('.swipeRight').click(function(){
$('.swipeBox').animate( { scrollLeft: '+=460' }, 1000);
});
$('.swipeLeft').click(function(){
$('.swipeBox').animate( { scrollLeft: '-=460' }, 1000);
});
但是这段代码在ReactJS中无法重现。
我想在ReactJS中基本实现这个。
有什么帮助吗?