Skip to content

Commit

Permalink
chore: 添加兜底判断
Browse files Browse the repository at this point in the history
  • Loading branch information
yandadaFreedom committed Dec 18, 2023
1 parent edc1525 commit 8e9306f
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,13 @@
},
initLayerComputed () {
const wrapper = this.$refs.wrapper
const computedStyle = getComputedStyle(wrapper)
// 考虑子元素样式可能会设置100%,如果直接继承 scrollContent 的样式可能会有问题
// 所以使用 wrapper 作为 innerWrapper 的宽高参考依据
this.$refs.innerWrapper.style.width = `${wrapper.clientWidth - parseInt(computedStyle.paddingLeft) - parseInt(computedStyle.paddingRight)}px`
this.$refs.innerWrapper.style.height = `${wrapper.clientHeight - parseInt(computedStyle.paddingTop) - parseInt(computedStyle.paddingBottom)}px`
if (wrapper) {
const computedStyle = getComputedStyle(wrapper)
// 考虑子元素样式可能会设置100%,如果直接继承 scrollContent 的样式可能会有问题
// 所以使用 wrapper 作为 innerWrapper 的宽高参考依据
this.$refs.innerWrapper.style.width = `${wrapper.clientWidth - parseInt(computedStyle.paddingLeft) - parseInt(computedStyle.paddingRight)}px`
this.$refs.innerWrapper.style.height = `${wrapper.clientHeight - parseInt(computedStyle.paddingTop) - parseInt(computedStyle.paddingBottom)}px`
}
const innerWrapper = this.$refs.innerWrapper
const childrenArr = Array.from(innerWrapper.children)
Expand Down Expand Up @@ -423,7 +425,10 @@
},
throttleRefresh: throttle(function () {
this.refresh()
}, 100),
}, 50, {
leading: false,
trailing: true
}),
shouldNotRefresh () {
const { scroller } = this.bs
const { scrollBehaviorX, scrollBehaviorY } = scroller
Expand Down

0 comments on commit 8e9306f

Please sign in to comment.