This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

修复滚动组件的判断

old
宇天 2020-05-11 09:56:07 +08:00
parent f6cb2d8e76
commit fef32d4fef
1 changed files with 16 additions and 4 deletions

View File

@ -286,11 +286,17 @@ export default class Scroll {
// 滚动比例 y 滚动条的可移动距离
var fixedY = (this.__BOX__.scrollTop / (sh - oh)) * (oh - yh)
fixedY = fixedY >> 0
this.props.thumbY = fixedY
if (fixedY === 0 || oh - yh === fixedY) {
if (
(fixedY === 0 || oh - yh === fixedY) &&
fixedY === this.props.thumbY
) {
return
}
ev.preventDefault()
this.props.thumbY = fixedY
this.__Y__.style.transform = `translateY(${fixedY}px)`
}
}
@ -303,11 +309,17 @@ export default class Scroll {
// 滚动比例 x 滚动条的可移动距离
var fixedX = (this.__BOX__.scrollLeft / (sw - ow)) * (ow - xw)
fixedX = fixedX >> 0
this.props.thumbX = fixedX
if (fixedX === 0 || ow - xw === fixedX) {
if (
(fixedX === 0 || ow - xw === fixedX) &&
fixedX === this.props.thumbX
) {
return
}
ev.preventDefault()
this.props.thumbX = fixedX
this.__X__.style.transform = `translateX(${fixedX}px)`
}
}