Adjust IndicatorScrollbar to not rely on AutoHideScrollbar for overflow
parent
0436507574
commit
75cbc1dc07
|
@ -66,6 +66,22 @@ export default class IndicatorScrollbar extends React.Component {
|
||||||
this._autoHideScrollbar = autoHideScrollbar;
|
this._autoHideScrollbar = autoHideScrollbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
const prevLen = prevProps && prevProps.children && prevProps.children.length || 0;
|
||||||
|
const curLen = this.props.children && this.props.children.length || 0;
|
||||||
|
// check overflow only if amount of children changes.
|
||||||
|
// if we don't guard here, we end up with an infinite
|
||||||
|
// render > componentDidUpdate > checkOverflow > setState > render loop
|
||||||
|
if (prevLen !== curLen) {
|
||||||
|
this.checkOverflow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.checkOverflow();
|
||||||
|
}
|
||||||
|
|
||||||
checkOverflow() {
|
checkOverflow() {
|
||||||
const hasTopOverflow = this._scrollElement.scrollTop > 0;
|
const hasTopOverflow = this._scrollElement.scrollTop > 0;
|
||||||
const hasBottomOverflow = this._scrollElement.scrollHeight >
|
const hasBottomOverflow = this._scrollElement.scrollHeight >
|
||||||
|
@ -95,10 +111,6 @@ export default class IndicatorScrollbar extends React.Component {
|
||||||
this._scrollElement.classList.remove("mx_IndicatorScrollbar_rightOverflow");
|
this._scrollElement.classList.remove("mx_IndicatorScrollbar_rightOverflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._autoHideScrollbar) {
|
|
||||||
this._autoHideScrollbar.checkOverflow();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.props.trackHorizontalOverflow) {
|
if (this.props.trackHorizontalOverflow) {
|
||||||
this.setState({
|
this.setState({
|
||||||
// Offset from absolute position of the container
|
// Offset from absolute position of the container
|
||||||
|
|
Loading…
Reference in New Issue