Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
checkBodyVScroll() {
if (this.bodyScroll) {
const { prefixCls } = this.props;
const node = this.bodyScroll.getDom();
// body does not exist if no data
if (node.children[0]) {
const wrapperHeight = node.clientHeight;
const bodyHeight = node.children[0].clientHeight;
const headerDom = this.headerScroll ? this.headerScroll.getDom() : null;
const footerDom = this.footerScroll ? this.footerScroll.getDom() : null;
const noVScroll = bodyHeight <= wrapperHeight;
if (this.noVScroll === undefined || this.noVScroll !== noVScroll) {
if (noVScroll) {
addClass(node, `${prefixCls}-no-v-scroll`);
if (headerDom) {
addClass(headerDom, `${prefixCls}-no-v-scroll`);
}
if (footerDom) {
addClass(footerDom, `${prefixCls}-no-v-scroll`);
}
} else {
removeClass(node, `${prefixCls}-no-v-scroll`);
if (headerDom) {
removeClass(headerDom, `${prefixCls}-no-v-scroll`);
}
if (footerDom) {
removeClass(footerDom, `${prefixCls}-no-v-scroll`);
}
}
this.noVScroll = noVScroll;
}
}
checkBodyVScroll() {
if (this.bodyScroll) {
const { prefixCls } = this.props;
const node = this.bodyScroll.getDom();
// body does not exist if no data
if (node.children[0]) {
const wrapperHeight = node.clientHeight;
const bodyHeight = node.children[0].clientHeight;
const headerDom = this.headerScroll ? this.headerScroll.getDom() : null;
const footerDom = this.footerScroll ? this.footerScroll.getDom() : null;
const noVScroll = bodyHeight <= wrapperHeight;
if (this.noVScroll === undefined || this.noVScroll !== noVScroll) {
if (noVScroll) {
addClass(node, `${prefixCls}-no-v-scroll`);
if (headerDom) {
addClass(headerDom, `${prefixCls}-no-v-scroll`);
}
if (footerDom) {
addClass(footerDom, `${prefixCls}-no-v-scroll`);
}
} else {
removeClass(node, `${prefixCls}-no-v-scroll`);
if (headerDom) {
removeClass(headerDom, `${prefixCls}-no-v-scroll`);
}
if (footerDom) {
removeClass(footerDom, `${prefixCls}-no-v-scroll`);
}
}
this.noVScroll = noVScroll;
const node = this.bodyScroll.getDom();
// body does not exist if no data
if (node.children[0]) {
const wrapperHeight = node.clientHeight;
const bodyHeight = node.children[0].clientHeight;
const headerDom = this.headerScroll ? this.headerScroll.getDom() : null;
const footerDom = this.footerScroll ? this.footerScroll.getDom() : null;
const noVScroll = bodyHeight <= wrapperHeight;
if (this.noVScroll === undefined || this.noVScroll !== noVScroll) {
if (noVScroll) {
addClass(node, `${prefixCls}-no-v-scroll`);
if (headerDom) {
addClass(headerDom, `${prefixCls}-no-v-scroll`);
}
if (footerDom) {
addClass(footerDom, `${prefixCls}-no-v-scroll`);
}
} else {
removeClass(node, `${prefixCls}-no-v-scroll`);
if (headerDom) {
removeClass(headerDom, `${prefixCls}-no-v-scroll`);
}
if (footerDom) {
removeClass(footerDom, `${prefixCls}-no-v-scroll`);
}
}
this.noVScroll = noVScroll;
}
}
}
}
checkBodyHScroll(scrollLeft) {
if (!this.state.hasFixed) {
return false;
}
if (!this.bodyScroll) {
return false;
}
const node = this.bodyScroll.getDom();
const wrapperScrollLeft = scrollLeft || node.scrollLeft;
if (this.state.hasFixed.hasLeft && this.fixedTable) {
if (wrapperScrollLeft > 0) {
addClass(this.fixedTable, 'has-scroll');
} else {
removeClass(this.fixedTable, 'has-scroll');
}
}
if (this.state.hasFixed.hasRight) {
const wrapperWidth = node.clientWidth;
if (node.children[0]) {
const bodyWidth = node.children[0].clientWidth;
if (this.rightFixedTable) {
if (wrapperScrollLeft + wrapperWidth + 3 < bodyWidth) {
addClass(this.rightFixedTable, 'end-of-scroll');
} else {
removeClass(this.rightFixedTable, 'end-of-scroll');
}
}
}
const node = this.bodyScroll.getDom();
const wrapperScrollLeft = scrollLeft || node.scrollLeft;
if (this.state.hasFixed.hasLeft && this.fixedTable) {
if (wrapperScrollLeft > 0) {
addClass(this.fixedTable, 'has-scroll');
} else {
removeClass(this.fixedTable, 'has-scroll');
}
}
if (this.state.hasFixed.hasRight) {
const wrapperWidth = node.clientWidth;
if (node.children[0]) {
const bodyWidth = node.children[0].clientWidth;
if (this.rightFixedTable) {
if (wrapperScrollLeft + wrapperWidth + 3 < bodyWidth) {
addClass(this.rightFixedTable, 'end-of-scroll');
} else {
removeClass(this.rightFixedTable, 'end-of-scroll');
}
}
}
}
return false;
}