我正在使用React-Perfect-Scrollbar
添加自定义滚动条。默认位置在包含 div 的左侧。我需要将它移动到 div 的右侧。怎么做?
代码的当前外观
import 'react-perfect-scrollbar/dist/css/styles.css';
import PerfectScrollbar from 'react-perfect-scrollbar'
...
<div className="tabcontent-2">
<PerfectScrollbar>
<p>{this.state.currentProject.description}</p>
</PerfectScrollbar>
</div>
...
用户界面的当前外观
我找不到一个option
由给定module
这样做。有人可以帮助我吗?
您可以按照此文档
https://mdbootstrap.com/docs/jquery/javascript/scroll/#smooth-scroll
您可以在 onScroll
var myCustomScrollbar = document.querySelector('.my-custom-scrollbar');
var ps = new PerfectScrollbar(myCustomScrollbar);
var scrollbarY = myCustomScrollbar.querySelector('.ps.ps--active-y>.ps__scrollbar-y-rail');
myCustomScrollbar.onscroll = function() {
scrollbarY.style.cssText = `top: ${this.scrollTop}px!important; height: 400px; right: ${-this.scrollLeft}px`;
}
在反应。我认为您可以使用滚动条参考进行更新
class Container extends Component {
...
render() {
return (
<ScrollBar
ref = {(ref) => { this._scrollBarRef = ref; }}
>
...
<ChildComponent
onUpdateSize = {() => { this._scrollBarRef.updateScroll(); }}
/>
...
</ScrollBar>
);
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句