fix: scroll.Y变化时重新计算scrollTop

This commit is contained in:
gx 2021-02-03 16:52:30 +08:00
parent 0e2e866a5e
commit 5906420fc4
3 changed files with 16 additions and 2 deletions

9
dist/demo.js vendored
View File

@ -48265,8 +48265,15 @@
// 当懒加载手动设置的scroll.y发生变化时滚动条回到顶部
var prevScrollY = prevProps.scroll.y;
var currentScrollY = this.props.scroll.y;
if (prevScrollY && currentScrollY && prevScrollY !== currentScrollY && this.props.lazyLoad) {
if (prevScrollY && currentScrollY && prevScrollY !== currentScrollY && this.props.lazyLoad && !this.props.ignoreScrollYChange) {
this.bodyTable.scrollTop = 0;
} else if (this.props.ignoreScrollYChange && currentScrollY && prevScrollY && prevScrollY !== currentScrollY) {
var distance = this.bodyTable.scrollTop + (currentScrollY - prevScrollY);
if (distance < 0) {
this.bodyTable.scrollTop = 0;
} else {
this.bodyTable.scrollTop = distance;
}
}
// 是否传入 scroll中的y属性如果传入判断是否是整数如果是则进行比较 。bodyTable 的clientHeight进行判断
this.isShowScrollY();

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -275,6 +275,13 @@ class Table extends Component {
const currentScrollY = this.props.scroll.y
if (prevScrollY && currentScrollY && (prevScrollY !== currentScrollY) && this.props.lazyLoad && !this.props.ignoreScrollYChange) {
this.bodyTable.scrollTop = 0
} else if (this.props.ignoreScrollYChange && currentScrollY && prevScrollY && (prevScrollY !== currentScrollY)) {
const distance = this.bodyTable.scrollTop + (currentScrollY - prevScrollY)
if (distance < 0) {
this.bodyTable.scrollTop = 0
} else {
this.bodyTable.scrollTop = distance
}
}
// 是否传入 scroll中的y属性如果传入判断是否是整数如果是则进行比较 。bodyTable 的clientHeight进行判断
this.isShowScrollY();