mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #14792 from grafana/adios-scrollbar
chore: Remove ScrollBar component, superseded by CustomScrollbar
This commit is contained in:
commit
ba19773347
@ -1,78 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import baron from 'baron';
|
|
||||||
|
|
||||||
export interface Props {
|
|
||||||
children: any;
|
|
||||||
className: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class ScrollBar extends React.Component<Props, any> {
|
|
||||||
private container: any;
|
|
||||||
private scrollbar: baron;
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.scrollbar = baron({
|
|
||||||
root: this.container.parentElement,
|
|
||||||
scroller: this.container,
|
|
||||||
bar: '.baron__bar',
|
|
||||||
barOnCls: '_scrollbar',
|
|
||||||
scrollingCls: '_scrolling',
|
|
||||||
track: '.baron__track',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate() {
|
|
||||||
this.scrollbar.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
this.scrollbar.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
// methods can be invoked by outside
|
|
||||||
setScrollTop(top) {
|
|
||||||
if (this.container) {
|
|
||||||
this.container.scrollTop = top;
|
|
||||||
this.scrollbar.update();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setScrollLeft(left) {
|
|
||||||
if (this.container) {
|
|
||||||
this.container.scrollLeft = left;
|
|
||||||
this.scrollbar.update();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
update() {
|
|
||||||
this.scrollbar.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
handleRef = ref => {
|
|
||||||
this.container = ref;
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div className="baron baron__root baron__clipper">
|
|
||||||
<div className={this.props.className + ' baron__scroller'} ref={this.handleRef}>
|
|
||||||
{this.props.children}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="baron__track">
|
|
||||||
<div className="baron__bar" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user