fix: scroll.Y变化时重新计算scrollTop
This commit is contained in:
parent
0e2e866a5e
commit
5906420fc4
|
@ -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();
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue